@itwin/ecschema-metadata 5.1.0-dev.9 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/CHANGELOG.md +88 -1
  2. package/lib/cjs/Constants.js.map +1 -1
  3. package/lib/cjs/Context.d.ts +1 -1
  4. package/lib/cjs/Context.js +1 -1
  5. package/lib/cjs/Context.js.map +1 -1
  6. package/lib/cjs/DelayedPromise.js.map +1 -1
  7. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  8. package/lib/cjs/Deserialization/Helper.d.ts +30 -11
  9. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  10. package/lib/cjs/Deserialization/Helper.js +124 -96
  11. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  12. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  13. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  14. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +12 -3
  15. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts.map +1 -1
  16. package/lib/cjs/Deserialization/SchemaGraphUtil.js +36 -23
  17. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  18. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  19. package/lib/cjs/Deserialization/XmlParser.js +14 -5
  20. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  21. package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
  22. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  23. package/lib/cjs/ECName.js +1 -1
  24. package/lib/cjs/ECName.js.map +1 -1
  25. package/lib/cjs/ECObjects.d.ts +1 -1
  26. package/lib/cjs/ECObjects.js +2 -2
  27. package/lib/cjs/ECObjects.js.map +1 -1
  28. package/lib/cjs/Exception.js.map +1 -1
  29. package/lib/cjs/IncrementalLoading/ClassParsers.d.ts +60 -0
  30. package/lib/cjs/IncrementalLoading/ClassParsers.d.ts.map +1 -0
  31. package/lib/cjs/IncrementalLoading/ClassParsers.js +111 -0
  32. package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -0
  33. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts +211 -0
  34. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -0
  35. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +387 -0
  36. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -0
  37. package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts +14 -0
  38. package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -0
  39. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +609 -0
  40. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -0
  41. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +109 -0
  42. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -0
  43. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +219 -0
  44. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -0
  45. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts +36 -0
  46. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -0
  47. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +77 -0
  48. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -0
  49. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts +60 -0
  50. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts.map +1 -0
  51. package/lib/cjs/IncrementalLoading/PerformanceLogger.js +82 -0
  52. package/lib/cjs/IncrementalLoading/PerformanceLogger.js.map +1 -0
  53. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +51 -0
  54. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -0
  55. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +122 -0
  56. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -0
  57. package/lib/cjs/IncrementalLoading/SchemaItemQueries.d.ts +16 -0
  58. package/lib/cjs/IncrementalLoading/SchemaItemQueries.d.ts.map +1 -0
  59. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +308 -0
  60. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -0
  61. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +42 -0
  62. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -0
  63. package/lib/cjs/IncrementalLoading/SchemaParser.js +109 -0
  64. package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -0
  65. package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts +12 -0
  66. package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -0
  67. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +365 -0
  68. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -0
  69. package/lib/cjs/Interfaces.js.map +1 -1
  70. package/lib/cjs/Metadata/Class.d.ts +5 -16
  71. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  72. package/lib/cjs/Metadata/Class.js +68 -68
  73. package/lib/cjs/Metadata/Class.js.map +1 -1
  74. package/lib/cjs/Metadata/Constant.js.map +1 -1
  75. package/lib/cjs/Metadata/CustomAttribute.d.ts +7 -1
  76. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  77. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  78. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +1 -1
  79. package/lib/cjs/Metadata/CustomAttributeClass.js +1 -1
  80. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  81. package/lib/cjs/Metadata/EntityClass.d.ts +6 -6
  82. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  83. package/lib/cjs/Metadata/EntityClass.js +48 -26
  84. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  85. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  86. package/lib/cjs/Metadata/Format.d.ts +5 -0
  87. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  88. package/lib/cjs/Metadata/Format.js +7 -0
  89. package/lib/cjs/Metadata/Format.js.map +1 -1
  90. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  91. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  92. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  93. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  94. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  95. package/lib/cjs/Metadata/Property.js.map +1 -1
  96. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  97. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  98. package/lib/cjs/Metadata/Schema.d.ts +10 -0
  99. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  100. package/lib/cjs/Metadata/Schema.js +13 -0
  101. package/lib/cjs/Metadata/Schema.js.map +1 -1
  102. package/lib/cjs/Metadata/SchemaItem.d.ts +10 -0
  103. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  104. package/lib/cjs/Metadata/SchemaItem.js +13 -0
  105. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  106. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  107. package/lib/cjs/PropertyTypes.js.map +1 -1
  108. package/lib/cjs/SchemaFormatsProvider.d.ts +4 -3
  109. package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -1
  110. package/lib/cjs/SchemaFormatsProvider.js +60 -17
  111. package/lib/cjs/SchemaFormatsProvider.js.map +1 -1
  112. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  113. package/lib/cjs/SchemaKey.js.map +1 -1
  114. package/lib/cjs/SchemaLoader.d.ts +4 -1
  115. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  116. package/lib/cjs/SchemaLoader.js +4 -1
  117. package/lib/cjs/SchemaLoader.js.map +1 -1
  118. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  119. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  120. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  121. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  122. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  123. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  124. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  125. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  126. package/lib/cjs/ecschema-metadata.d.ts +2 -0
  127. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  128. package/lib/cjs/ecschema-metadata.js +2 -0
  129. package/lib/cjs/ecschema-metadata.js.map +1 -1
  130. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  131. package/lib/cjs/utils/SchemaLoadingController.d.ts +37 -0
  132. package/lib/cjs/utils/SchemaLoadingController.d.ts.map +1 -0
  133. package/lib/cjs/utils/SchemaLoadingController.js +65 -0
  134. package/lib/cjs/utils/SchemaLoadingController.js.map +1 -0
  135. package/lib/esm/Constants.js.map +1 -1
  136. package/lib/esm/Context.d.ts +1 -1
  137. package/lib/esm/Context.js +1 -1
  138. package/lib/esm/Context.js.map +1 -1
  139. package/lib/esm/DelayedPromise.js.map +1 -1
  140. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  141. package/lib/esm/Deserialization/Helper.d.ts +30 -11
  142. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  143. package/lib/esm/Deserialization/Helper.js +124 -96
  144. package/lib/esm/Deserialization/Helper.js.map +1 -1
  145. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  146. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  147. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts +12 -3
  148. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts.map +1 -1
  149. package/lib/esm/Deserialization/SchemaGraphUtil.js +36 -23
  150. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  151. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  152. package/lib/esm/Deserialization/XmlParser.js +14 -5
  153. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  154. package/lib/esm/Deserialization/XmlSerializationUtils.js +1 -1
  155. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  156. package/lib/esm/ECName.js +1 -1
  157. package/lib/esm/ECName.js.map +1 -1
  158. package/lib/esm/ECObjects.d.ts +1 -1
  159. package/lib/esm/ECObjects.js +2 -2
  160. package/lib/esm/ECObjects.js.map +1 -1
  161. package/lib/esm/Exception.js.map +1 -1
  162. package/lib/esm/IncrementalLoading/ClassParsers.d.ts +60 -0
  163. package/lib/esm/IncrementalLoading/ClassParsers.d.ts.map +1 -0
  164. package/lib/esm/IncrementalLoading/ClassParsers.js +104 -0
  165. package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -0
  166. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts +211 -0
  167. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -0
  168. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +383 -0
  169. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -0
  170. package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts +14 -0
  171. package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -0
  172. package/lib/esm/IncrementalLoading/FullSchemaQueries.js +606 -0
  173. package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -0
  174. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +109 -0
  175. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -0
  176. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +215 -0
  177. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -0
  178. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts +36 -0
  179. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -0
  180. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +73 -0
  181. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -0
  182. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts +60 -0
  183. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts.map +1 -0
  184. package/lib/esm/IncrementalLoading/PerformanceLogger.js +78 -0
  185. package/lib/esm/IncrementalLoading/PerformanceLogger.js.map +1 -0
  186. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +51 -0
  187. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -0
  188. package/lib/esm/IncrementalLoading/SchemaItemParsers.js +117 -0
  189. package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -0
  190. package/lib/esm/IncrementalLoading/SchemaItemQueries.d.ts +16 -0
  191. package/lib/esm/IncrementalLoading/SchemaItemQueries.d.ts.map +1 -0
  192. package/lib/esm/IncrementalLoading/SchemaItemQueries.js +305 -0
  193. package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -0
  194. package/lib/esm/IncrementalLoading/SchemaParser.d.ts +42 -0
  195. package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -0
  196. package/lib/esm/IncrementalLoading/SchemaParser.js +104 -0
  197. package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -0
  198. package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts +12 -0
  199. package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -0
  200. package/lib/esm/IncrementalLoading/SchemaStubQueries.js +359 -0
  201. package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -0
  202. package/lib/esm/Interfaces.js.map +1 -1
  203. package/lib/esm/Metadata/Class.d.ts +5 -16
  204. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  205. package/lib/esm/Metadata/Class.js +68 -68
  206. package/lib/esm/Metadata/Class.js.map +1 -1
  207. package/lib/esm/Metadata/Constant.js.map +1 -1
  208. package/lib/esm/Metadata/CustomAttribute.d.ts +7 -1
  209. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
  210. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  211. package/lib/esm/Metadata/CustomAttributeClass.d.ts +1 -1
  212. package/lib/esm/Metadata/CustomAttributeClass.js +1 -1
  213. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  214. package/lib/esm/Metadata/EntityClass.d.ts +6 -6
  215. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  216. package/lib/esm/Metadata/EntityClass.js +48 -26
  217. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  218. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  219. package/lib/esm/Metadata/Format.d.ts +5 -0
  220. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  221. package/lib/esm/Metadata/Format.js +7 -0
  222. package/lib/esm/Metadata/Format.js.map +1 -1
  223. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  224. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  225. package/lib/esm/Metadata/Mixin.js.map +1 -1
  226. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  227. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  228. package/lib/esm/Metadata/Property.js.map +1 -1
  229. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  230. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  231. package/lib/esm/Metadata/Schema.d.ts +10 -0
  232. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  233. package/lib/esm/Metadata/Schema.js +13 -0
  234. package/lib/esm/Metadata/Schema.js.map +1 -1
  235. package/lib/esm/Metadata/SchemaItem.d.ts +10 -0
  236. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  237. package/lib/esm/Metadata/SchemaItem.js +13 -0
  238. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  239. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  240. package/lib/esm/PropertyTypes.js.map +1 -1
  241. package/lib/esm/SchemaFormatsProvider.d.ts +4 -3
  242. package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -1
  243. package/lib/esm/SchemaFormatsProvider.js +61 -18
  244. package/lib/esm/SchemaFormatsProvider.js.map +1 -1
  245. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  246. package/lib/esm/SchemaKey.js.map +1 -1
  247. package/lib/esm/SchemaLoader.d.ts +4 -1
  248. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  249. package/lib/esm/SchemaLoader.js +4 -1
  250. package/lib/esm/SchemaLoader.js.map +1 -1
  251. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  252. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  253. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  254. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  255. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  256. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  257. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  258. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  259. package/lib/esm/ecschema-metadata.d.ts +2 -0
  260. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  261. package/lib/esm/ecschema-metadata.js +2 -0
  262. package/lib/esm/ecschema-metadata.js.map +1 -1
  263. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  264. package/lib/esm/utils/SchemaLoadingController.d.ts +37 -0
  265. package/lib/esm/utils/SchemaLoadingController.d.ts.map +1 -0
  266. package/lib/esm/utils/SchemaLoadingController.js +61 -0
  267. package/lib/esm/utils/SchemaLoadingController.js.map +1 -0
  268. package/package.json +15 -10
