@itwin/ecschema-metadata 5.0.0-dev.8 → 5.0.0-dev.82

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 (274) hide show
  1. package/CHANGELOG.md +46 -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 +60 -20
  5. package/lib/cjs/Context.d.ts.map +1 -1
  6. package/lib/cjs/Context.js +43 -19
  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/XmlParser.js +11 -1
  22. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  23. package/lib/cjs/ECName.js +1 -0
  24. package/lib/cjs/ECName.js.map +1 -1
  25. package/lib/cjs/ECObjects.d.ts +21 -1
  26. package/lib/cjs/ECObjects.d.ts.map +1 -1
  27. package/lib/cjs/ECObjects.js +34 -2
  28. package/lib/cjs/ECObjects.js.map +1 -1
  29. package/lib/cjs/Exception.js +1 -0
  30. package/lib/cjs/Exception.js.map +1 -1
  31. package/lib/cjs/Interfaces.d.ts +10 -3
  32. package/lib/cjs/Interfaces.d.ts.map +1 -1
  33. package/lib/cjs/Interfaces.js.map +1 -1
  34. package/lib/cjs/Metadata/Class.d.ts +53 -5
  35. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  36. package/lib/cjs/Metadata/Class.js +118 -19
  37. package/lib/cjs/Metadata/Class.js.map +1 -1
  38. package/lib/cjs/Metadata/Constant.d.ts +14 -1
  39. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  40. package/lib/cjs/Metadata/Constant.js +27 -2
  41. package/lib/cjs/Metadata/Constant.js.map +1 -1
  42. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
  43. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  44. package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
  45. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  46. package/lib/cjs/Metadata/EntityClass.d.ts +18 -6
  47. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  48. package/lib/cjs/Metadata/EntityClass.js +29 -9
  49. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  50. package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
  51. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  52. package/lib/cjs/Metadata/Enumeration.js +22 -1
  53. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  54. package/lib/cjs/Metadata/Format.d.ts +41 -1
  55. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  56. package/lib/cjs/Metadata/Format.js +68 -3
  57. package/lib/cjs/Metadata/Format.js.map +1 -1
  58. package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
  59. package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
  60. package/lib/cjs/Metadata/InvertedUnit.js +17 -6
  61. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  62. package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
  63. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  64. package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
  65. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  66. package/lib/cjs/Metadata/Mixin.d.ts +15 -1
  67. package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
  68. package/lib/cjs/Metadata/Mixin.js +23 -2
  69. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  70. package/lib/cjs/Metadata/OverrideFormat.js +9 -0
  71. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  72. package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
  73. package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
  74. package/lib/cjs/Metadata/Phenomenon.js +22 -1
  75. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  76. package/lib/cjs/Metadata/Property.d.ts +1 -1
  77. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  78. package/lib/cjs/Metadata/Property.js +83 -28
  79. package/lib/cjs/Metadata/Property.js.map +1 -1
  80. package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
  81. package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
  82. package/lib/cjs/Metadata/PropertyCategory.js +21 -1
  83. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  84. package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
  85. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  86. package/lib/cjs/Metadata/RelationshipClass.js +47 -10
  87. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  88. package/lib/cjs/Metadata/Schema.d.ts +116 -11
  89. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  90. package/lib/cjs/Metadata/Schema.js +135 -33
  91. package/lib/cjs/Metadata/Schema.js.map +1 -1
  92. package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
  93. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  94. package/lib/cjs/Metadata/SchemaItem.js +10 -0
  95. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  96. package/lib/cjs/Metadata/Unit.d.ts +8 -1
  97. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  98. package/lib/cjs/Metadata/Unit.js +21 -3
  99. package/lib/cjs/Metadata/Unit.js.map +1 -1
  100. package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
  101. package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
  102. package/lib/cjs/Metadata/UnitSystem.js +21 -3
  103. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  104. package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
  105. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  106. package/lib/cjs/SchemaJsonLocater.js +3 -3
  107. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  108. package/lib/cjs/SchemaKey.d.ts +7 -1
  109. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  110. package/lib/cjs/SchemaKey.js +13 -3
  111. package/lib/cjs/SchemaKey.js.map +1 -1
  112. package/lib/cjs/SchemaLoader.d.ts +2 -2
  113. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  114. package/lib/cjs/SchemaLoader.js +1 -0
  115. package/lib/cjs/SchemaLoader.js.map +1 -1
  116. package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
  117. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  118. package/lib/cjs/UnitConversion/Graph.js +69 -65
  119. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  120. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
  121. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  122. package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
  123. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  124. package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
  125. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  126. package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
  127. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  128. package/lib/cjs/UnitConversion/UnitTree.js +11 -1
  129. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  130. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +6 -3
  131. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  132. package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
  133. package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
  134. package/lib/cjs/Validation/SchemaWalker.js +4 -0
  135. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  136. package/lib/cjs/utils/SchemaGraph.js +2 -3
  137. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  138. package/lib/esm/Constants.js +20 -20
  139. package/lib/esm/Constants.js.map +1 -1
  140. package/lib/esm/Context.d.ts +60 -20
  141. package/lib/esm/Context.d.ts.map +1 -1
  142. package/lib/esm/Context.js +41 -17
  143. package/lib/esm/Context.js.map +1 -1
  144. package/lib/esm/DelayedPromise.js +6 -4
  145. package/lib/esm/DelayedPromise.js.map +1 -1
  146. package/lib/esm/Deserialization/AbstractParser.js +1 -0
  147. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  148. package/lib/esm/Deserialization/Helper.d.ts +3 -3
  149. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  150. package/lib/esm/Deserialization/Helper.js +8 -0
  151. package/lib/esm/Deserialization/Helper.js.map +1 -1
  152. package/lib/esm/Deserialization/JsonParser.js +3 -0
  153. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  154. package/lib/esm/Deserialization/JsonProps.d.ts +3 -0
  155. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  156. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  157. package/lib/esm/Deserialization/XmlParser.js +11 -1
  158. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  159. package/lib/esm/ECName.js +1 -0
  160. package/lib/esm/ECName.js.map +1 -1
  161. package/lib/esm/ECObjects.d.ts +21 -1
  162. package/lib/esm/ECObjects.d.ts.map +1 -1
  163. package/lib/esm/ECObjects.js +32 -1
  164. package/lib/esm/ECObjects.js.map +1 -1
  165. package/lib/esm/Exception.js +1 -0
  166. package/lib/esm/Exception.js.map +1 -1
  167. package/lib/esm/Interfaces.d.ts +10 -3
  168. package/lib/esm/Interfaces.d.ts.map +1 -1
  169. package/lib/esm/Interfaces.js.map +1 -1
  170. package/lib/esm/Metadata/Class.d.ts +53 -5
  171. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  172. package/lib/esm/Metadata/Class.js +119 -20
  173. package/lib/esm/Metadata/Class.js.map +1 -1
  174. package/lib/esm/Metadata/Constant.d.ts +14 -1
  175. package/lib/esm/Metadata/Constant.d.ts.map +1 -1
  176. package/lib/esm/Metadata/Constant.js +27 -2
  177. package/lib/esm/Metadata/Constant.js.map +1 -1
  178. package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
  179. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
  180. package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
  181. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  182. package/lib/esm/Metadata/EntityClass.d.ts +18 -6
  183. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  184. package/lib/esm/Metadata/EntityClass.js +29 -9
  185. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  186. package/lib/esm/Metadata/Enumeration.d.ts +14 -1
  187. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
  188. package/lib/esm/Metadata/Enumeration.js +22 -1
  189. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  190. package/lib/esm/Metadata/Format.d.ts +41 -1
  191. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  192. package/lib/esm/Metadata/Format.js +68 -3
  193. package/lib/esm/Metadata/Format.js.map +1 -1
  194. package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
  195. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
  196. package/lib/esm/Metadata/InvertedUnit.js +17 -6
  197. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  198. package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
  199. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  200. package/lib/esm/Metadata/KindOfQuantity.js +43 -18
  201. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  202. package/lib/esm/Metadata/Mixin.d.ts +15 -1
  203. package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
  204. package/lib/esm/Metadata/Mixin.js +24 -3
  205. package/lib/esm/Metadata/Mixin.js.map +1 -1
  206. package/lib/esm/Metadata/OverrideFormat.js +9 -0
  207. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  208. package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
  209. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
  210. package/lib/esm/Metadata/Phenomenon.js +22 -1
  211. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  212. package/lib/esm/Metadata/Property.d.ts +1 -1
  213. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  214. package/lib/esm/Metadata/Property.js +84 -29
  215. package/lib/esm/Metadata/Property.js.map +1 -1
  216. package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
  217. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
  218. package/lib/esm/Metadata/PropertyCategory.js +21 -1
  219. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  220. package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
  221. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  222. package/lib/esm/Metadata/RelationshipClass.js +48 -11
  223. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  224. package/lib/esm/Metadata/Schema.d.ts +116 -11
  225. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  226. package/lib/esm/Metadata/Schema.js +135 -33
  227. package/lib/esm/Metadata/Schema.js.map +1 -1
  228. package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
  229. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  230. package/lib/esm/Metadata/SchemaItem.js +11 -1
  231. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  232. package/lib/esm/Metadata/Unit.d.ts +8 -1
  233. package/lib/esm/Metadata/Unit.d.ts.map +1 -1
  234. package/lib/esm/Metadata/Unit.js +21 -3
  235. package/lib/esm/Metadata/Unit.js.map +1 -1
  236. package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
  237. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
  238. package/lib/esm/Metadata/UnitSystem.js +21 -3
  239. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  240. package/lib/esm/SchemaJsonLocater.d.ts +3 -3
  241. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
  242. package/lib/esm/SchemaJsonLocater.js +3 -3
  243. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  244. package/lib/esm/SchemaKey.d.ts +7 -1
  245. package/lib/esm/SchemaKey.d.ts.map +1 -1
  246. package/lib/esm/SchemaKey.js +13 -3
  247. package/lib/esm/SchemaKey.js.map +1 -1
  248. package/lib/esm/SchemaLoader.d.ts +2 -2
  249. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  250. package/lib/esm/SchemaLoader.js +1 -0
  251. package/lib/esm/SchemaLoader.js.map +1 -1
  252. package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
  253. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  254. package/lib/esm/UnitConversion/Graph.js +69 -65
  255. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  256. package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
  257. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
  258. package/lib/esm/UnitConversion/UnitConversion.js +9 -7
  259. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  260. package/lib/esm/UnitConversion/UnitConverter.js +2 -0
  261. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  262. package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
  263. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  264. package/lib/esm/UnitConversion/UnitTree.js +11 -1
  265. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  266. package/lib/esm/UnitProvider/SchemaUnitProvider.js +6 -3
  267. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  268. package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
  269. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
  270. package/lib/esm/Validation/SchemaWalker.js +4 -0
  271. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  272. package/lib/esm/utils/SchemaGraph.js +2 -3
  273. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  274. package/package.json +14 -14