@@ -1 +1 @@
1
- {"version":3,"file":"Format.js","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AI,CAAC,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,QAAgB;QACpC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACjC,CAAC;IAED;;OAEG;IACO,SAAS,CAAC,MAAc;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAoB;QAC3C,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;IACvC,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,YAA0B;QAClD,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC;IACzC,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,KAA2E;QAC5F,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAiB;QACtC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,MAAM;YACvD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,cAAc,CAAC,IAAiB;QAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACtB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,MAAM,YAAY,CAAC,CAAC;IAClH,CAAC;CACF;AA7VD,wBA6VC;AAED;;;GAGG;AACH,MAAsB,aAAc,SAAQ,MAAM;CAWjD;AAXD,sCAWC","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 { ECSchemaError, ECSchemaStatus } 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\";\nimport { LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\n\n/**\n * @public @preview\n */\nexport class Format extends SchemaItem {\n public override readonly schemaItemType = Format.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.Format; }\n private _base: BaseFormat;\n private _units?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>;\n\n /** @internal */\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(): ReadonlyArray<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined {\n return this._units;\n }\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 * @internal\n */\n protected addUnit(unit: LazyLoadedUnit | LazyLoadedInvertedUnit, 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 ECSchemaError(ECSchemaStatus.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 /**\n *\n * @param precision\n * @internal\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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n \n if(Unit.isUnit(newUnit))\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => newUnit), unit.label);\n else if(InvertedUnit.isInvertedUnit(newUnit))\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => 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 ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n if(Unit.isUnit(newUnit))\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => newUnit), unit.label);\n else if(InvertedUnit.isInvertedUnit(newUnit))\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => 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 for(const [unit, label] of this.units) {\n const resolvedUnit = await unit;\n const unitElement = schemaXml.createElement(\"Unit\");\n if (undefined !== label)\n unitElement.setAttribute(\"label\", label);\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, resolvedUnit.schema, resolvedUnit.name);\n unitElement.textContent = unitName;\n compositeElement.appendChild(unitElement);\n };\n\n itemElement.appendChild(compositeElement);\n }\n\n return itemElement;\n }\n\n /**\n * @internal\n */\n protected setFormatType(formatType: FormatType) {\n this._base.type = formatType;\n }\n\n /**\n * @internal\n */\n protected setRoundFactor(roundFactor: number) {\n this._base.roundFactor = roundFactor;\n }\n\n /**\n * @internal\n */\n protected setShowSignOption(signOption: ShowSignOption) {\n this._base.showSignOption = signOption;\n }\n\n /**\n * @internal\n */\n protected setDecimalSeparator(separator: string) {\n this._base.decimalSeparator = separator;\n }\n\n /**\n * @internal\n */\n protected setThousandSeparator(separator: string) {\n this._base.thousandSeparator = separator;\n }\n\n /**\n * @internal\n */\n protected setUomSeparator(separator: string) {\n this._base.uomSeparator = separator;\n }\n\n /**\n * @internal\n */\n protected setStationSeparator(separator: string) {\n this._base.stationSeparator = separator;\n }\n\n /**\n * @internal\n */\n protected setStationOffsetSize(stationOffsetSize: number) {\n this._base.stationOffsetSize = stationOffsetSize;\n }\n\n /**\n * @internal\n */\n protected setScientificType(scientificType: ScientificType) {\n this._base.scientificType = scientificType;\n }\n\n /**\n * @internal\n */\n protected setMinWidth(minWidth: number) {\n this._base.minWidth = minWidth;\n }\n\n /**\n * @internal\n */\n protected setSpacer(spacer: string) {\n this._base.spacer = spacer;\n }\n\n /**\n * @internal\n */\n protected setIncludeZero(includeZero: boolean) {\n this._base.includeZero = includeZero;\n }\n\n /**\n * @internal\n */\n protected setFormatTraits(formatTraits: FormatTraits) {\n this._base.formatTraits = formatTraits;\n }\n\n /**\n * @internal\n */\n protected setUnits(units: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, 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 * @internal\n */\n public static assertIsFormat(item?: SchemaItem): asserts item is Format {\n if (!this.isFormat(item))\n throw new ECSchemaError(ECSchemaStatus.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: LazyLoadedUnit | LazyLoadedInvertedUnit, 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":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAC7D,wD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IACnD,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,cAA8B;QACxD,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,QAAgB;QACpC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACjC,CAAC;IAED;;OAEG;IACO,SAAS,CAAC,MAAc;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,WAAoB;QAC3C,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;IACvC,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,YAA0B;QAClD,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC;IACzC,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,KAA2E;QAC5F,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAiB;QACtC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,MAAM;YACvD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,cAAc,CAAC,IAAiB;QAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACtB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,MAAM,YAAY,CAAC,CAAC;IAClH,CAAC;CACF;AArWD,wBAqWC;AAED;;;GAGG;AACH,MAAsB,aAAc,SAAQ,MAAM;CAWjD;AAXD,sCAWC","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 { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport {\r\n BaseFormat, DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\r\n ScientificType, ShowSignOption,\r\n} from \"@itwin/core-quantity\";\r\nimport { InvertedUnit } from \"./InvertedUnit\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { Unit } from \"./Unit\";\r\nimport { LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\r\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport class Format extends SchemaItem {\r\n public override readonly schemaItemType = Format.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.Format; }\r\n private _base: BaseFormat;\r\n private _units?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>;\r\n\r\n /** @internal */\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this._base = new BaseFormat(name);\r\n }\r\n\r\n public get roundFactor(): number { return this._base.roundFactor; }\r\n public get type(): FormatType { return this._base.type; }\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._base.precision; }\r\n public get minWidth(): number | undefined { return this._base.minWidth; }\r\n public get scientificType(): ScientificType | undefined { return this._base.scientificType; }\r\n public get showSignOption(): ShowSignOption { return this._base.showSignOption; }\r\n public get decimalSeparator(): string { return this._base.decimalSeparator; }\r\n public get thousandSeparator(): string { return this._base.thousandSeparator; }\r\n public get uomSeparator(): string { return this._base.uomSeparator; }\r\n public get stationSeparator(): string { return this._base.stationSeparator; }\r\n public get stationOffsetSize(): number | undefined { return this._base.stationOffsetSize; }\r\n public get stationBaseFactor(): number | undefined { return this._base.stationBaseFactor; }\r\n public get formatTraits(): FormatTraits { return this._base.formatTraits; }\r\n public get spacer(): string | undefined { return this._base.spacer; }\r\n public get includeZero(): boolean | undefined { return this._base.includeZero; }\r\n public get units(): ReadonlyArray<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined {\r\n return this._units;\r\n }\r\n\r\n private parseFormatTraits(formatTraitsFromJson: string | string[]) {\r\n return this._base.parseFormatTraits(formatTraitsFromJson);\r\n }\r\n\r\n public hasFormatTrait(formatTrait: FormatTraits) {\r\n return this._base.hasFormatTraitSet(formatTrait);\r\n }\r\n\r\n /**\r\n * Adds a Unit, or InvertedUnit, with an optional label override.\r\n * @param unit The Unit, or InvertedUnit, to add to this Format.\r\n * @param label A label that overrides the label defined within the Unit when a value is formatted.\r\n * @internal\r\n */\r\n protected addUnit(unit: LazyLoadedUnit | LazyLoadedInvertedUnit, label?: string) {\r\n if (undefined === this._units)\r\n this._units = [];\r\n else { // Validate that a duplicate is not added.\r\n for (const existingUnit of this._units) {\r\n if (unit.fullName.toLowerCase() === existingUnit[0].fullName.toLowerCase())\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has duplicate units, '${unit.fullName}'.`); // TODO: Validation - this should be a validation error not a hard failure.\r\n }\r\n }\r\n\r\n this._units.push([unit, label]);\r\n }\r\n\r\n /**\r\n *\r\n * @param precision\r\n * @internal\r\n */\r\n protected setPrecision(precision: number) { this._base.precision = precision; }\r\n\r\n private typecheck(formatProps: SchemaItemFormatProps) {\r\n this._base.loadFormatProperties(formatProps);\r\n\r\n if (undefined !== formatProps.composite) { // TODO: This is duplicated below when the units need to be processed...\r\n if (undefined !== formatProps.composite.includeZero)\r\n this._base.includeZero = formatProps.composite.includeZero;\r\n\r\n if (undefined !== formatProps.composite.spacer) {\r\n if (formatProps.composite.spacer.length > 1)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has a composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\r\n this._base.spacer = formatProps.composite.spacer;\r\n }\r\n\r\n // Composite requires 1-4 units\r\n if (formatProps.composite.units.length <= 0 || formatProps.composite.units.length > 4)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);\r\n }\r\n }\r\n\r\n public override fromJSONSync(formatProps: SchemaItemFormatProps) {\r\n super.fromJSONSync(formatProps);\r\n this.typecheck(formatProps);\r\n if (undefined === formatProps.composite)\r\n return;\r\n\r\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\r\n for (const unit of formatProps.composite.units) {\r\n const newUnit = this.schema.lookupItemSync(unit.name);\r\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\r\n\r\n if(Unit.isUnit(newUnit))\r\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => newUnit), unit.label);\r\n else if(InvertedUnit.isInvertedUnit(newUnit))\r\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => newUnit), unit.label);\r\n }\r\n }\r\n\r\n public override async fromJSON(formatProps: SchemaItemFormatProps) {\r\n await super.fromJSON(formatProps);\r\n this.typecheck(formatProps);\r\n if (undefined === formatProps.composite)\r\n return;\r\n\r\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\r\n for (const unit of formatProps.composite.units) {\r\n const newUnit = await this.schema.lookupItem(unit.name);\r\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\r\n\r\n if(Unit.isUnit(newUnit))\r\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => newUnit), unit.label);\r\n else if(InvertedUnit.isInvertedUnit(newUnit))\r\n this.addUnit(new DelayedPromiseWithProps(newUnit.key, async () => newUnit), unit.label);\r\n }\r\n }\r\n\r\n /**\r\n * Save this Format'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): SchemaItemFormatProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.type = this.type;\r\n schemaJson.precision = this.precision;\r\n\r\n // this._spacer = \" \";\r\n // this._includeZero = true;\r\n\r\n // Serialize the minimal amount of information needed so anything that is the same as the default, do not serialize.\r\n if (0.0 !== this.roundFactor)\r\n schemaJson.roundFactor = this.roundFactor;\r\n if (ShowSignOption.OnlyNegative !== this.showSignOption)\r\n schemaJson.showSignOption = this.showSignOption;\r\n if (FormatTraits.Uninitialized !== this.formatTraits)\r\n schemaJson.formatTraits = formatTraitsToArray(this.formatTraits);\r\n if (\".\" !== this.decimalSeparator)\r\n schemaJson.decimalSeparator = this.decimalSeparator;\r\n if (\",\" !== this.thousandSeparator)\r\n schemaJson.thousandSeparator = this.thousandSeparator;\r\n if (\" \" !== this.uomSeparator)\r\n schemaJson.uomSeparator = this.uomSeparator;\r\n\r\n if (undefined !== this.minWidth)\r\n schemaJson.minWidth = this.minWidth;\r\n\r\n if (FormatType.Scientific === this.type && undefined !== this.scientificType)\r\n schemaJson.scientificType = this.scientificType;\r\n\r\n if (FormatType.Station === this.type) {\r\n if (undefined !== this.stationOffsetSize)\r\n schemaJson.stationOffsetSize = this.stationOffsetSize;\r\n if (\" \" !== this.stationSeparator)\r\n schemaJson.stationSeparator = this.stationSeparator;\r\n }\r\n\r\n if (undefined === this.units)\r\n return schemaJson;\r\n\r\n schemaJson.composite = {};\r\n\r\n if (\" \" !== this.spacer)\r\n schemaJson.composite.spacer = this.spacer;\r\n\r\n if (true !== this.includeZero)\r\n schemaJson.composite.includeZero = this.includeZero;\r\n\r\n schemaJson.composite.units = [];\r\n for (const unit of this.units) {\r\n schemaJson.composite.units.push({\r\n name: unit[0].fullName,\r\n label: unit[1],\r\n });\r\n }\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 itemElement.setAttribute(\"type\", this.type.toLowerCase());\r\n itemElement.setAttribute(\"precision\", this.precision.toString());\r\n itemElement.setAttribute(\"roundFactor\", this.roundFactor.toString());\r\n itemElement.setAttribute(\"showSignOption\", this.showSignOption);\r\n itemElement.setAttribute(\"decimalSeparator\", this.decimalSeparator);\r\n itemElement.setAttribute(\"thousandSeparator\", this.thousandSeparator);\r\n itemElement.setAttribute(\"uomSeparator\", this.uomSeparator);\r\n itemElement.setAttribute(\"stationSeparator\", this.stationSeparator);\r\n\r\n if (undefined !== this.minWidth)\r\n itemElement.setAttribute(\"minWidth\", this.minWidth.toString());\r\n if (undefined !== this.scientificType)\r\n itemElement.setAttribute(\"scientificType\", this.scientificType);\r\n if (undefined !== this.stationOffsetSize)\r\n itemElement.setAttribute(\"stationOffsetSize\", this.stationOffsetSize.toString());\r\n\r\n const formatTraits = formatTraitsToArray(this.formatTraits);\r\n if (formatTraits.length > 0)\r\n itemElement.setAttribute(\"formatTraits\", formatTraits.join(\"|\"));\r\n\r\n if (undefined !== this.units) {\r\n const compositeElement = schemaXml.createElement(\"Composite\");\r\n if (undefined !== this.spacer)\r\n compositeElement.setAttribute(\"spacer\", this.spacer);\r\n if (undefined !== this.includeZero)\r\n compositeElement.setAttribute(\"includeZero\", this.includeZero.toString());\r\n\r\n for(const [unit, label] of this.units) {\r\n const resolvedUnit = await unit;\r\n const unitElement = schemaXml.createElement(\"Unit\");\r\n if (undefined !== label)\r\n unitElement.setAttribute(\"label\", label);\r\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, resolvedUnit.schema, resolvedUnit.name);\r\n unitElement.textContent = unitName;\r\n compositeElement.appendChild(unitElement);\r\n };\r\n\r\n itemElement.appendChild(compositeElement);\r\n }\r\n\r\n return itemElement;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setFormatType(formatType: FormatType) {\r\n this._base.type = formatType;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setRoundFactor(roundFactor: number) {\r\n this._base.roundFactor = roundFactor;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setShowSignOption(signOption: ShowSignOption) {\r\n this._base.showSignOption = signOption;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setDecimalSeparator(separator: string) {\r\n this._base.decimalSeparator = separator;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setThousandSeparator(separator: string) {\r\n this._base.thousandSeparator = separator;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setUomSeparator(separator: string) {\r\n this._base.uomSeparator = separator;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setStationSeparator(separator: string) {\r\n this._base.stationSeparator = separator;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setStationOffsetSize(stationOffsetSize: number) {\r\n this._base.stationOffsetSize = stationOffsetSize;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setStationBaseFactor(stationBaseFactor: number) {\r\n this._base.stationBaseFactor = stationBaseFactor;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setScientificType(scientificType: ScientificType) {\r\n this._base.scientificType = scientificType;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setMinWidth(minWidth: number) {\r\n this._base.minWidth = minWidth;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setSpacer(spacer: string) {\r\n this._base.spacer = spacer;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setIncludeZero(includeZero: boolean) {\r\n this._base.includeZero = includeZero;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setFormatTraits(formatTraits: FormatTraits) {\r\n this._base.formatTraits = formatTraits;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setUnits(units: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>) {\r\n this._units = units;\r\n }\r\n\r\n /** Type guard to check if the SchemaItem is of type Format.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is a Format, false otherwise.\r\n */\r\n public static isFormat(item?: SchemaItem): item is Format {\r\n if (item && item.schemaItemType === SchemaItemType.Format)\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 Format.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to Format if it is a Format, undefined otherwise.\r\n * @internal\r\n */\r\n public static assertIsFormat(item?: SchemaItem): asserts item is Format {\r\n if (!this.isFormat(item))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Format}' (Format)`);\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 MutableFormat extends Format {\r\n public abstract override addUnit(unit: LazyLoadedUnit | LazyLoadedInvertedUnit, label?: string): void;\r\n public abstract override setPrecision(precision: number): void;\r\n public abstract override setFormatType(formatType: FormatType): void;\r\n public abstract override setRoundFactor(roundFactor: number): void;\r\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\r\n public abstract override setDecimalSeparator(separator: string): void;\r\n public abstract override setThousandSeparator(separator: string): void;\r\n public abstract override setUomSeparator(separator: string): void;\r\n public abstract override setStationSeparator(separator: string): void;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAG7D,6CAA0C;AAC1C,iCAA8B;AAC9B,6CAA0C;AAE1C;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C,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC3F,IAAI,CAAC,uBAAuB;YAC1B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,aAAa,EAAE,mCAAmC,iBAAiB,CAAC,UAAU,GAAG,CAAC,CAAC;QAC5H,IAAI,CAAC,WAAW,GAAG,IAAI,wCAAuB,CAA4B,uBAAuB,EAC/F,KAAK,IAAI,EAAE;YACT,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,EAAE,uBAAU,CAAC,CAAC;YACrF,IAAI,SAAS,KAAK,UAAU;gBAC1B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,aAAa,EAAE,mCAAmC,iBAAiB,CAAC,UAAU,GAAG,CAAC,CAAC;YAC5H,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;AA1GD,oCA0GC;AAED;;;GAGG;AACH,MAAsB,mBAAoB,SAAQ,YAAY;CAI7D;AAJD,kDAIC","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 { ECSchemaError, ECSchemaStatus } 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 * @public @preview\n */\nexport class InvertedUnit extends SchemaItem {\n public override readonly schemaItemType = InvertedUnit.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.InvertedUnit; }\n private _invertsUnit?: LazyLoadedUnit; // required\n private _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 * Type guard to check if the SchemaItem is of type InvertedUnit.\n * @param item The SchemaItem to check.\n * @returns True if the item is a InvertedUnit, false otherwise.\n */\n public static isInvertedUnit(item?: SchemaItem): item is InvertedUnit {\n if (item && item.schemaItemType === SchemaItemType.InvertedUnit)\n return true;\n\n return false;\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 * @internal\n */\n public static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit {\n if (!this.isInvertedUnit(item))\n throw new ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 * @internal\n * Used for schema editing\n */\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\n this._invertsUnit = invertsUnit;\n }\n\n /**\n * @internal\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,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAG7D,6CAA0C;AAC1C,iCAA8B;AAC9B,6CAA0C;AAE1C;;;GAGG;AACH,MAAa,YAAa,SAAQ,uBAAU;IACjB,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;IACtE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3E,YAAY,CAAkB,CAAC,WAAW;IAC1C,WAAW,CAAwB,CAAC,WAAW;IAEvD,IAAW,WAAW,KAAiC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAClF,IAAW,UAAU,KAAuC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAEtF;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,IAAiB;QAC5C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,YAAY;YAC7D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,oBAAo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ACjE,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;AA1GD,oCA0GC;AAED;;;GAGG;AACH,MAAsB,mBAAoB,SAAQ,YAAY;CAI7D;AAJD,kDAIC","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 { InvertedUnitProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { LazyLoadedUnit, LazyLoadedUnitSystem } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { Unit } from \"./Unit\";\r\nimport { UnitSystem } from \"./UnitSystem\";\r\n\r\n/**\r\n * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.\r\n * @public @preview\r\n */\r\nexport class InvertedUnit extends SchemaItem {\r\n public override readonly schemaItemType = InvertedUnit.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.InvertedUnit; }\r\n private _invertsUnit?: LazyLoadedUnit; // required\r\n private _unitSystem?: LazyLoadedUnitSystem; // required\r\n\r\n public get invertsUnit(): LazyLoadedUnit | undefined { return this._invertsUnit; }\r\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\r\n\r\n /**\r\n * Type guard to check if the SchemaItem is of type InvertedUnit.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is a InvertedUnit, false otherwise.\r\n */\r\n public static isInvertedUnit(item?: SchemaItem): item is InvertedUnit {\r\n if (item && item.schemaItemType === SchemaItemType.InvertedUnit)\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 InvertedUnit.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.\r\n * @internal\r\n */\r\n public static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit {\r\n if (!this.isInvertedUnit(item))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);\r\n }\r\n\r\n /**\r\n * Save this InvertedUnit'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): InvertedUnitProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.invertsUnit = this.invertsUnit!.fullName;\r\n schemaJson.unitSystem = this.unitSystem!.fullName;\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n const unitSystem = await this.unitSystem;\r\n if (undefined !== unitSystem) {\r\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\r\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\r\n }\r\n\r\n const invertsUnit = await this.invertsUnit;\r\n if (undefined !== invertsUnit) {\r\n const invertsUnitName = XmlSerializationUtils.createXmlTypedName(this.schema, invertsUnit.schema, invertsUnit.name);\r\n itemElement.setAttribute(\"invertsUnit\", invertsUnitName);\r\n }\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(invertedUnitProps: InvertedUnitProps) {\r\n super.fromJSONSync(invertedUnitProps);\r\n const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);\r\n this._invertsUnit = new DelayedPromiseWithProps<SchemaItemKey, Unit>(unitSchemaItemKey,\r\n async () => {\r\n const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);\r\n if (undefined === invertsUnit)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);\r\n return invertsUnit;\r\n });\r\n\r\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);\r\n if (!unitSystemSchemaItemKey)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\r\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\r\n async () => {\r\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\r\n if (undefined === unitSystem)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\r\n return unitSystem;\r\n });\r\n }\r\n\r\n public override async fromJSON(invertedUnitProps: InvertedUnitProps) {\r\n this.fromJSONSync(invertedUnitProps);\r\n }\r\n\r\n /**\r\n * @internal\r\n * Used for schema editing\r\n */\r\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\r\n this._invertsUnit = invertsUnit;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Used for schema editing\r\n */\r\n protected setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\r\n this._unitSystem = unitSystem;\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 MutableInvertedUnit extends InvertedUnit {\r\n public abstract override setInvertsUnit(invertsUnit: LazyLoadedUnit): void;\r\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAE7D,qCAAkC;AAClC,iDAA8C;AAC9C,qDAAuE;AACvE,6CAA0C;AAC1C,iCAA8B;AAE9B;;GAEG;AACH,MAAa,cAAe,SAAQ,uBAAU;IACnB,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;IACxE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7E,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAA6C,EAAE,CAAC;IACpE,gBAAgB,CAA2C;IAEnE,4DAA4D;IAC5D,IAAW,yBAAyB,KAAoD,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7H,sCAAsC;IACtC,IAAW,mBAAmB,KAA+C,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAEhH,uBAAuB;IACvB,IAAW,eAAe,KAA0D,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEnH,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAE1D;;;;;OAKG;IACO,qBAAqB,CAAC,MAAyC,EAAE,YAAqB,KAAK;QACnG,qCAAqC;QACrC,mEAAmE;QACnE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAA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AAqB;QAC9C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;;OAGG;IACO,kBAAkB,CAAC,KAA0D;QACrF,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,cAAc;YAC/D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,sBAAsB,CAAC,IAAiB;QACpD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC9B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IAClI,CAAC;CACF;AAlPD,wCAkPC;AACD;;;GAGG;AACH,MAAsB,qBAAsB,SAAQ,cAAc;CAMjE;AAND,sDAMC","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 { KindOfQuantityProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { OverrideFormat, OverrideFormatProps } from \"./OverrideFormat\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/** A Typescript class representation of a KindOfQuantity.\n * @public @preview\n */\nexport class KindOfQuantity extends SchemaItem {\n public override readonly schemaItemType = KindOfQuantity.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.KindOfQuantity; }\n private _relativeError: number = 1.0;\n private _presentationFormats: Array<LazyLoadedFormat | OverrideFormat> = [];\n private _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;\n\n /** The first presentation format in the list of Formats. */\n public get defaultPresentationFormat(): LazyLoadedFormat | OverrideFormat | undefined { return this.presentationFormats[0]; }\n\n /** A list of presentation formats. */\n public get presentationFormats(): Array<LazyLoadedFormat | OverrideFormat> { return this._presentationFormats; }\n\n /** Persistence unit */\n public get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined { return this._persistenceUnit; }\n\n public get relativeError() { return this._relativeError; }\n\n /**\n *\n * @param format The Format to add to this KindOfQuantity\n * @param isDefault\n * @internal\n */\n protected addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean = false) {\n // TODO: Add some sort of validation?\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);\n }\n\n /** Creates an OverrideFormat in the context of this KindOfQuantity.\n * @param parent The Format to override.\n * @param precision The precision override\n * @param unitLabelOverrides The list of unit and label overrides.\n * @internal\n */\n protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat {\n if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);\n\n if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);\n\n // TODO: Check compatibility of Unit overrides with the persistence unit\n\n return new OverrideFormat(parent, precision, unitLabelOverrides);\n }\n\n private async processPresentationUnits(presentationUnitsJson: string | string[]): Promise<void> {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = await this.schema.lookupItem(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);\n \n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n private processPresentationUnitsSync(presentationUnitsJson: string | string[]): void {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = this.schema.lookupItemSync(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);\n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n /**\n * Save this KindOfQuantity'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): KindOfQuantityProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.relativeError = this.relativeError;\n schemaJson.persistenceUnit = this.persistenceUnit!.fullName;\n if (undefined !== this.presentationFormats && 0 < this.presentationFormats.length)\n schemaJson.presentationUnits = this.presentationFormats.map((format) => format.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 persistenceUnit = await this.persistenceUnit;\n if (undefined !== persistenceUnit) {\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, persistenceUnit.schema, persistenceUnit.name);\n itemElement.setAttribute(\"persistenceUnit\", unitName);\n }\n\n if (undefined !== this.presentationFormats) {\n const presUnitStrings: string[] = [];\n for(const format of this.presentationFormats) {\n if (!OverrideFormat.isOverrideFormat(format)) {\n const resolvedFormat = await format;\n presUnitStrings.push(XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));\n continue;\n }\n presUnitStrings.push(format.fullNameXml(this.schema));\n };\n itemElement.setAttribute(\"presentationUnits\", presUnitStrings.join(\";\"));\n }\n itemElement.setAttribute(\"relativeError\", this.relativeError.toString());\n\n return itemElement;\n }\n\n public override fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void {\n super.fromJSONSync(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if (Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);\n }\n\n public override async fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void> {\n await super.fromJSON(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if (Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setRelativeError(relativeError: number): void {\n this._relativeError = relativeError;\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void {\n this._persistenceUnit = value;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns True if the item is a KindOfQuantity, false otherwise.\n */\n public static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity {\n if (item && item.schemaItemType === SchemaItemType.KindOfQuantity)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.\n * @internal\n */\n public static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity {\n if (!this.isKindOfQuantity(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;\n public abstract override setRelativeError(relativeError: number): void;\n}\n"]}
1
+ {"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAE7D,qCAAkC;AAClC,iDAA8C;AAC9C,qDAAuE;AACvE,6CAA0C;AAC1C,iCAA8B;AAE9B;;GAEG;AACH,MAAa,cAAe,SAAQ,uBAAU;IACnB,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;IACxE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7E,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAA6C,EAAE,CAAC;IACpE,gBAAgB,CAA2C;IAEnE,4DAA4D;IAC5D,IAAW,yBAAyB,KAAoD,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7H,sCAAsC;IACtC,IAAW,mBAAmB,KAA+C,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAEhH,uBAAuB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,KAAK,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC;;YAEtG,IAAI,CAAC,gBAAgB,GAAG,IAAI,wCAAuB,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC;QAGxG,IAAI,SAAS,KAAK,mBAAmB,CAAC,iBAAiB;YACrD,MAAM,IAAI,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACO,gBAAgB,CAAC,aAAqB;QAC9C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;;OAGG;IACO,kBAAkB,CAAC,KAA0D;QACrF,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,cAAc;YAC/D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,sBAAsB,CAAC,IAAiB;QACpD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC9B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IAClI,CAAC;CACF;AAlPD,wCAkPC;AACD;;;GAGG;AACH,MAAsB,qBAAsB,SAAQ,cAAc;CAMjE;AAND,sDAMC","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 { KindOfQuantityProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\r\nimport { Format } from \"./Format\";\r\nimport { InvertedUnit } from \"./InvertedUnit\";\r\nimport { OverrideFormat, OverrideFormatProps } from \"./OverrideFormat\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { Unit } from \"./Unit\";\r\n\r\n/** A Typescript class representation of a KindOfQuantity.\r\n * @public @preview\r\n */\r\nexport class KindOfQuantity extends SchemaItem {\r\n public override readonly schemaItemType = KindOfQuantity.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.KindOfQuantity; }\r\n private _relativeError: number = 1.0;\r\n private _presentationFormats: Array<LazyLoadedFormat | OverrideFormat> = [];\r\n private _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;\r\n\r\n /** The first presentation format in the list of Formats. */\r\n public get defaultPresentationFormat(): LazyLoadedFormat | OverrideFormat | undefined { return this.presentationFormats[0]; }\r\n\r\n /** A list of presentation formats. */\r\n public get presentationFormats(): Array<LazyLoadedFormat | OverrideFormat> { return this._presentationFormats; }\r\n\r\n /** Persistence unit */\r\n public get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined { return this._persistenceUnit; }\r\n\r\n public get relativeError() { return this._relativeError; }\r\n\r\n /**\r\n *\r\n * @param format The Format to add to this KindOfQuantity\r\n * @param isDefault\r\n * @internal\r\n */\r\n protected addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean = false) {\r\n // TODO: Add some sort of validation?\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n (isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);\r\n }\r\n\r\n /** Creates an OverrideFormat in the context of this KindOfQuantity.\r\n * @param parent The Format to override.\r\n * @param precision The precision override\r\n * @param unitLabelOverrides The list of unit and label overrides.\r\n * @internal\r\n */\r\n protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat {\r\n if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);\r\n\r\n if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);\r\n\r\n // TODO: Check compatibility of Unit overrides with the persistence unit\r\n\r\n return new OverrideFormat(parent, precision, unitLabelOverrides);\r\n }\r\n\r\n private async processPresentationUnits(presentationUnitsJson: string | string[]): Promise<void> {\r\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\r\n for (const formatString of presUnitsArr) {\r\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\r\n\r\n const format = await this.schema.lookupItem(presFormatOverride.name, Format);\r\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\r\n\r\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\r\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\r\n continue;\r\n }\r\n\r\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\r\n if (undefined !== presFormatOverride.unitAndLabels) {\r\n if (4 < presFormatOverride.unitAndLabels.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\r\n\r\n unitAndLabels = [];\r\n for (const unitOverride of presFormatOverride.unitAndLabels) {\r\n const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);\r\n\r\n if(Unit.isUnit(unitOrInverted))\r\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\r\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\r\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\r\n }\r\n }\r\n\r\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\r\n this.addPresentationFormat(overrideFormat);\r\n }\r\n }\r\n\r\n private processPresentationUnitsSync(presentationUnitsJson: string | string[]): void {\r\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\r\n for (const formatString of presUnitsArr) {\r\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\r\n\r\n const format = this.schema.lookupItemSync(presFormatOverride.name, Format);\r\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\r\n\r\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\r\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\r\n continue;\r\n }\r\n\r\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\r\n if (undefined !== presFormatOverride.unitAndLabels) {\r\n if (4 < presFormatOverride.unitAndLabels.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\r\n\r\n unitAndLabels = [];\r\n for (const unitOverride of presFormatOverride.unitAndLabels) {\r\n const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);\r\n if(Unit.isUnit(unitOrInverted))\r\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\r\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\r\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\r\n else\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\r\n }\r\n }\r\n\r\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\r\n this.addPresentationFormat(overrideFormat);\r\n }\r\n }\r\n\r\n /**\r\n * Save this KindOfQuantity'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): KindOfQuantityProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.relativeError = this.relativeError;\r\n schemaJson.persistenceUnit = this.persistenceUnit!.fullName;\r\n if (undefined !== this.presentationFormats && 0 < this.presentationFormats.length)\r\n schemaJson.presentationUnits = this.presentationFormats.map((format) => format.fullName);\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n const persistenceUnit = await this.persistenceUnit;\r\n if (undefined !== persistenceUnit) {\r\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, persistenceUnit.schema, persistenceUnit.name);\r\n itemElement.setAttribute(\"persistenceUnit\", unitName);\r\n }\r\n\r\n if (undefined !== this.presentationFormats) {\r\n const presUnitStrings: string[] = [];\r\n for(const format of this.presentationFormats) {\r\n if (!OverrideFormat.isOverrideFormat(format)) {\r\n const resolvedFormat = await format;\r\n presUnitStrings.push(XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));\r\n continue;\r\n }\r\n presUnitStrings.push(format.fullNameXml(this.schema));\r\n };\r\n itemElement.setAttribute(\"presentationUnits\", presUnitStrings.join(\";\"));\r\n }\r\n itemElement.setAttribute(\"relativeError\", this.relativeError.toString());\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void {\r\n super.fromJSONSync(kindOfQuantityProps);\r\n this._relativeError = kindOfQuantityProps.relativeError;\r\n\r\n const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);\r\n if (undefined === persistenceUnit)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\r\n\r\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\r\n\r\n if (Unit.isUnit(persistenceUnit))\r\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\r\n else\r\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\r\n\r\n if (undefined !== kindOfQuantityProps.presentationUnits)\r\n this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);\r\n }\r\n\r\n public override async fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void> {\r\n await super.fromJSON(kindOfQuantityProps);\r\n this._relativeError = kindOfQuantityProps.relativeError;\r\n\r\n const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);\r\n if (undefined === persistenceUnit)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\r\n\r\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\r\n\r\n if (Unit.isUnit(persistenceUnit))\r\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\r\n else\r\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\r\n\r\n\r\n if (undefined !== kindOfQuantityProps.presentationUnits)\r\n await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);\r\n }\r\n\r\n /**\r\n * Used for schema editing.\r\n * @internal\r\n */\r\n protected setRelativeError(relativeError: number): void {\r\n this._relativeError = relativeError;\r\n }\r\n\r\n /**\r\n * Used for schema editing.\r\n * @internal\r\n */\r\n protected setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void {\r\n this._persistenceUnit = value;\r\n }\r\n\r\n /**\r\n * Type guard to check if the SchemaItem is of type KindOfQuantity.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is a KindOfQuantity, false otherwise.\r\n */\r\n public static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity {\r\n if (item && item.schemaItemType === SchemaItemType.KindOfQuantity)\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 KindOfQuantity.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.\r\n * @internal\r\n */\r\n public static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity {\r\n if (!this.isKindOfQuantity(item))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\r\n public abstract override addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;\r\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n public abstract override setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;\r\n public abstract override setRelativeError(relativeError: number): void;\r\n}\r\n"]}
@@ -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,4CAA6D;AAG7D,mCAAkC;AAClC,+CAAoG;AAMpG;;;GAGG;AACH,MAAa,KAAM,SAAQ,eAAO;IACP,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;IAC/D,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,UAAU,CAAyB;IAE3C,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,gBAAgB;IAChB,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,2BAAe,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;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;IAED;;;;;;;;OAQG;IACO,4BAA4B,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QAClI,OAAO,IAAI,CAAC,WAAW,CAAC,IAAA,0CAA4B,EAAC,IAAI,EAAE,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,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,uCAAuC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAE/G,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;QACvC,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,kCAAkC,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEpH,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;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,KAAK,WAAW,CAAC,CAAC;IAChH,CAAC;CACF;AA1ID,sBA0IC;AACD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,KAAK;CAK/C;AALD,oCAKC","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 { MixinProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\nimport { NavigationProperty } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of a Mixin.\n * @public @preview\n */\nexport class Mixin extends ECClass {\n public override readonly schemaItemType = Mixin.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.Mixin; }\n private _appliesTo?: LazyLoadedEntityClass;\n\n public get appliesTo(): LazyLoadedEntityClass | undefined {\n return this._appliesTo;\n }\n\n /** @internal */\n constructor(schema: Schema, name: string) {\n super(schema, name, ECClassModifier.Abstract);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @returns\n *\n * @internal\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * @internal\n */\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\n this._appliesTo = appliesTo;\n }\n\n /**\n * Save this Mixin'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): MixinProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (undefined !== this.appliesTo) {\n schemaJson.appliesTo = this.appliesTo.fullName;\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\n // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\n // already exist for this item before creating a new one to apply IsMixin\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\n if (undefined !== coreCustomSchema) {\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\n isMixinElement.setAttribute(\"xmlns\", xmlns);\n }\n\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\n const appliesTo = await this.appliesTo;\n if (undefined !== appliesTo) {\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\n appliesToElement.textContent = appliesToName;\n isMixinElement.appendChild(appliesToElement);\n }\n\n customAttributes.appendChild(isMixinElement);\n itemElement.appendChild(customAttributes);\n\n return itemElement;\n }\n\n public override fromJSONSync(mixinProps: MixinProps) {\n super.fromJSONSync(mixinProps);\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\n if (!entityClassSchemaItemKey)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\n async () => {\n const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey, EntityClass);\n if (undefined === appliesTo)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n return appliesTo;\n });\n }\n\n public override async fromJSON(mixinProps: MixinProps) {\n this.fromJSONSync(mixinProps);\n }\n\n public async applicableTo(entityClass: EntityClass) {\n if (!this.appliesTo)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\n\n const appliesTo = await this.appliesTo;\n if (appliesTo === undefined)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\n\n return appliesTo.is(entityClass);\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Mixin.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Mixin, false otherwise.\n */\n public static isMixin(item?: SchemaItem): item is Mixin {\n if (item && item.schemaItemType === SchemaItemType.Mixin)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Mixin.\n * @param item The SchemaItem to check.\n * @returns The item cast to Mixin if it is a Mixin, undefined otherwise.\n * @internal\n */\n public static assertIsMixin(item?: SchemaItem): asserts item is Mixin {\n if (!this.isMixin(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Mixin}' (Mixin)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableMixin extends Mixin {\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
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,4CAA6D;AAG7D,mCAAkC;AAClC,+CAAoG;AAMpG;;;GAGG;AACH,MAAa,KAAM,SAAQ,eAAO;IACP,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;IAC/D,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,UAAU,CAAyB;IAE3C,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IA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H,CAAC;CACF;AA1ID,sBA0IC;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 { ECSchemaError, ECSchemaStatus } 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 * @public @preview\r\n */\r\nexport class Mixin extends ECClass {\r\n public override readonly schemaItemType = Mixin.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.Mixin; }\r\n private _appliesTo?: LazyLoadedEntityClass;\r\n\r\n public get appliesTo(): LazyLoadedEntityClass | undefined {\r\n return this._appliesTo;\r\n }\r\n\r\n /** @internal */\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 * @internal\r\n */\r\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n * @returns\r\n *\r\n * @internal\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 * @internal\r\n */\r\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\r\n this._appliesTo = appliesTo;\r\n }\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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 * @internal\r\n */\r\n public static assertIsMixin(item?: SchemaItem): asserts item is Mixin {\r\n if (!this.isMixin(item))\r\n throw new ECSchemaError(ECSchemaStatus.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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"OverrideFormat.js","sourceRoot":"","sources":["../../../src/Metadata/OverrideFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAyOH,wCAEC;AAzOD,oFAAiF;AACjF,4CAA8C;AAC9C,wDAAqK;AAMrK,4CAA6D;AAW7D;;;GAGG;AACH,MAAa,cAAc;IACjB,UAAU,CAA0C;IACpD,MAAM,CAAwE;IAEtF,uDAAuD;IACvC,MAAM,CAAS;IAE/B;;;OAGG;IACa,IAAI,CAAS;IAE7B,gBAAgB;IAChB,YAAY,MAAc,EAAE,SAAkD,EAAE,aAAoF;QAClK,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;QAClB,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,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AC;QAEtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,kCAAkC;YAClC,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,KAAK,MAAM,IAAI,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;AA3MD,wCA2MC;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":["/*---------------------------------------------------------------------------------------------\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 { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { DecimalPrecision, FormatProps, formatStringRgx, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"@itwin/core-quantity\";\nimport { Format } from \"./Format\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItemOverrideFormatProps } from \"../Deserialization/JsonProps\";\nimport { Mutable } from \"@itwin/core-bentley\";\nimport { LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\n\n/**\n * @public @preview\n */\nexport interface OverrideFormatProps {\n readonly name: string;\n readonly precision?: number;\n readonly unitAndLabels?: Array<[string, string | undefined]>; // Tuple of [unit name | unit label]\n}\n\n/**\n * Overrides of a Format, from a Schema, and is SchemaItem that is used specifically on KindOfQuantity.\n * @public @preview\n */\nexport class OverrideFormat {\n private _precision?: DecimalPrecision | FractionalPrecision;\n private _units?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>;\n\n /** The Format that this OverrideFormat is extending */\n public readonly parent: Format;\n\n /** The name of this OverrideFormat.\n *\n * This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.\n */\n public readonly name: string;\n\n /** @internal */\n constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>) {\n this.parent = parent;\n this.name = OverrideFormat.createOverrideFormatFullName(parent, precision, unitAndLabels);\n this._precision = precision;\n this._units = unitAndLabels;\n }\n\n // Properties that can be overriden\n public get precision(): DecimalPrecision | FractionalPrecision {\n return (undefined === this._precision) ? this.parent.precision : this._precision;\n }\n\n public get units(): ReadonlyArray<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined {\n return (undefined === this._units) ? this.parent.units : this._units;\n }\n\n // Properties that cannot be overriden\n public get fullName(): string { return this.name; }\n public get roundFactor(): number { return this.parent.roundFactor; }\n public get type(): FormatType { return this.parent.type; }\n public get minWidth(): number | undefined { return this.parent.minWidth; }\n public get scientificType(): ScientificType | undefined { return this.parent.scientificType; }\n public get showSignOption(): ShowSignOption { return this.parent.showSignOption; }\n public get decimalSeparator(): string { return this.parent.decimalSeparator; }\n public get thousandSeparator(): string { return this.parent.thousandSeparator; }\n public get uomSeparator(): string { return this.parent.uomSeparator; }\n public get stationSeparator(): string { return this.parent.stationSeparator; }\n public get stationOffsetSize(): number | undefined { return this.parent.stationOffsetSize; }\n public get formatTraits(): FormatTraits { return this.parent.formatTraits; }\n public get spacer(): string | undefined { return this.parent.spacer; }\n public get includeZero(): boolean | undefined { return this.parent.includeZero; }\n\n public hasFormatTrait(formatTrait: FormatTraits) {\n return (this.parent.formatTraits & formatTrait) === formatTrait;\n }\n\n /** Returns the format string of this override in the Xml full name format.\n * @internal\n */\n public fullNameXml(koqSchema: Schema): string {\n let fullName = XmlSerializationUtils.createXmlTypedName(koqSchema, this.parent.schema, this.parent.name);\n\n if (undefined !== this.precision)\n fullName += `(${this.precision.toString()})`;\n\n if (undefined === this._units)\n return fullName;\n for (const [unit, unitLabel] of this._units) {\n const unitSchema = koqSchema.context.getSchemaSync(unit.schemaKey);\n if(unitSchema === undefined)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The unit schema ${unit.schemaKey} is not found in the context.`);\n\n fullName += \"[\";\n fullName += XmlSerializationUtils.createXmlTypedName(koqSchema, unitSchema, unit.name);\n if (unitLabel !== undefined)\n fullName += `|${unitLabel}`;\n fullName += `]`;\n }\n return fullName;\n }\n\n /**\n * Creates a valid OverrideFormat fullName from the parent Format and overridden units.\n * @param parent The parent Format.\n * @param unitAndLabels The overridden unit and labels collection.\n */\n public static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): string {\n let fullName = parent.fullName;\n\n if (precision)\n fullName += `(${precision.toString()})`;\n\n if (undefined === unitAndLabels)\n return fullName;\n for (const [unit, unitLabel] of unitAndLabels)\n if (undefined === unitLabel)\n fullName += `[${unit.fullName}]`;\n else\n fullName += `[${unit.fullName}|${unitLabel}]`;\n return fullName;\n }\n\n /** Parses the format string into the parts that make up an Override Format\n * @param formatString\n */\n public static parseFormatString(formatString: string): OverrideFormatProps {\n const match = formatString.split(formatStringRgx); // split string based on regex groups\n if (undefined === match[1])\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The format string, ${formatString}, on KindOfQuantity is missing a format.`);\n\n let precision: OverrideFormatProps[\"precision\"];\n if (undefined !== match[2] && undefined !== match[3]) {\n const overrideString = match[2];\n const tokens: string[] = [];\n let prevPos = 1; // Initial position is the character directly after the opening '(' in the override string.\n let currPos;\n\n // TODO need to include `,` as a valid search argument.\n while (-1 !== (currPos = overrideString.indexOf(\")\", prevPos))) {\n tokens.push(overrideString.substring(prevPos, currPos));\n prevPos = currPos + 1;\n }\n\n if (overrideString.length > 0 && undefined === tokens.find((token) => {\n return \"\" !== token; // there is at least one token that is not empty.\n })) {\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n }\n\n // The first override parameter overrides the default precision of the format\n const precisionIndx: number = 0;\n if (tokens.length >= precisionIndx + 1) {\n if (tokens[precisionIndx].length > 0) {\n precision = Number.parseInt(tokens[precisionIndx], 10);\n if (Number.isNaN(precision))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The format string '${formatString}' on KindOfQuantity has a precision override '${tokens[precisionIndx]}' that is not number.`);\n }\n }\n }\n\n let i = 4;\n let unitAndLabels: OverrideFormatProps[\"unitAndLabels\"];\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\n if (undefined === match[i])\n break;\n // Unit override required\n if (undefined === match[i + 1])\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n if (undefined === unitAndLabels)\n unitAndLabels = [];\n\n if (undefined !== match[i + 2]) // matches '|'\n 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)\n else\n unitAndLabels.push([match[i + 1], undefined]); // add unit name\n\n i += 4;\n }\n\n return { name: match[1], precision, unitAndLabels };\n }\n\n /**\n * @internal\n */\n public static isOverrideFormat(format: unknown): format is OverrideFormat {\n const overrideFormat = format as Partial<OverrideFormat>;\n\n return overrideFormat !== undefined && overrideFormat.name !== undefined && overrideFormat.parent !== undefined && overrideFormat.parent.schemaItemType === SchemaItemType.Format;\n }\n\n /**\n * Returns a JSON object that contains the specification for the OverrideFormat where the precision and units properties have been overriden.\n * If the precision and/or units properties have been overriden, the returned object will contain a \"name\" and a \"parent\" property.\n * The \"name\" property identifies the OverrideFormat object itself and the \"parent\" property identifies the Format that has been overriden.\n * This method is not intended for complete serialization as it does not serialize any of the schema item properties.\n */\n public getFormatProps(): SchemaItemOverrideFormatProps {\n const formatJson = this.parent.toJSON() as Mutable<SchemaItemOverrideFormatProps>;\n\n if (this.parent.fullName !== this.fullName) {\n // Update name and parent properties to distinguish it from parent Format\n formatJson.name = this.fullName;\n formatJson.parent = this.parent.fullName;\n }\n\n // Update Precision overriden property\n formatJson.precision = this.precision;\n\n if (this.units !== undefined) {\n // Update Units overriden property\n const units = [];\n for (const unit of this.units) {\n units.push({\n name: unit[0].fullName,\n label: unit[1],\n });\n }\n\n formatJson.composite = {\n spacer: (this.spacer !== \" \") ? this.spacer : undefined,\n includeZero: (this.includeZero === false) ? this.includeZero : undefined,\n units,\n };\n }\n\n return formatJson;\n }\n}\n\n/**\n * @internal\n */\nexport function getFormatProps(format: Format | OverrideFormat): FormatProps {\n return OverrideFormat.isOverrideFormat(format) ? format.getFormatProps() : format.toJSON();\n}\n"]}
1
+ {"version":3,"file":"OverrideFormat.js","sourceRoot":"","sources":["../../../src/Metadata/OverrideFormat.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAyOH,wCAEC;AAzOD,oFAAiF;AACjF,4CAA8C;AAC9C,wDAAqK;AAMrK,4CAA6D;AAW7D;;;GAGG;AACH,MAAa,cAAc;IACjB,UAAU,CAA0C;IACpD,MAAM,CAAwE;IAEtF,uDAAuD;IACvC,MAAM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AAO,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 { Schema } from \"./Schema\";\r\nimport { SchemaItemOverrideFormatProps } from \"../Deserialization/JsonProps\";\r\nimport { Mutable } from \"@itwin/core-bentley\";\r\nimport { LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\n\r\n/**\r\n * @public @preview\r\n */\r\nexport interface OverrideFormatProps {\r\n readonly name: string;\r\n readonly precision?: number;\r\n readonly 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 * @public @preview\r\n */\r\nexport class OverrideFormat {\r\n private _precision?: DecimalPrecision | FractionalPrecision;\r\n private _units?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, 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 /** @internal */\r\n constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, 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 {\r\n return (undefined === this._precision) ? this.parent.precision : this._precision;\r\n }\r\n\r\n public get units(): ReadonlyArray<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined {\r\n return (undefined === this._units) ? this.parent.units : this._units;\r\n }\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 * @internal\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 const unitSchema = koqSchema.context.getSchemaSync(unit.schemaKey);\r\n if(unitSchema === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The unit schema ${unit.schemaKey} is not found in the context.`);\r\n\r\n fullName += \"[\";\r\n fullName += XmlSerializationUtils.createXmlTypedName(koqSchema, unitSchema, 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<[LazyLoadedUnit | LazyLoadedInvertedUnit, 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 ECSchemaError(ECSchemaStatus.InvalidECJson, `The format string, ${formatString}, on KindOfQuantity is missing a format.`);\r\n\r\n let precision: OverrideFormatProps[\"precision\"];\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 ECSchemaError(ECSchemaStatus.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 if (tokens.length >= precisionIndx + 1) {\r\n if (tokens[precisionIndx].length > 0) {\r\n precision = Number.parseInt(tokens[precisionIndx], 10);\r\n if (Number.isNaN(precision))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The format string '${formatString}' on KindOfQuantity has a precision override '${tokens[precisionIndx]}' that is not number.`);\r\n }\r\n }\r\n }\r\n\r\n let i = 4;\r\n let unitAndLabels: OverrideFormatProps[\"unitAndLabels\"];\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 ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\r\n\r\n if (undefined === unitAndLabels)\r\n unitAndLabels = [];\r\n\r\n if (undefined !== match[i + 2]) // matches '|'\r\n 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 unitAndLabels.push([match[i + 1], undefined]); // add unit name\r\n\r\n i += 4;\r\n }\r\n\r\n return { name: match[1], precision, unitAndLabels };\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static isOverrideFormat(format: unknown): format is OverrideFormat {\r\n const overrideFormat = format as Partial<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 +1 @@
1
- {"version":3,"file":"Phenomenon.js","sourceRoot":"","sources":["../../../src/Metadata/Phenomenon.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAA8C;AAC9C,4CAA6D;AAE7D,6CAA0C;AAE1C,uBAAuB;AACvB,MAAa,UAAW,SAAQ,uBAAU;IACf,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IACpE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IACzE,WAAW,CAAS,CAAC,sKAAsK;IAEnM,gBAAgB;IAChB,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EA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AED;;;;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;;;;;OAKG;IACI,MAAM,CAAC,kBAAkB,CAAC,IAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAC1B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,UAAU,gBAAgB,CAAC,CAAC;IAC1H,CAAC;CACF;AA3ED,gCA2EC;AAED;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,UAAU;CAGzD;AAHD,8CAGC","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 { PhenomenonProps } from \"../Deserialization/JsonProps\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/** @public @preview */\nexport class Phenomenon extends SchemaItem {\n public override readonly schemaItemType = Phenomenon.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.Phenomenon; }\n private _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\n\n /** @internal */\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._definition = \"\";\n }\n\n public get definition(): string { return this._definition; }\n\n /**\n * Save this Phenomenon'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): PhenomenonProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.definition = this.definition;\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(\"definition\", this.definition);\n return itemElement;\n }\n\n public override fromJSONSync(phenomenonProps: PhenomenonProps) {\n super.fromJSONSync(phenomenonProps);\n if (this._definition !== \"\" && phenomenonProps.definition.toLowerCase() !== this._definition.toLowerCase())\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${this.name} has an invalid 'definition' attribute.`);\n else if (this._definition === \"\")\n this._definition = phenomenonProps.definition;\n }\n\n public override async fromJSON(phenomenonProps: PhenomenonProps) {\n this.fromJSONSync(phenomenonProps);\n }\n\n /**\n *\n * @param definition\n * @internal\n */\n protected async setDefinition(definition: string) {\n this._definition = definition;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Phenomenon.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Phenomenon, false otherwise.\n */\n public static isPhenomenon(item?: SchemaItem): item is Phenomenon {\n if (item && item.schemaItemType === SchemaItemType.Phenomenon)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Phenomenon.\n * @param item The SchemaItem to check.\n * @returns The item cast to Phenomenon if it is a Phenomenon, undefined otherwise.\n * @internal\n */\n public static assertIsPhenomenon(item?: SchemaItem): asserts item is Phenomenon {\n if (!this.isPhenomenon(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Phenomenon}' (Phenomenon)`);\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutablePhenomenon extends Phenomenon {\n public abstract override setDefinition(definition: string): Promise<void>;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
1
+ {"version":3,"file":"Phenomenon.js","sourceRoot":"","sources":["../../../src/Metadata/Phenomenon.ts"],"names":[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AAE,kBAAkB,IAAI,CAAC,IAAI,yCAAyC,CAAC,CAAC;aACzH,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;IAED;;;;OAIG;IACO,KAAK,CAAC,aAAa,CAAC,UAAkB;QAC9C,IAAI,CAAC,WAAW,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;;;;;OAKG;IACI,MAAM,CAAC,kBAAkB,CAAC,IAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAC1B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,UAAU,gBAAgB,CAAC,CAAC;IAC1H,CAAC;CACF;AA3ED,gCA2EC;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 { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/** @public @preview */\r\nexport class Phenomenon extends SchemaItem {\r\n public override readonly schemaItemType = Phenomenon.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.Phenomenon; }\r\n private _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 /** @internal */\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 ECSchemaError(ECSchemaStatus.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 /**\r\n *\r\n * @param definition\r\n * @internal\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 * @internal\r\n */\r\n public static assertIsPhenomenon(item?: SchemaItem): asserts item is Phenomenon {\r\n if (!this.isPhenomenon(item))\r\n throw new ECSchemaError(ECSchemaStatus.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"]}