@@ -12,7 +12,8 @@ import { Unit } from "./Unit";
12
12
  * @beta
13
13
  */
14
14
  export declare class Format extends SchemaItem {
15
- readonly schemaItemType: SchemaItemType.Format;
15
+ readonly schemaItemType: SchemaItemType;
16
+ static get schemaItemType(): SchemaItemType;
16
17
  protected _base: BaseFormat;
17
18
  protected _units?: Array<[Unit | InvertedUnit, string | undefined]>;
18
19
  constructor(schema: Schema, name: string);
@@ -79,6 +80,45 @@ export declare class Format extends SchemaItem {
79
80
  * @alpha Used in schema editing.
80
81
  */
81
82
  protected setStationSeparator(separator: string): void;
83
+ /**
84
+ * @alpha Used in schema editing.
85
+ */
86
+ protected setStationOffsetSize(stationOffsetSize: number): void;
87
+ /**
88
+ * @alpha Used in schema editing.
89
+ */
90
+ protected setScientificType(scientificType: ScientificType): void;
91
+ /**
92
+ * @alpha Used in schema editing.
93
+ */
94
+ protected setMinWidth(minWidth: number): void;
95
+ /**
96
+ * @alpha Used in schema editing.
97
+ */
98
+ protected setSpacer(spacer: string): void;
99
+ /**
100
+ * @alpha Used in schema editing.
101
+ */
102
+ protected setIncludeZero(includeZero: boolean): void;
103
+ /**
104
+ * @alpha Used in schema editing.
105
+ */
106
+ protected setFormatTraits(formatTraits: FormatTraits): void;
107
+ /**
108
+ * @alpha Used in schema editing.
109
+ */
110
+ protected setUnits(units: Array<[Unit | InvertedUnit, string | undefined]>): void;
111
+ /** Type guard to check if the SchemaItem is of type Format.
112
+ * @param item The SchemaItem to check.
113
+ * @returns True if the item is a Format, false otherwise.
114
+ */
115
+ static isFormat(item?: SchemaItem): item is Format;
116
+ /**
117
+ * Type assertion to check if the SchemaItem is of type Format.
118
+ * @param item The SchemaItem to check.
119
+ * @returns The item cast to Format if it is a Format, undefined otherwise.
120
+ */
121
+ static assertIsFormat(item?: SchemaItem): asserts item is Format;
82
122
  }
83
123
  /**
84
124
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Format.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Format.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAuB,UAAU,EAAE,mBAAmB,EAChG,cAAc,EAAE,cAAc,EAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,qBAAa,MAAO,SAAQ,UAAU;IACpC,SAAyB,cAAc,EAAG,cAAc,CAAC,MAAM,CAAC;IAChE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC;IAC5B,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;gB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
  import { SchemaItemType } from "../ECObjects";
10
10
  import { ECObjectsError, ECObjectsStatus } from "../Exception";
11
11
  import { BaseFormat, FormatTraits, formatTraitsToArray, FormatType, ShowSignOption, } from "@itwin/core-quantity";
12
+ import { InvertedUnit } from "./InvertedUnit";
12
13
  import { SchemaItem } from "./SchemaItem";
14
+ import { Unit } from "./Unit";
13
15
  /**
14
16
  * @beta
15
17
  */
16
18
  export class Format extends SchemaItem {
19
+ schemaItemType = Format.schemaItemType;
20
+ static get schemaItemType() { return SchemaItemType.Format; }
21
+ _base;
22
+ _units;
17
23
  constructor(schema, name) {
18
24
  super(schema, name);
19
- this.schemaItemType = SchemaItemType.Format;
20
25
  this._base = new BaseFormat(name);
21
26
  }
22
27
  get roundFactor() { return this._base.roundFactor; }
@@ -80,7 +85,7 @@ export class Format extends SchemaItem {
80
85
  // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation
81
86
  for (const unit of formatProps.composite.units) {
82
87
  const newUnit = this.schema.lookupItemSync(unit.name);
83
- if (undefined === newUnit)
88
+ if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))
84
89
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
85
90
  this.addUnit(newUnit, unit.label);
86
91
  }
@@ -93,7 +98,7 @@ export class Format extends SchemaItem {
93
98
  // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation
94
99
  for (const unit of formatProps.composite.units) {
95
100
  const newUnit = await this.schema.lookupItem(unit.name);
96
- if (undefined === newUnit)
101
+ if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))
97
102
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
98
103
  this.addUnit(newUnit, unit.label);
99
104
  }
@@ -228,6 +233,66 @@ export class Format extends SchemaItem {
228
233
  setStationSeparator(separator) {
229
234
  this._base.stationSeparator = separator;
230
235
  }
236
+ /**
237
+ * @alpha Used in schema editing.
238
+ */
239
+ setStationOffsetSize(stationOffsetSize) {
240
+ this._base.stationOffsetSize = stationOffsetSize;
241
+ }
242
+ /**
243
+ * @alpha Used in schema editing.
244
+ */
245
+ setScientificType(scientificType) {
246
+ this._base.scientificType = scientificType;
247
+ }
248
+ /**
249
+ * @alpha Used in schema editing.
250
+ */
251
+ setMinWidth(minWidth) {
252
+ this._base.minWidth = minWidth;
253
+ }
254
+ /**
255
+ * @alpha Used in schema editing.
256
+ */
257
+ setSpacer(spacer) {
258
+ this._base.spacer = spacer;
259
+ }
260
+ /**
261
+ * @alpha Used in schema editing.
262
+ */
263
+ setIncludeZero(includeZero) {
264
+ this._base.includeZero = includeZero;
265
+ }
266
+ /**
267
+ * @alpha Used in schema editing.
268
+ */
269
+ setFormatTraits(formatTraits) {
270
+ this._base.formatTraits = formatTraits;
271
+ }
272
+ /**
273
+ * @alpha Used in schema editing.
274
+ */
275
+ setUnits(units) {
276
+ this._units = units;
277
+ }
278
+ /** Type guard to check if the SchemaItem is of type Format.
279
+ * @param item The SchemaItem to check.
280
+ * @returns True if the item is a Format, false otherwise.
281
+ */
282
+ static isFormat(item) {
283
+ if (item && item.schemaItemType === SchemaItemType.Format)
284
+ return true;
285
+ return false;
286
+ }
287
+ /**
288
+ * Type assertion to check if the SchemaItem is of type Format.
289
+ * @param item The SchemaItem to check.
290
+ * @returns The item cast to Format if it is a Format, undefined otherwise.
291
+ */
292
+ static assertIsFormat(item) {
293
+ if (!this.isFormat(item))
294
+ throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Format}' (Format)`);
295
+ }
231
296
  }
232
297
  /**
233
298
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Metadata/Format.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,C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S,CAAC;IAC1C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,MAAM;CAWjD","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 { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport {\n BaseFormat, DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\n ScientificType, ShowSignOption,\n} from \"@itwin/core-quantity\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/**\n * @beta\n */\nexport class Format extends SchemaItem {\n public override readonly schemaItemType!: SchemaItemType.Format;\n protected _base: BaseFormat;\n protected _units?: Array<[Unit | InvertedUnit, string | undefined]>;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this.schemaItemType = SchemaItemType.Format;\n\n this._base = new BaseFormat(name);\n }\n\n public get roundFactor(): number { return this._base.roundFactor; }\n public get type(): FormatType { return this._base.type; }\n public get precision(): DecimalPrecision | FractionalPrecision { return this._base.precision; }\n public get minWidth(): number | undefined { return this._base.minWidth; }\n public get scientificType(): ScientificType | undefined { return this._base.scientificType; }\n public get showSignOption(): ShowSignOption { return this._base.showSignOption; }\n public get decimalSeparator(): string { return this._base.decimalSeparator; }\n public get thousandSeparator(): string { return this._base.thousandSeparator; }\n public get uomSeparator(): string { return this._base.uomSeparator; }\n public get stationSeparator(): string { return this._base.stationSeparator; }\n public get stationOffsetSize(): number | undefined { return this._base.stationOffsetSize; }\n public get formatTraits(): FormatTraits { return this._base.formatTraits; }\n public get spacer(): string | undefined { return this._base.spacer; }\n public get includeZero(): boolean | undefined { return this._base.includeZero; }\n public get units(): Array<[Unit | InvertedUnit, string | undefined]> | undefined { return this._units; }\n\n private parseFormatTraits(formatTraitsFromJson: string | string[]) {\n return this._base.parseFormatTraits(formatTraitsFromJson);\n }\n\n public hasFormatTrait(formatTrait: FormatTraits) {\n return this._base.hasFormatTraitSet(formatTrait);\n }\n\n /**\n * Adds a Unit, or InvertedUnit, with an optional label override.\n * @param unit The Unit, or InvertedUnit, to add to this Format.\n * @param label A label that overrides the label defined within the Unit when a value is formatted.\n */\n protected addUnit(unit: Unit | InvertedUnit, label?: string) {\n if (undefined === this._units)\n this._units = [];\n else { // Validate that a duplicate is not added.\n for (const existingUnit of this._units) {\n if (unit.fullName.toLowerCase() === existingUnit[0].fullName.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has duplicate units, '${unit.fullName}'.`); // TODO: Validation - this should be a validation error not a hard failure.\n }\n }\n\n this._units.push([unit, label]);\n }\n\n protected setPrecision(precision: number) { this._base.precision = precision; }\n\n private typecheck(formatProps: SchemaItemFormatProps) {\n this._base.loadFormatProperties(formatProps);\n\n if (undefined !== formatProps.composite) { // TODO: This is duplicated below when the units need to be processed...\n if (undefined !== formatProps.composite.includeZero)\n this._base.includeZero = formatProps.composite.includeZero;\n\n if (undefined !== formatProps.composite.spacer) {\n if (formatProps.composite.spacer.length > 1)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has a composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._base.spacer = formatProps.composite.spacer;\n }\n\n // Composite requires 1-4 units\n if (formatProps.composite.units.length <= 0 || formatProps.composite.units.length > 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);\n }\n }\n\n public override fromJSONSync(formatProps: SchemaItemFormatProps) {\n super.fromJSONSync(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = this.schema.lookupItemSync<Unit | InvertedUnit>(unit.name);\n if (undefined === newUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n public override async fromJSON(formatProps: SchemaItemFormatProps) {\n await super.fromJSON(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = await this.schema.lookupItem<Unit | InvertedUnit>(unit.name);\n if (undefined === newUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n /**\n * Save this Format's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): SchemaItemFormatProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.type = this.type;\n schemaJson.precision = this.precision;\n\n // this._spacer = \" \";\n // this._includeZero = true;\n\n // Serialize the minimal amount of information needed so anything that is the same as the default, do not serialize.\n if (0.0 !== this.roundFactor)\n schemaJson.roundFactor = this.roundFactor;\n if (ShowSignOption.OnlyNegative !== this.showSignOption)\n schemaJson.showSignOption = this.showSignOption;\n if (FormatTraits.Uninitialized !== this.formatTraits)\n schemaJson.formatTraits = formatTraitsToArray(this.formatTraits);\n if (\".\" !== this.decimalSeparator)\n schemaJson.decimalSeparator = this.decimalSeparator;\n if (\",\" !== this.thousandSeparator)\n schemaJson.thousandSeparator = this.thousandSeparator;\n if (\" \" !== this.uomSeparator)\n schemaJson.uomSeparator = this.uomSeparator;\n\n if (undefined !== this.minWidth)\n schemaJson.minWidth = this.minWidth;\n\n if (FormatType.Scientific === this.type && undefined !== this.scientificType)\n schemaJson.scientificType = this.scientificType;\n\n if (FormatType.Station === this.type) {\n if (undefined !== this.stationOffsetSize)\n schemaJson.stationOffsetSize = this.stationOffsetSize;\n if (\" \" !== this.stationSeparator)\n schemaJson.stationSeparator = this.stationSeparator;\n }\n\n if (undefined === this.units)\n return schemaJson;\n\n schemaJson.composite = {};\n\n if (\" \" !== this.spacer)\n schemaJson.composite.spacer = this.spacer;\n\n if (true !== this.includeZero)\n schemaJson.composite.includeZero = this.includeZero;\n\n schemaJson.composite.units = [];\n for (const unit of this.units) {\n schemaJson.composite.units.push({\n name: unit[0].fullName,\n label: unit[1],\n });\n }\n\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"type\", this.type.toLowerCase());\n itemElement.setAttribute(\"precision\", this.precision.toString());\n itemElement.setAttribute(\"roundFactor\", this.roundFactor.toString());\n itemElement.setAttribute(\"showSignOption\", this.showSignOption);\n itemElement.setAttribute(\"decimalSeparator\", this.decimalSeparator);\n itemElement.setAttribute(\"thousandSeparator\", this.thousandSeparator);\n itemElement.setAttribute(\"uomSeparator\", this.uomSeparator);\n itemElement.setAttribute(\"stationSeparator\", this.stationSeparator);\n\n if (undefined !== this.minWidth)\n itemElement.setAttribute(\"minWidth\", this.minWidth.toString());\n if (undefined !== this.scientificType)\n itemElement.setAttribute(\"scientificType\", this.scientificType);\n if (undefined !== this.stationOffsetSize)\n itemElement.setAttribute(\"stationOffsetSize\", this.stationOffsetSize.toString());\n\n const formatTraits = formatTraitsToArray(this.formatTraits);\n if (formatTraits.length > 0)\n itemElement.setAttribute(\"formatTraits\", formatTraits.join(\"|\"));\n\n if (undefined !== this.units) {\n const compositeElement = schemaXml.createElement(\"Composite\");\n if (undefined !== this.spacer)\n compositeElement.setAttribute(\"spacer\", this.spacer);\n if (undefined !== this.includeZero)\n compositeElement.setAttribute(\"includeZero\", this.includeZero.toString());\n\n this.units.forEach(([unit, label]) => {\n const unitElement = schemaXml.createElement(\"Unit\");\n if (undefined !== label)\n unitElement.setAttribute(\"label\", label);\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, unit.schema, unit.name);\n unitElement.textContent = unitName;\n compositeElement.appendChild(unitElement);\n });\n\n itemElement.appendChild(compositeElement);\n }\n\n return itemElement;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatType(formatType: FormatType) {\n this._base.type = formatType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setRoundFactor(roundFactor: number) {\n this._base.roundFactor = roundFactor;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setShowSignOption(signOption: ShowSignOption) {\n this._base.showSignOption = signOption;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDecimalSeparator(separator: string) {\n this._base.decimalSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setThousandSeparator(separator: string) {\n this._base.thousandSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUomSeparator(separator: string) {\n this._base.uomSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationSeparator(separator: string) {\n this._base.stationSeparator = separator;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableFormat extends Format {\n public abstract override addUnit(unit: Unit | InvertedUnit, label?: string): void;\n public abstract override setPrecision(precision: number): void;\n public abstract override setFormatType(formatType: FormatType): void;\n public abstract override setRoundFactor(roundFactor: number): void;\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\n public abstract override setDecimalSeparator(separator: string): void;\n public abstract override setThousandSeparator(separator: string): void;\n public abstract override setUomSeparator(separator: string): void;\n public abstract override setStationSeparator(separator: string): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
1
+ {"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Metadata/Format.ts"],"names":[],"m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QACxE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAiB;QACxC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,MAAM;YACvD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,IAAiB;QAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACtB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,MAAM,YAAY,CAAC,CAAC;IACpH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,MAAM;CAWjD","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 { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport {\n BaseFormat, DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\n ScientificType, ShowSignOption,\n} from \"@itwin/core-quantity\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/**\n * @beta\n */\nexport class Format extends SchemaItem {\n public override readonly schemaItemType = Format.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Format; }\n protected _base: BaseFormat;\n protected _units?: Array<[Unit | InvertedUnit, string | undefined]>;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._base = new BaseFormat(name);\n }\n\n public get roundFactor(): number { return this._base.roundFactor; }\n public get type(): FormatType { return this._base.type; }\n public get precision(): DecimalPrecision | FractionalPrecision { return this._base.precision; }\n public get minWidth(): number | undefined { return this._base.minWidth; }\n public get scientificType(): ScientificType | undefined { return this._base.scientificType; }\n public get showSignOption(): ShowSignOption { return this._base.showSignOption; }\n public get decimalSeparator(): string { return this._base.decimalSeparator; }\n public get thousandSeparator(): string { return this._base.thousandSeparator; }\n public get uomSeparator(): string { return this._base.uomSeparator; }\n public get stationSeparator(): string { return this._base.stationSeparator; }\n public get stationOffsetSize(): number | undefined { return this._base.stationOffsetSize; }\n public get formatTraits(): FormatTraits { return this._base.formatTraits; }\n public get spacer(): string | undefined { return this._base.spacer; }\n public get includeZero(): boolean | undefined { return this._base.includeZero; }\n public get units(): Array<[Unit | InvertedUnit, string | undefined]> | undefined { return this._units; }\n\n private parseFormatTraits(formatTraitsFromJson: string | string[]) {\n return this._base.parseFormatTraits(formatTraitsFromJson);\n }\n\n public hasFormatTrait(formatTrait: FormatTraits) {\n return this._base.hasFormatTraitSet(formatTrait);\n }\n\n /**\n * Adds a Unit, or InvertedUnit, with an optional label override.\n * @param unit The Unit, or InvertedUnit, to add to this Format.\n * @param label A label that overrides the label defined within the Unit when a value is formatted.\n */\n protected addUnit(unit: Unit | InvertedUnit, label?: string) {\n if (undefined === this._units)\n this._units = [];\n else { // Validate that a duplicate is not added.\n for (const existingUnit of this._units) {\n if (unit.fullName.toLowerCase() === existingUnit[0].fullName.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has duplicate units, '${unit.fullName}'.`); // TODO: Validation - this should be a validation error not a hard failure.\n }\n }\n\n this._units.push([unit, label]);\n }\n\n protected setPrecision(precision: number) { this._base.precision = precision; }\n\n private typecheck(formatProps: SchemaItemFormatProps) {\n this._base.loadFormatProperties(formatProps);\n\n if (undefined !== formatProps.composite) { // TODO: This is duplicated below when the units need to be processed...\n if (undefined !== formatProps.composite.includeZero)\n this._base.includeZero = formatProps.composite.includeZero;\n\n if (undefined !== formatProps.composite.spacer) {\n if (formatProps.composite.spacer.length > 1)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has a composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._base.spacer = formatProps.composite.spacer;\n }\n\n // Composite requires 1-4 units\n if (formatProps.composite.units.length <= 0 || formatProps.composite.units.length > 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);\n }\n }\n\n public override fromJSONSync(formatProps: SchemaItemFormatProps) {\n super.fromJSONSync(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = this.schema.lookupItemSync(unit.name);\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n public override async fromJSON(formatProps: SchemaItemFormatProps) {\n await super.fromJSON(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = await this.schema.lookupItem(unit.name);\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n /**\n * Save this Format's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): SchemaItemFormatProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.type = this.type;\n schemaJson.precision = this.precision;\n\n // this._spacer = \" \";\n // this._includeZero = true;\n\n // Serialize the minimal amount of information needed so anything that is the same as the default, do not serialize.\n if (0.0 !== this.roundFactor)\n schemaJson.roundFactor = this.roundFactor;\n if (ShowSignOption.OnlyNegative !== this.showSignOption)\n schemaJson.showSignOption = this.showSignOption;\n if (FormatTraits.Uninitialized !== this.formatTraits)\n schemaJson.formatTraits = formatTraitsToArray(this.formatTraits);\n if (\".\" !== this.decimalSeparator)\n schemaJson.decimalSeparator = this.decimalSeparator;\n if (\",\" !== this.thousandSeparator)\n schemaJson.thousandSeparator = this.thousandSeparator;\n if (\" \" !== this.uomSeparator)\n schemaJson.uomSeparator = this.uomSeparator;\n\n if (undefined !== this.minWidth)\n schemaJson.minWidth = this.minWidth;\n\n if (FormatType.Scientific === this.type && undefined !== this.scientificType)\n schemaJson.scientificType = this.scientificType;\n\n if (FormatType.Station === this.type) {\n if (undefined !== this.stationOffsetSize)\n schemaJson.stationOffsetSize = this.stationOffsetSize;\n if (\" \" !== this.stationSeparator)\n schemaJson.stationSeparator = this.stationSeparator;\n }\n\n if (undefined === this.units)\n return schemaJson;\n\n schemaJson.composite = {};\n\n if (\" \" !== this.spacer)\n schemaJson.composite.spacer = this.spacer;\n\n if (true !== this.includeZero)\n schemaJson.composite.includeZero = this.includeZero;\n\n schemaJson.composite.units = [];\n for (const unit of this.units) {\n schemaJson.composite.units.push({\n name: unit[0].fullName,\n label: unit[1],\n });\n }\n\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"type\", this.type.toLowerCase());\n itemElement.setAttribute(\"precision\", this.precision.toString());\n itemElement.setAttribute(\"roundFactor\", this.roundFactor.toString());\n itemElement.setAttribute(\"showSignOption\", this.showSignOption);\n itemElement.setAttribute(\"decimalSeparator\", this.decimalSeparator);\n itemElement.setAttribute(\"thousandSeparator\", this.thousandSeparator);\n itemElement.setAttribute(\"uomSeparator\", this.uomSeparator);\n itemElement.setAttribute(\"stationSeparator\", this.stationSeparator);\n\n if (undefined !== this.minWidth)\n itemElement.setAttribute(\"minWidth\", this.minWidth.toString());\n if (undefined !== this.scientificType)\n itemElement.setAttribute(\"scientificType\", this.scientificType);\n if (undefined !== this.stationOffsetSize)\n itemElement.setAttribute(\"stationOffsetSize\", this.stationOffsetSize.toString());\n\n const formatTraits = formatTraitsToArray(this.formatTraits);\n if (formatTraits.length > 0)\n itemElement.setAttribute(\"formatTraits\", formatTraits.join(\"|\"));\n\n if (undefined !== this.units) {\n const compositeElement = schemaXml.createElement(\"Composite\");\n if (undefined !== this.spacer)\n compositeElement.setAttribute(\"spacer\", this.spacer);\n if (undefined !== this.includeZero)\n compositeElement.setAttribute(\"includeZero\", this.includeZero.toString());\n\n this.units.forEach(([unit, label]) => {\n const unitElement = schemaXml.createElement(\"Unit\");\n if (undefined !== label)\n unitElement.setAttribute(\"label\", label);\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, unit.schema, unit.name);\n unitElement.textContent = unitName;\n compositeElement.appendChild(unitElement);\n });\n\n itemElement.appendChild(compositeElement);\n }\n\n return itemElement;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatType(formatType: FormatType) {\n this._base.type = formatType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setRoundFactor(roundFactor: number) {\n this._base.roundFactor = roundFactor;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setShowSignOption(signOption: ShowSignOption) {\n this._base.showSignOption = signOption;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDecimalSeparator(separator: string) {\n this._base.decimalSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setThousandSeparator(separator: string) {\n this._base.thousandSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUomSeparator(separator: string) {\n this._base.uomSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationSeparator(separator: string) {\n this._base.stationSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationOffsetSize(stationOffsetSize: number) {\n this._base.stationOffsetSize = stationOffsetSize;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setScientificType(scientificType: ScientificType) {\n this._base.scientificType = scientificType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setMinWidth(minWidth: number) {\n this._base.minWidth = minWidth;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setSpacer(spacer: string) {\n this._base.spacer = spacer;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setIncludeZero(includeZero: boolean) {\n this._base.includeZero = includeZero;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatTraits(formatTraits: FormatTraits) {\n this._base.formatTraits = formatTraits;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUnits(units: Array<[Unit | InvertedUnit, string | undefined]>) {\n this._units = units;\n }\n\n /** Type guard to check if the SchemaItem is of type Format.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Format, false otherwise.\n */\n public static isFormat(item?: SchemaItem): item is Format {\n if (item && item.schemaItemType === SchemaItemType.Format)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Format.\n * @param item The SchemaItem to check.\n * @returns The item cast to Format if it is a Format, undefined otherwise.\n */\n public static assertIsFormat(item?: SchemaItem): asserts item is Format {\n if (!this.isFormat(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Format}' (Format)`);\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableFormat extends Format {\n public abstract override addUnit(unit: Unit | InvertedUnit, label?: string): void;\n public abstract override setPrecision(precision: number): void;\n public abstract override setFormatType(formatType: FormatType): void;\n public abstract override setRoundFactor(roundFactor: number): void;\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\n public abstract override setDecimalSeparator(separator: string): void;\n public abstract override setThousandSeparator(separator: string): void;\n public abstract override setUomSeparator(separator: string): void;\n public abstract override setStationSeparator(separator: string): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -4,23 +4,28 @@
4
4
  import { InvertedUnitProps } from "../Deserialization/JsonProps";
5
5
  import { SchemaItemType } from "../ECObjects";
6
6
  import { LazyLoadedUnit, LazyLoadedUnitSystem } from "../Interfaces";
7
- import { Schema } from "./Schema";
8
7
  import { SchemaItem } from "./SchemaItem";
9
8
  /**
10
9
  * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
11
10
  * @beta
12
11
  */
13
12
  export declare class InvertedUnit extends SchemaItem {
14
- readonly schemaItemType: SchemaItemType.InvertedUnit;
13
+ readonly schemaItemType: SchemaItemType;
14
+ static get schemaItemType(): SchemaItemType;
15
15
  protected _invertsUnit?: LazyLoadedUnit;
16
16
  protected _unitSystem?: LazyLoadedUnitSystem;
17
- constructor(schema: Schema, name: string);
18
17
  get invertsUnit(): LazyLoadedUnit | undefined;
19
18
  get unitSystem(): LazyLoadedUnitSystem | undefined;
20
19
  /**
21
20
  * @alpha
22
21
  */
23
22
  static isInvertedUnit(object: any): object is InvertedUnit;
23
+ /**
24
+ * Type assertion to check if the SchemaItem is of type InvertedUnit.
25
+ * @param item The SchemaItem to check.
26
+ * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
27
+ */
28
+ static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit;
24
29
  /**
25
30
  * Save this InvertedUnit's properties to an object for serializing to JSON.
26
31
  * @param standalone Serialization includes only this object (as opposed to the full schema).
@@ -1 +1 @@
1
- {"version":3,"file":"InvertedUnit.d.ts","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,cAAc,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AAE,cAAc,GAAG,IAAI;aACjD,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;aACrD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -10,15 +10,17 @@ import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils"
10
10
  import { SchemaItemType } from "../ECObjects";
11
11
  import { ECObjectsError, ECObjectsStatus } from "../Exception";
12
12
  import { SchemaItem } from "./SchemaItem";
13
+ import { Unit } from "./Unit";
14
+ import { UnitSystem } from "./UnitSystem";
13
15
  /**
14
16
  * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
15
17
  * @beta
16
18
  */
17
19
  export class InvertedUnit extends SchemaItem {
18
- constructor(schema, name) {
19
- super(schema, name);
20
- this.schemaItemType = SchemaItemType.InvertedUnit;
21
- }
20
+ schemaItemType = InvertedUnit.schemaItemType;
21
+ static get schemaItemType() { return SchemaItemType.InvertedUnit; }
22
+ _invertsUnit; // required
23
+ _unitSystem; // required
22
24
  get invertsUnit() { return this._invertsUnit; }
23
25
  get unitSystem() { return this._unitSystem; }
24
26
  /**
@@ -27,6 +29,15 @@ export class InvertedUnit extends SchemaItem {
27
29
  static isInvertedUnit(object) {
28
30
  return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.InvertedUnit;
29
31
  }
32
+ /**
33
+ * Type assertion to check if the SchemaItem is of type InvertedUnit.
34
+ * @param item The SchemaItem to check.
35
+ * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
36
+ */
37
+ static assertIsInvertedUnit(item) {
38
+ if (!this.isInvertedUnit(item))
39
+ throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);
40
+ }
30
41
  /**
31
42
  * Save this InvertedUnit's properties to an object for serializing to JSON.
32
43
  * @param standalone Serialization includes only this object (as opposed to the full schema).
@@ -57,7 +68,7 @@ export class InvertedUnit extends SchemaItem {
57
68
  super.fromJSONSync(invertedUnitProps);
58
69
  const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);
59
70
  this._invertsUnit = new DelayedPromiseWithProps(unitSchemaItemKey, async () => {
60
- const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey);
71
+ const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);
61
72
  if (undefined === invertsUnit)
62
73
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);
63
74
  return invertsUnit;
@@ -66,7 +77,7 @@ export class InvertedUnit extends SchemaItem {
66
77
  if (!unitSystemSchemaItemKey)
67
78
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
68
79
  this._unitSystem = new DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
69
- const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
80
+ const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);
70
81
  if (undefined === unitSystem)
71
82
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
72
83
  return unitSystem;
@@ -1 +1 @@
1
- {"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.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;AAI/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,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AI,SAAS,KAAK,UAAU;gBAC1B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,aAAa,EAAE,mCAAmC,iBAAiB,CAAC,UAAU,GAAG,CAAC,CAAC;YAC9H,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,iBAAoC;QACjE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAA2B;QAClD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,YAAY;CAI7D","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 { InvertedUnitProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedUnit, LazyLoadedUnitSystem } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\nimport { UnitSystem } from \"./UnitSystem\";\n\n/**\n * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.\n * @beta\n */\nexport class InvertedUnit extends SchemaItem {\n public override readonly schemaItemType!: SchemaItemType.InvertedUnit;\n protected _invertsUnit?: LazyLoadedUnit; // required\n protected _unitSystem?: LazyLoadedUnitSystem; // required\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this.schemaItemType = SchemaItemType.InvertedUnit;\n }\n\n public get invertsUnit(): LazyLoadedUnit | undefined { return this._invertsUnit; }\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\n\n /**\n * @alpha\n */\n public static isInvertedUnit(object: any): object is InvertedUnit {\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.InvertedUnit;\n }\n\n /**\n * Save this InvertedUnit's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): InvertedUnitProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.invertsUnit = this.invertsUnit!.fullName;\n schemaJson.unitSystem = this.unitSystem!.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 const unitSystem = await this.unitSystem;\n if (undefined !== unitSystem) {\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\n }\n\n const invertsUnit = await this.invertsUnit;\n if (undefined !== invertsUnit) {\n const invertsUnitName = XmlSerializationUtils.createXmlTypedName(this.schema, invertsUnit.schema, invertsUnit.name);\n itemElement.setAttribute(\"invertsUnit\", invertsUnitName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(invertedUnitProps: InvertedUnitProps) {\n super.fromJSONSync(invertedUnitProps);\n const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);\n this._invertsUnit = new DelayedPromiseWithProps<SchemaItemKey, Unit>(unitSchemaItemKey,\n async () => {\n const invertsUnit = await this.schema.lookupItem<Unit>(unitSchemaItemKey);\n if (undefined === invertsUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);\n return invertsUnit;\n });\n\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);\n if (!unitSystemSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\n async () => {\n const unitSystem = await this.schema.lookupItem<UnitSystem>(unitSystemSchemaItemKey);\n if (undefined === unitSystem)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n return unitSystem;\n });\n }\n\n public override async fromJSON(invertedUnitProps: InvertedUnitProps) {\n this.fromJSONSync(invertedUnitProps);\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\n this._invertsUnit = invertsUnit;\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\n this._unitSystem = unitSystem;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableInvertedUnit extends InvertedUnit {\n public abstract override setInvertsUnit(invertsUnit: LazyLoadedUnit): void;\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
1
+ {"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.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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AAC,aAAa,EAAE,oCAAoC,iBAAiB,CAAC,WAAW,GAAG,CAAC,CAAC;YAChI,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC,CAAC;QAEL,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC3F,IAAI,CAAC,uBAAuB;YAC1B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,aAAa,EAAE,mCAAmC,iBAAiB,CAAC,UAAU,GAAG,CAAC,CAAC;QAC9H,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAuB,CAA4B,uBAAuB,EAC/F,KAAK,IAAI,EAAE;YACT,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;YACrF,IAAI,SAAS,KAAK,UAAU;gBAC1B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,aAAa,EAAE,mCAAmC,iBAAiB,CAAC,UAAU,GAAG,CAAC,CAAC;YAC9H,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,iBAAoC;QACjE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAA2B;QAClD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,YAAY;CAI7D","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 { InvertedUnitProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedUnit, LazyLoadedUnitSystem } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\nimport { UnitSystem } from \"./UnitSystem\";\n\n/**\n * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.\n * @beta\n */\nexport class InvertedUnit extends SchemaItem {\n public override readonly schemaItemType = InvertedUnit.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.InvertedUnit; }\n protected _invertsUnit?: LazyLoadedUnit; // required\n protected _unitSystem?: LazyLoadedUnitSystem; // required\n\n public get invertsUnit(): LazyLoadedUnit | undefined { return this._invertsUnit; }\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\n\n /**\n * @alpha\n */\n public static isInvertedUnit(object: any): object is InvertedUnit {\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.InvertedUnit;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type InvertedUnit.\n * @param item The SchemaItem to check.\n * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.\n */\n public static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit {\n if(!this.isInvertedUnit(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);\n }\n\n /**\n * Save this InvertedUnit's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): InvertedUnitProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.invertsUnit = this.invertsUnit!.fullName;\n schemaJson.unitSystem = this.unitSystem!.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 const unitSystem = await this.unitSystem;\n if (undefined !== unitSystem) {\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\n }\n\n const invertsUnit = await this.invertsUnit;\n if (undefined !== invertsUnit) {\n const invertsUnitName = XmlSerializationUtils.createXmlTypedName(this.schema, invertsUnit.schema, invertsUnit.name);\n itemElement.setAttribute(\"invertsUnit\", invertsUnitName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(invertedUnitProps: InvertedUnitProps) {\n super.fromJSONSync(invertedUnitProps);\n const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);\n this._invertsUnit = new DelayedPromiseWithProps<SchemaItemKey, Unit>(unitSchemaItemKey,\n async () => {\n const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);\n if (undefined === invertsUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);\n return invertsUnit;\n });\n\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);\n if (!unitSystemSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\n async () => {\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\n if (undefined === unitSystem)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n return unitSystem;\n });\n }\n\n public override async fromJSON(invertedUnitProps: InvertedUnitProps) {\n this.fromJSONSync(invertedUnitProps);\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\n this._invertsUnit = invertsUnit;\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\n this._unitSystem = unitSystem;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableInvertedUnit extends InvertedUnit {\n public abstract override setInvertsUnit(invertsUnit: LazyLoadedUnit): void;\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
@@ -7,14 +7,14 @@ import { LazyLoadedInvertedUnit, LazyLoadedUnit } from "../Interfaces";
7
7
  import { Format } from "./Format";
8
8
  import { InvertedUnit } from "./InvertedUnit";
9
9
  import { OverrideFormat } from "./OverrideFormat";
10
- import { Schema } from "./Schema";
11
10
  import { SchemaItem } from "./SchemaItem";
12
11
  import { Unit } from "./Unit";
13
12
  /** A Typescript class representation of a KindOfQuantity.
14
13
  * @beta
15
14
  */
16
15
  export declare class KindOfQuantity extends SchemaItem {
17
- readonly schemaItemType: SchemaItemType.KindOfQuantity;
16
+ readonly schemaItemType: SchemaItemType;
17
+ static get schemaItemType(): SchemaItemType;
18
18
  protected _relativeError: number;
19
19
  protected _presentationFormats: Array<Format | OverrideFormat>;
20
20
  protected _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;
@@ -25,7 +25,6 @@ export declare class KindOfQuantity extends SchemaItem {
25
25
  get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined;
26
26
  protected set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined);
27
27
  get relativeError(): number;
28
- constructor(schema: Schema, name: string);
29
28
  /**
30
29
  *
31
30
  * @param format The Format to add to this KindOfQuantity
@@ -55,6 +54,18 @@ export declare class KindOfQuantity extends SchemaItem {
55
54
  * Used for schema editing.
56
55
  */
57
56
  protected setRelativeError(relativeError: number): void;
57
+ /**
58
+ * Type guard to check if the SchemaItem is of type KindOfQuantity.
59
+ * @param item The SchemaItem to check.
60
+ * @returns True if the item is a KindOfQuantity, false otherwise.
61
+ */
62
+ static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity;
63
+ /**
64
+ * Type assertion to check if the SchemaItem is of type KindOfQuantity.
65
+ * @param item The SchemaItem to check.
66
+ * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
67
+ */
68
+ static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity;
58
69
  }
59
70
  /**
60
71
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantity.d.ts","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,SAAyB,cAAc,EAAG,cAAc,CAAC,cAAc,CAAC;IACxE,SAAS,CAAC,cAAc,EAAE,MAAM,CAAO;IACvC,SAAS,CAAC,oBAAoB,EAAE,KAAK,CAAC,MAAM,G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,SAAQ,cAAc;aACvC,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;aAChF,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,cAAc;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -9,12 +9,20 @@ 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 { Format } from "./Format";
13
+ import { InvertedUnit } from "./InvertedUnit";
12
14
  import { OverrideFormat } from "./OverrideFormat";
13
15
  import { SchemaItem } from "./SchemaItem";
16
+ import { Unit } from "./Unit";
14
17
  /** A Typescript class representation of a KindOfQuantity.
15
18
  * @beta
16
19
  */
17
20
  export class KindOfQuantity extends SchemaItem {
21
+ schemaItemType = KindOfQuantity.schemaItemType;
22
+ static get schemaItemType() { return SchemaItemType.KindOfQuantity; }
23
+ _relativeError = 1.0;
24
+ _presentationFormats = new Array();
25
+ _persistenceUnit;
18
26
  /** The first presentation format in the list of Formats. */
19
27
  get defaultPresentationFormat() { return this.presentationFormats[0]; }
20
28
  /** A list of presentation formats. */
@@ -22,12 +30,6 @@ export class KindOfQuantity extends SchemaItem {
22
30
  get persistenceUnit() { return this._persistenceUnit; }
23
31
  set persistenceUnit(value) { this._persistenceUnit = value; }
24
32
  get relativeError() { return this._relativeError; }
25
- constructor(schema, name) {
26
- super(schema, name);
27
- this._relativeError = 1.0;
28
- this._presentationFormats = new Array();
29
- this.schemaItemType = SchemaItemType.KindOfQuantity; // Needed to allow both run-time and compile-time check.
30
- }
31
33
  /**
32
34
  *
33
35
  * @param format The Format to add to this KindOfQuantity
@@ -54,7 +56,7 @@ export class KindOfQuantity extends SchemaItem {
54
56
  const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(";");
55
57
  for (const formatString of presUnitsArr) {
56
58
  const presFormatOverride = OverrideFormat.parseFormatString(formatString);
57
- const format = await this.schema.lookupItem(presFormatOverride.name);
59
+ const format = await this.schema.lookupItem(presFormatOverride.name, Format);
58
60
  if (undefined === format || format.schemaItemType !== SchemaItemType.Format)
59
61
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
60
62
  if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
@@ -67,10 +69,10 @@ export class KindOfQuantity extends SchemaItem {
67
69
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
68
70
  unitAndLabels = [];
69
71
  for (const unitOverride of presFormatOverride.unitAndLabels) {
70
- const unit = await this.schema.lookupItem(unitOverride[0]);
71
- if (undefined === unit)
72
+ const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);
73
+ if (undefined === unitOrInverted || (!Unit.isUnit(unitOrInverted) && !InvertedUnit.isInvertedUnit(unitOrInverted)))
72
74
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
73
- unitAndLabels.push([unit, unitOverride[1]]);
75
+ unitAndLabels.push([unitOrInverted, unitOverride[1]]);
74
76
  }
75
77
  }
76
78
  const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
@@ -81,7 +83,7 @@ export class KindOfQuantity extends SchemaItem {
81
83
  const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(";");
82
84
  for (const formatString of presUnitsArr) {
83
85
  const presFormatOverride = OverrideFormat.parseFormatString(formatString);
84
- const format = this.schema.lookupItemSync(presFormatOverride.name);
86
+ const format = this.schema.lookupItemSync(presFormatOverride.name, Format);
85
87
  if (undefined === format || format.schemaItemType !== SchemaItemType.Format)
86
88
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
87
89
  if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
@@ -94,10 +96,10 @@ export class KindOfQuantity extends SchemaItem {
94
96
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
95
97
  unitAndLabels = [];
96
98
  for (const unitOverride of presFormatOverride.unitAndLabels) {
97
- const unit = this.schema.lookupItemSync(unitOverride[0]);
98
- if (undefined === unit)
99
+ const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);
100
+ if (undefined === unitOrInverted || (!Unit.isUnit(unitOrInverted) && !InvertedUnit.isInvertedUnit(unitOrInverted)))
99
101
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
100
- unitAndLabels.push([unit, unitOverride[1]]);
102
+ unitAndLabels.push([unitOrInverted, unitOverride[1]]);
101
103
  }
102
104
  }
103
105
  const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
@@ -142,9 +144,12 @@ export class KindOfQuantity extends SchemaItem {
142
144
  const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);
143
145
  if (undefined === persistenceUnit)
144
146
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
145
- if (persistenceUnit.schemaItemType !== SchemaItemType.Unit && persistenceUnit.schemaItemType !== SchemaItemType.InvertedUnit)
147
+ if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))
146
148
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
147
- this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
149
+ if (Unit.isUnit(persistenceUnit))
150
+ this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
151
+ else
152
+ this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
148
153
  if (undefined !== kindOfQuantityProps.presentationUnits)
149
154
  this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);
150
155
  }
@@ -154,9 +159,12 @@ export class KindOfQuantity extends SchemaItem {
154
159
  const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);
155
160
  if (undefined === persistenceUnit)
156
161
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
157
- if (persistenceUnit.schemaItemType !== SchemaItemType.Unit && persistenceUnit.schemaItemType !== SchemaItemType.InvertedUnit)
162
+ if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))
158
163
  throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
159
- this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
164
+ if (Unit.isUnit(persistenceUnit))
165
+ this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
166
+ else
167
+ this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
160
168
  if (undefined !== kindOfQuantityProps.presentationUnits)
161
169
  await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);
162
170
  }
@@ -167,6 +175,23 @@ export class KindOfQuantity extends SchemaItem {
167
175
  setRelativeError(relativeError) {
168
176
  this._relativeError = relativeError;
169
177
  }
178
+ /**
179
+ * Type guard to check if the SchemaItem is of type KindOfQuantity.
180
+ * @param item The SchemaItem to check.
181
+ * @returns True if the item is a KindOfQuantity, false otherwise.
182
+ */
183
+ static isKindOfQuantity(item) {
184
+ return item?.schemaItemType === SchemaItemType.KindOfQuantity;
185
+ }
186
+ /**
187
+ * Type assertion to check if the SchemaItem is of type KindOfQuantity.
188
+ * @param item The SchemaItem to check.
189
+ * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
190
+ */
191
+ static assertIsKindOfQuantity(item) {
192
+ if (!this.isKindOfQuantity(item))
193
+ throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);
194
+ }
170
195
  }
171
196
  /**
172
197
  * @internal