@itwin/ecschema-metadata 5.0.0-dev.9 → 5.0.0-dev.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/lib/cjs/Constants.js +20 -20
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +83 -34
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +73 -23
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.js +6 -4
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js +1 -0
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts +3 -3
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +8 -0
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +3 -0
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +3 -0
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +11 -3
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +2 -6
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js +1 -0
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +21 -1
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +33 -2
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js +1 -0
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +10 -3
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +75 -16
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +168 -46
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +14 -1
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +27 -2
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +20 -8
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +42 -22
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +22 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +41 -1
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +68 -3
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +17 -6
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +15 -1
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +23 -2
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +9 -0
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +22 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +5 -1
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +83 -28
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +21 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +47 -10
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +116 -11
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +135 -33
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +10 -0
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +8 -1
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +21 -3
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +21 -3
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
- package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js +3 -3
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +7 -1
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +13 -3
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +2 -2
- package/lib/cjs/SchemaLoader.d.ts.map +1 -1
- package/lib/cjs/SchemaLoader.js +1 -0
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js +69 -65
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js +11 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js +6 -4
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +1 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +2 -3
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.js +20 -20
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Context.d.ts +83 -34
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +71 -21
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.js +6 -4
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js +1 -0
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts +3 -3
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +8 -0
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +3 -0
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +3 -0
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +11 -3
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +2 -6
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.js +1 -0
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +21 -1
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +31 -1
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.js +1 -0
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +10 -3
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +75 -16
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +169 -47
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +14 -1
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +27 -2
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +20 -8
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +42 -22
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +14 -1
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +22 -1
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +41 -1
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +68 -3
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +17 -6
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +43 -18
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +15 -1
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +24 -3
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +9 -0
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +22 -1
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +5 -1
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +84 -29
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +21 -1
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +48 -11
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +116 -11
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +135 -33
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +11 -1
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +8 -1
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +21 -3
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +21 -3
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaJsonLocater.d.ts +3 -3
- package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/esm/SchemaJsonLocater.js +3 -3
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +7 -1
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +13 -3
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +2 -2
- package/lib/esm/SchemaLoader.d.ts.map +1 -1
- package/lib/esm/SchemaLoader.js +1 -0
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js +69 -65
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/Parser.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js +9 -7
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js +2 -0
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js +11 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js +6 -4
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +1 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +2 -3
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +14 -14
|
@@ -12,14 +12,19 @@ const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtil
|
|
|
12
12
|
const ECObjects_1 = require("../ECObjects");
|
|
13
13
|
const Exception_1 = require("../Exception");
|
|
14
14
|
const core_quantity_1 = require("@itwin/core-quantity");
|
|
15
|
+
const InvertedUnit_1 = require("./InvertedUnit");
|
|
15
16
|
const SchemaItem_1 = require("./SchemaItem");
|
|
17
|
+
const Unit_1 = require("./Unit");
|
|
16
18
|
/**
|
|
17
19
|
* @beta
|
|
18
20
|
*/
|
|
19
21
|
class Format extends SchemaItem_1.SchemaItem {
|
|
22
|
+
schemaItemType = Format.schemaItemType;
|
|
23
|
+
static get schemaItemType() { return ECObjects_1.SchemaItemType.Format; }
|
|
24
|
+
_base;
|
|
25
|
+
_units;
|
|
20
26
|
constructor(schema, name) {
|
|
21
27
|
super(schema, name);
|
|
22
|
-
this.schemaItemType = ECObjects_1.SchemaItemType.Format;
|
|
23
28
|
this._base = new core_quantity_1.BaseFormat(name);
|
|
24
29
|
}
|
|
25
30
|
get roundFactor() { return this._base.roundFactor; }
|
|
@@ -83,7 +88,7 @@ class Format extends SchemaItem_1.SchemaItem {
|
|
|
83
88
|
// Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation
|
|
84
89
|
for (const unit of formatProps.composite.units) {
|
|
85
90
|
const newUnit = this.schema.lookupItemSync(unit.name);
|
|
86
|
-
if (undefined === newUnit)
|
|
91
|
+
if (undefined === newUnit || (!Unit_1.Unit.isUnit(newUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(newUnit)))
|
|
87
92
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, ``);
|
|
88
93
|
this.addUnit(newUnit, unit.label);
|
|
89
94
|
}
|
|
@@ -96,7 +101,7 @@ class Format extends SchemaItem_1.SchemaItem {
|
|
|
96
101
|
// Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation
|
|
97
102
|
for (const unit of formatProps.composite.units) {
|
|
98
103
|
const newUnit = await this.schema.lookupItem(unit.name);
|
|
99
|
-
if (undefined === newUnit)
|
|
104
|
+
if (undefined === newUnit || (!Unit_1.Unit.isUnit(newUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(newUnit)))
|
|
100
105
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, ``);
|
|
101
106
|
this.addUnit(newUnit, unit.label);
|
|
102
107
|
}
|
|
@@ -231,6 +236,66 @@ class Format extends SchemaItem_1.SchemaItem {
|
|
|
231
236
|
setStationSeparator(separator) {
|
|
232
237
|
this._base.stationSeparator = separator;
|
|
233
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* @alpha Used in schema editing.
|
|
241
|
+
*/
|
|
242
|
+
setStationOffsetSize(stationOffsetSize) {
|
|
243
|
+
this._base.stationOffsetSize = stationOffsetSize;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @alpha Used in schema editing.
|
|
247
|
+
*/
|
|
248
|
+
setScientificType(scientificType) {
|
|
249
|
+
this._base.scientificType = scientificType;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @alpha Used in schema editing.
|
|
253
|
+
*/
|
|
254
|
+
setMinWidth(minWidth) {
|
|
255
|
+
this._base.minWidth = minWidth;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @alpha Used in schema editing.
|
|
259
|
+
*/
|
|
260
|
+
setSpacer(spacer) {
|
|
261
|
+
this._base.spacer = spacer;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* @alpha Used in schema editing.
|
|
265
|
+
*/
|
|
266
|
+
setIncludeZero(includeZero) {
|
|
267
|
+
this._base.includeZero = includeZero;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* @alpha Used in schema editing.
|
|
271
|
+
*/
|
|
272
|
+
setFormatTraits(formatTraits) {
|
|
273
|
+
this._base.formatTraits = formatTraits;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* @alpha Used in schema editing.
|
|
277
|
+
*/
|
|
278
|
+
setUnits(units) {
|
|
279
|
+
this._units = units;
|
|
280
|
+
}
|
|
281
|
+
/** Type guard to check if the SchemaItem is of type Format.
|
|
282
|
+
* @param item The SchemaItem to check.
|
|
283
|
+
* @returns True if the item is a Format, false otherwise.
|
|
284
|
+
*/
|
|
285
|
+
static isFormat(item) {
|
|
286
|
+
if (item && item.schemaItemType === ECObjects_1.SchemaItemType.Format)
|
|
287
|
+
return true;
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Type assertion to check if the SchemaItem is of type Format.
|
|
292
|
+
* @param item The SchemaItem to check.
|
|
293
|
+
* @returns The item cast to Format if it is a Format, undefined otherwise.
|
|
294
|
+
*/
|
|
295
|
+
static assertIsFormat(item) {
|
|
296
|
+
if (!this.isFormat(item))
|
|
297
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.Format}' (Format)`);
|
|
298
|
+
}
|
|
234
299
|
}
|
|
235
300
|
exports.Format = Format;
|
|
236
301
|
/**
|
|
@@ -1 +1 @@
|
|
|
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,4CAA+D;AAC/D,wDAG8B;AAG9B,6CAA0C;AAG1C;;GAEG;AACH,MAAa,MAAO,SAAQ,uBAAU;IAKpC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC,MAAM,CAAC;QAE5C,IAAI,CAAC,KAAK,GAAG,IAAI,0BAAU,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,IAAW,WAAW,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACnE,IAAW,IAAI,KAAiB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,IAAW,SAAS,KAA6C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/F,IAAW,QAAQ,KAAyB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzE,IAAW,cAAc,KAAiC,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7F,IAAW,cAAc,KAAqB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC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IAED;;OAEG;IACO,oBAAoB,CAAC,SAAiB;QAC9C,IAAI,CAAC,KAAK,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAC3C,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,SAAiB;QACzC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC;IACtC,CAAC;IAED;;OAEG;IACO,mBAAmB,CAAC,SAAiB;QAC7C,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAC1C,CAAC;CACF;AApQD,wBAoQC;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 { ECObjectsError, ECObjectsStatus } 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\n\r\n/**\r\n * @beta\r\n */\r\nexport class Format extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.Format;\r\n protected _base: BaseFormat;\r\n protected _units?: Array<[Unit | InvertedUnit, string | undefined]>;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.Format;\r\n\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 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(): Array<[Unit | InvertedUnit, string | undefined]> | undefined { return this._units; }\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 */\r\n protected addUnit(unit: Unit | InvertedUnit, 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 ECObjectsError(ECObjectsStatus.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 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 ECObjectsError(ECObjectsStatus.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 ECObjectsError(ECObjectsStatus.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 | InvertedUnit>(unit.name);\r\n if (undefined === newUnit)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\r\n this.addUnit(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 | InvertedUnit>(unit.name);\r\n if (undefined === newUnit)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\r\n this.addUnit(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 this.units.forEach(([unit, label]) => {\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, unit.schema, unit.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 * @alpha Used in schema editing.\r\n */\r\n protected setFormatType(formatType: FormatType) {\r\n this._base.type = formatType;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setRoundFactor(roundFactor: number) {\r\n this._base.roundFactor = roundFactor;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setShowSignOption(signOption: ShowSignOption) {\r\n this._base.showSignOption = signOption;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setDecimalSeparator(separator: string) {\r\n this._base.decimalSeparator = separator;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setThousandSeparator(separator: string) {\r\n this._base.thousandSeparator = separator;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setUomSeparator(separator: string) {\r\n this._base.uomSeparator = separator;\r\n }\r\n\r\n /**\r\n * @alpha Used in schema editing.\r\n */\r\n protected setStationSeparator(separator: string) {\r\n this._base.stationSeparator = separator;\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: Unit | InvertedUnit, 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
|
+
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Metadata/Format.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA+D;AAC/D,wDAG8B;AAC9B,iDAA8C;AAE9C,6CAA0C;AAC1C,iCAA8B;AAE9B;;GAEG;AACH,MAAa,MAAO,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AAzUD,wBAyUC;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 { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport {\n BaseFormat, DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\n ScientificType, ShowSignOption,\n} from \"@itwin/core-quantity\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/**\n * @beta\n */\nexport class Format extends SchemaItem {\n public override readonly schemaItemType = Format.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Format; }\n protected _base: BaseFormat;\n protected _units?: Array<[Unit | InvertedUnit, string | undefined]>;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._base = new BaseFormat(name);\n }\n\n public get roundFactor(): number { return this._base.roundFactor; }\n public get type(): FormatType { return this._base.type; }\n public get precision(): DecimalPrecision | FractionalPrecision { return this._base.precision; }\n public get minWidth(): number | undefined { return this._base.minWidth; }\n public get scientificType(): ScientificType | undefined { return this._base.scientificType; }\n public get showSignOption(): ShowSignOption { return this._base.showSignOption; }\n public get decimalSeparator(): string { return this._base.decimalSeparator; }\n public get thousandSeparator(): string { return this._base.thousandSeparator; }\n public get uomSeparator(): string { return this._base.uomSeparator; }\n public get stationSeparator(): string { return this._base.stationSeparator; }\n public get stationOffsetSize(): number | undefined { return this._base.stationOffsetSize; }\n public get formatTraits(): FormatTraits { return this._base.formatTraits; }\n public get spacer(): string | undefined { return this._base.spacer; }\n public get includeZero(): boolean | undefined { return this._base.includeZero; }\n public get units(): Array<[Unit | InvertedUnit, string | undefined]> | undefined { return this._units; }\n\n private parseFormatTraits(formatTraitsFromJson: string | string[]) {\n return this._base.parseFormatTraits(formatTraitsFromJson);\n }\n\n public hasFormatTrait(formatTrait: FormatTraits) {\n return this._base.hasFormatTraitSet(formatTrait);\n }\n\n /**\n * Adds a Unit, or InvertedUnit, with an optional label override.\n * @param unit The Unit, or InvertedUnit, to add to this Format.\n * @param label A label that overrides the label defined within the Unit when a value is formatted.\n */\n protected addUnit(unit: Unit | InvertedUnit, label?: string) {\n if (undefined === this._units)\n this._units = [];\n else { // Validate that a duplicate is not added.\n for (const existingUnit of this._units) {\n if (unit.fullName.toLowerCase() === existingUnit[0].fullName.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has duplicate units, '${unit.fullName}'.`); // TODO: Validation - this should be a validation error not a hard failure.\n }\n }\n\n this._units.push([unit, label]);\n }\n\n protected setPrecision(precision: number) { this._base.precision = precision; }\n\n private typecheck(formatProps: SchemaItemFormatProps) {\n this._base.loadFormatProperties(formatProps);\n\n if (undefined !== formatProps.composite) { // TODO: This is duplicated below when the units need to be processed...\n if (undefined !== formatProps.composite.includeZero)\n this._base.includeZero = formatProps.composite.includeZero;\n\n if (undefined !== formatProps.composite.spacer) {\n if (formatProps.composite.spacer.length > 1)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has a composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._base.spacer = formatProps.composite.spacer;\n }\n\n // Composite requires 1-4 units\n if (formatProps.composite.units.length <= 0 || formatProps.composite.units.length > 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);\n }\n }\n\n public override fromJSONSync(formatProps: SchemaItemFormatProps) {\n super.fromJSONSync(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = this.schema.lookupItemSync(unit.name);\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n public override async fromJSON(formatProps: SchemaItemFormatProps) {\n await super.fromJSON(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = await this.schema.lookupItem(unit.name);\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n /**\n * Save this Format's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): SchemaItemFormatProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.type = this.type;\n schemaJson.precision = this.precision;\n\n // this._spacer = \" \";\n // this._includeZero = true;\n\n // Serialize the minimal amount of information needed so anything that is the same as the default, do not serialize.\n if (0.0 !== this.roundFactor)\n schemaJson.roundFactor = this.roundFactor;\n if (ShowSignOption.OnlyNegative !== this.showSignOption)\n schemaJson.showSignOption = this.showSignOption;\n if (FormatTraits.Uninitialized !== this.formatTraits)\n schemaJson.formatTraits = formatTraitsToArray(this.formatTraits);\n if (\".\" !== this.decimalSeparator)\n schemaJson.decimalSeparator = this.decimalSeparator;\n if (\",\" !== this.thousandSeparator)\n schemaJson.thousandSeparator = this.thousandSeparator;\n if (\" \" !== this.uomSeparator)\n schemaJson.uomSeparator = this.uomSeparator;\n\n if (undefined !== this.minWidth)\n schemaJson.minWidth = this.minWidth;\n\n if (FormatType.Scientific === this.type && undefined !== this.scientificType)\n schemaJson.scientificType = this.scientificType;\n\n if (FormatType.Station === this.type) {\n if (undefined !== this.stationOffsetSize)\n schemaJson.stationOffsetSize = this.stationOffsetSize;\n if (\" \" !== this.stationSeparator)\n schemaJson.stationSeparator = this.stationSeparator;\n }\n\n if (undefined === this.units)\n return schemaJson;\n\n schemaJson.composite = {};\n\n if (\" \" !== this.spacer)\n schemaJson.composite.spacer = this.spacer;\n\n if (true !== this.includeZero)\n schemaJson.composite.includeZero = this.includeZero;\n\n schemaJson.composite.units = [];\n for (const unit of this.units) {\n schemaJson.composite.units.push({\n name: unit[0].fullName,\n label: unit[1],\n });\n }\n\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"type\", this.type.toLowerCase());\n itemElement.setAttribute(\"precision\", this.precision.toString());\n itemElement.setAttribute(\"roundFactor\", this.roundFactor.toString());\n itemElement.setAttribute(\"showSignOption\", this.showSignOption);\n itemElement.setAttribute(\"decimalSeparator\", this.decimalSeparator);\n itemElement.setAttribute(\"thousandSeparator\", this.thousandSeparator);\n itemElement.setAttribute(\"uomSeparator\", this.uomSeparator);\n itemElement.setAttribute(\"stationSeparator\", this.stationSeparator);\n\n if (undefined !== this.minWidth)\n itemElement.setAttribute(\"minWidth\", this.minWidth.toString());\n if (undefined !== this.scientificType)\n itemElement.setAttribute(\"scientificType\", this.scientificType);\n if (undefined !== this.stationOffsetSize)\n itemElement.setAttribute(\"stationOffsetSize\", this.stationOffsetSize.toString());\n\n const formatTraits = formatTraitsToArray(this.formatTraits);\n if (formatTraits.length > 0)\n itemElement.setAttribute(\"formatTraits\", formatTraits.join(\"|\"));\n\n if (undefined !== this.units) {\n const compositeElement = schemaXml.createElement(\"Composite\");\n if (undefined !== this.spacer)\n compositeElement.setAttribute(\"spacer\", this.spacer);\n if (undefined !== this.includeZero)\n compositeElement.setAttribute(\"includeZero\", this.includeZero.toString());\n\n this.units.forEach(([unit, label]) => {\n const unitElement = schemaXml.createElement(\"Unit\");\n if (undefined !== label)\n unitElement.setAttribute(\"label\", label);\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, unit.schema, unit.name);\n unitElement.textContent = unitName;\n compositeElement.appendChild(unitElement);\n });\n\n itemElement.appendChild(compositeElement);\n }\n\n return itemElement;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatType(formatType: FormatType) {\n this._base.type = formatType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setRoundFactor(roundFactor: number) {\n this._base.roundFactor = roundFactor;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setShowSignOption(signOption: ShowSignOption) {\n this._base.showSignOption = signOption;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDecimalSeparator(separator: string) {\n this._base.decimalSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setThousandSeparator(separator: string) {\n this._base.thousandSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUomSeparator(separator: string) {\n this._base.uomSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationSeparator(separator: string) {\n this._base.stationSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationOffsetSize(stationOffsetSize: number) {\n this._base.stationOffsetSize = stationOffsetSize;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setScientificType(scientificType: ScientificType) {\n this._base.scientificType = scientificType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setMinWidth(minWidth: number) {\n this._base.minWidth = minWidth;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setSpacer(spacer: string) {\n this._base.spacer = spacer;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setIncludeZero(includeZero: boolean) {\n this._base.includeZero = includeZero;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatTraits(formatTraits: FormatTraits) {\n this._base.formatTraits = formatTraits;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUnits(units: Array<[Unit | InvertedUnit, string | undefined]>) {\n this._units = units;\n }\n\n /** Type guard to check if the SchemaItem is of type Format.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Format, false otherwise.\n */\n public static isFormat(item?: SchemaItem): item is Format {\n if (item && item.schemaItemType === SchemaItemType.Format)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Format.\n * @param item The SchemaItem to check.\n * @returns The item cast to Format if it is a Format, undefined otherwise.\n */\n public static assertIsFormat(item?: SchemaItem): asserts item is Format {\n if (!this.isFormat(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Format}' (Format)`);\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableFormat extends Format {\n public abstract override addUnit(unit: Unit | InvertedUnit, label?: string): void;\n public abstract override setPrecision(precision: number): void;\n public abstract override setFormatType(formatType: FormatType): void;\n public abstract override setRoundFactor(roundFactor: number): void;\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\n public abstract override setDecimalSeparator(separator: string): void;\n public abstract override setThousandSeparator(separator: string): void;\n public abstract override setUomSeparator(separator: string): void;\n public abstract override setStationSeparator(separator: string): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -4,23 +4,28 @@
|
|
|
4
4
|
import { InvertedUnitProps } from "../Deserialization/JsonProps";
|
|
5
5
|
import { SchemaItemType } from "../ECObjects";
|
|
6
6
|
import { LazyLoadedUnit, LazyLoadedUnitSystem } from "../Interfaces";
|
|
7
|
-
import { Schema } from "./Schema";
|
|
8
7
|
import { SchemaItem } from "./SchemaItem";
|
|
9
8
|
/**
|
|
10
9
|
* An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
|
|
11
10
|
* @beta
|
|
12
11
|
*/
|
|
13
12
|
export declare class InvertedUnit extends SchemaItem {
|
|
14
|
-
readonly schemaItemType: SchemaItemType
|
|
13
|
+
readonly schemaItemType: SchemaItemType;
|
|
14
|
+
static get schemaItemType(): SchemaItemType;
|
|
15
15
|
protected _invertsUnit?: LazyLoadedUnit;
|
|
16
16
|
protected _unitSystem?: LazyLoadedUnitSystem;
|
|
17
|
-
constructor(schema: Schema, name: string);
|
|
18
17
|
get invertsUnit(): LazyLoadedUnit | undefined;
|
|
19
18
|
get unitSystem(): LazyLoadedUnitSystem | undefined;
|
|
20
19
|
/**
|
|
21
20
|
* @alpha
|
|
22
21
|
*/
|
|
23
22
|
static isInvertedUnit(object: any): object is InvertedUnit;
|
|
23
|
+
/**
|
|
24
|
+
* Type assertion to check if the SchemaItem is of type InvertedUnit.
|
|
25
|
+
* @param item The SchemaItem to check.
|
|
26
|
+
* @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
|
|
27
|
+
*/
|
|
28
|
+
static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit;
|
|
24
29
|
/**
|
|
25
30
|
* Save this InvertedUnit's properties to an object for serializing to JSON.
|
|
26
31
|
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedUnit.d.ts","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"InvertedUnit.d.ts","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":"AAIA;;G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AI;aACrD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -13,15 +13,17 @@ const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtil
|
|
|
13
13
|
const ECObjects_1 = require("../ECObjects");
|
|
14
14
|
const Exception_1 = require("../Exception");
|
|
15
15
|
const SchemaItem_1 = require("./SchemaItem");
|
|
16
|
+
const Unit_1 = require("./Unit");
|
|
17
|
+
const UnitSystem_1 = require("./UnitSystem");
|
|
16
18
|
/**
|
|
17
19
|
* An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
|
|
18
20
|
* @beta
|
|
19
21
|
*/
|
|
20
22
|
class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
schemaItemType = InvertedUnit.schemaItemType;
|
|
24
|
+
static get schemaItemType() { return ECObjects_1.SchemaItemType.InvertedUnit; }
|
|
25
|
+
_invertsUnit; // required
|
|
26
|
+
_unitSystem; // required
|
|
25
27
|
get invertsUnit() { return this._invertsUnit; }
|
|
26
28
|
get unitSystem() { return this._unitSystem; }
|
|
27
29
|
/**
|
|
@@ -30,6 +32,15 @@ class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
|
30
32
|
static isInvertedUnit(object) {
|
|
31
33
|
return SchemaItem_1.SchemaItem.isSchemaItem(object) && object.schemaItemType === ECObjects_1.SchemaItemType.InvertedUnit;
|
|
32
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Type assertion to check if the SchemaItem is of type InvertedUnit.
|
|
37
|
+
* @param item The SchemaItem to check.
|
|
38
|
+
* @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
|
|
39
|
+
*/
|
|
40
|
+
static assertIsInvertedUnit(item) {
|
|
41
|
+
if (!this.isInvertedUnit(item))
|
|
42
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.InvertedUnit}' (InvertedUnit)`);
|
|
43
|
+
}
|
|
33
44
|
/**
|
|
34
45
|
* Save this InvertedUnit's properties to an object for serializing to JSON.
|
|
35
46
|
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
@@ -60,7 +71,7 @@ class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
|
60
71
|
super.fromJSONSync(invertedUnitProps);
|
|
61
72
|
const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);
|
|
62
73
|
this._invertsUnit = new DelayedPromise_1.DelayedPromiseWithProps(unitSchemaItemKey, async () => {
|
|
63
|
-
const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey);
|
|
74
|
+
const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit_1.Unit);
|
|
64
75
|
if (undefined === invertsUnit)
|
|
65
76
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);
|
|
66
77
|
return invertsUnit;
|
|
@@ -69,7 +80,7 @@ class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
|
69
80
|
if (!unitSystemSchemaItemKey)
|
|
70
81
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
|
|
71
82
|
this._unitSystem = new DelayedPromise_1.DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
|
|
72
|
-
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
|
|
83
|
+
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem_1.UnitSystem);
|
|
73
84
|
if (undefined === unitSystem)
|
|
74
85
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
|
|
75
86
|
return unitSystem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA+D;
|
|
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,4CAA+D;AAG/D,6CAA0C;AAC1C,iCAA8B;AAC9B,6CAA0C;AAE1C;;;GAGG;AACH,MAAa,YAAa,SAAQ,uBAAU;IACjB,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;IAC/D,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IACzE,YAAY,CAAkB,CAAC,WAAW;IAC1C,WAAW,CAAwB,CAAC,WAAW;IAEzD,IAAW,WAAW,KAAiC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAClF,IAAW,UAAU,KAAuC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAEtF;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,MAAW;QACtC,OAAO,uBAAU,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,cAAc,KAAK,0BAAc,CAAC,YAAY,CAAC;IAClG,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,oBAAoB,CAAC,IAAiB;QAClD,IAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC3B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,YAAY,kBAAkB,CAAC,CAAC;IAChI,CAAC;IAED;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uB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;CACF;AAnGD,oCAmGC;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 { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedUnit, LazyLoadedUnitSystem } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\nimport { UnitSystem } from \"./UnitSystem\";\n\n/**\n * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.\n * @beta\n */\nexport class InvertedUnit extends SchemaItem {\n public override readonly schemaItemType = InvertedUnit.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.InvertedUnit; }\n protected _invertsUnit?: LazyLoadedUnit; // required\n protected _unitSystem?: LazyLoadedUnitSystem; // required\n\n public get invertsUnit(): LazyLoadedUnit | undefined { return this._invertsUnit; }\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\n\n /**\n * @alpha\n */\n public static isInvertedUnit(object: any): object is InvertedUnit {\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.InvertedUnit;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type InvertedUnit.\n * @param item The SchemaItem to check.\n * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.\n */\n public static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit {\n if(!this.isInvertedUnit(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);\n }\n\n /**\n * Save this InvertedUnit's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): InvertedUnitProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.invertsUnit = this.invertsUnit!.fullName;\n schemaJson.unitSystem = this.unitSystem!.fullName;\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const unitSystem = await this.unitSystem;\n if (undefined !== unitSystem) {\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\n }\n\n const invertsUnit = await this.invertsUnit;\n if (undefined !== invertsUnit) {\n const invertsUnitName = XmlSerializationUtils.createXmlTypedName(this.schema, invertsUnit.schema, invertsUnit.name);\n itemElement.setAttribute(\"invertsUnit\", invertsUnitName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(invertedUnitProps: InvertedUnitProps) {\n super.fromJSONSync(invertedUnitProps);\n const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);\n this._invertsUnit = new DelayedPromiseWithProps<SchemaItemKey, Unit>(unitSchemaItemKey,\n async () => {\n const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);\n if (undefined === invertsUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);\n return invertsUnit;\n });\n\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);\n if (!unitSystemSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\n async () => {\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\n if (undefined === unitSystem)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n return unitSystem;\n });\n }\n\n public override async fromJSON(invertedUnitProps: InvertedUnitProps) {\n this.fromJSONSync(invertedUnitProps);\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\n this._invertsUnit = invertsUnit;\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\n this._unitSystem = unitSystem;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableInvertedUnit extends InvertedUnit {\n public abstract override setInvertsUnit(invertsUnit: LazyLoadedUnit): void;\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -7,14 +7,14 @@ import { LazyLoadedInvertedUnit, LazyLoadedUnit } from "../Interfaces";
|
|
|
7
7
|
import { Format } from "./Format";
|
|
8
8
|
import { InvertedUnit } from "./InvertedUnit";
|
|
9
9
|
import { OverrideFormat } from "./OverrideFormat";
|
|
10
|
-
import { Schema } from "./Schema";
|
|
11
10
|
import { SchemaItem } from "./SchemaItem";
|
|
12
11
|
import { Unit } from "./Unit";
|
|
13
12
|
/** A Typescript class representation of a KindOfQuantity.
|
|
14
13
|
* @beta
|
|
15
14
|
*/
|
|
16
15
|
export declare class KindOfQuantity extends SchemaItem {
|
|
17
|
-
readonly schemaItemType: SchemaItemType
|
|
16
|
+
readonly schemaItemType: SchemaItemType;
|
|
17
|
+
static get schemaItemType(): SchemaItemType;
|
|
18
18
|
protected _relativeError: number;
|
|
19
19
|
protected _presentationFormats: Array<Format | OverrideFormat>;
|
|
20
20
|
protected _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;
|
|
@@ -25,7 +25,6 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
25
25
|
get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined;
|
|
26
26
|
protected set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined);
|
|
27
27
|
get relativeError(): number;
|
|
28
|
-
constructor(schema: Schema, name: string);
|
|
29
28
|
/**
|
|
30
29
|
*
|
|
31
30
|
* @param format The Format to add to this KindOfQuantity
|
|
@@ -55,6 +54,18 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
55
54
|
* Used for schema editing.
|
|
56
55
|
*/
|
|
57
56
|
protected setRelativeError(relativeError: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
59
|
+
* @param item The SchemaItem to check.
|
|
60
|
+
* @returns True if the item is a KindOfQuantity, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity;
|
|
63
|
+
/**
|
|
64
|
+
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
65
|
+
* @param item The SchemaItem to check.
|
|
66
|
+
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
67
|
+
*/
|
|
68
|
+
static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity;
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantity.d.ts","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAA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AC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,cAAc;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -12,12 +12,20 @@ const DelayedPromise_1 = require("../DelayedPromise");
|
|
|
12
12
|
const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
|
|
13
13
|
const ECObjects_1 = require("../ECObjects");
|
|
14
14
|
const Exception_1 = require("../Exception");
|
|
15
|
+
const Format_1 = require("./Format");
|
|
16
|
+
const InvertedUnit_1 = require("./InvertedUnit");
|
|
15
17
|
const OverrideFormat_1 = require("./OverrideFormat");
|
|
16
18
|
const SchemaItem_1 = require("./SchemaItem");
|
|
19
|
+
const Unit_1 = require("./Unit");
|
|
17
20
|
/** A Typescript class representation of a KindOfQuantity.
|
|
18
21
|
* @beta
|
|
19
22
|
*/
|
|
20
23
|
class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
24
|
+
schemaItemType = KindOfQuantity.schemaItemType;
|
|
25
|
+
static get schemaItemType() { return ECObjects_1.SchemaItemType.KindOfQuantity; }
|
|
26
|
+
_relativeError = 1.0;
|
|
27
|
+
_presentationFormats = new Array();
|
|
28
|
+
_persistenceUnit;
|
|
21
29
|
/** The first presentation format in the list of Formats. */
|
|
22
30
|
get defaultPresentationFormat() { return this.presentationFormats[0]; }
|
|
23
31
|
/** A list of presentation formats. */
|
|
@@ -25,12 +33,6 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
25
33
|
get persistenceUnit() { return this._persistenceUnit; }
|
|
26
34
|
set persistenceUnit(value) { this._persistenceUnit = value; }
|
|
27
35
|
get relativeError() { return this._relativeError; }
|
|
28
|
-
constructor(schema, name) {
|
|
29
|
-
super(schema, name);
|
|
30
|
-
this._relativeError = 1.0;
|
|
31
|
-
this._presentationFormats = new Array();
|
|
32
|
-
this.schemaItemType = ECObjects_1.SchemaItemType.KindOfQuantity; // Needed to allow both run-time and compile-time check.
|
|
33
|
-
}
|
|
34
36
|
/**
|
|
35
37
|
*
|
|
36
38
|
* @param format The Format to add to this KindOfQuantity
|
|
@@ -57,7 +59,7 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
57
59
|
const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(";");
|
|
58
60
|
for (const formatString of presUnitsArr) {
|
|
59
61
|
const presFormatOverride = OverrideFormat_1.OverrideFormat.parseFormatString(formatString);
|
|
60
|
-
const format = await this.schema.lookupItem(presFormatOverride.name);
|
|
62
|
+
const format = await this.schema.lookupItem(presFormatOverride.name, Format_1.Format);
|
|
61
63
|
if (undefined === format || format.schemaItemType !== ECObjects_1.SchemaItemType.Format)
|
|
62
64
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
63
65
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
@@ -70,10 +72,10 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
70
72
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, ``);
|
|
71
73
|
unitAndLabels = [];
|
|
72
74
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
73
|
-
const
|
|
74
|
-
if (undefined ===
|
|
75
|
+
const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);
|
|
76
|
+
if (undefined === unitOrInverted || (!Unit_1.Unit.isUnit(unitOrInverted) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(unitOrInverted)))
|
|
75
77
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
76
|
-
unitAndLabels.push([
|
|
78
|
+
unitAndLabels.push([unitOrInverted, unitOverride[1]]);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -84,7 +86,7 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
84
86
|
const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(";");
|
|
85
87
|
for (const formatString of presUnitsArr) {
|
|
86
88
|
const presFormatOverride = OverrideFormat_1.OverrideFormat.parseFormatString(formatString);
|
|
87
|
-
const format = this.schema.lookupItemSync(presFormatOverride.name);
|
|
89
|
+
const format = this.schema.lookupItemSync(presFormatOverride.name, Format_1.Format);
|
|
88
90
|
if (undefined === format || format.schemaItemType !== ECObjects_1.SchemaItemType.Format)
|
|
89
91
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
90
92
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
@@ -97,10 +99,10 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
97
99
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, ``);
|
|
98
100
|
unitAndLabels = [];
|
|
99
101
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
100
|
-
const
|
|
101
|
-
if (undefined ===
|
|
102
|
+
const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);
|
|
103
|
+
if (undefined === unitOrInverted || (!Unit_1.Unit.isUnit(unitOrInverted) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(unitOrInverted)))
|
|
102
104
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
103
|
-
unitAndLabels.push([
|
|
105
|
+
unitAndLabels.push([unitOrInverted, unitOverride[1]]);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -145,9 +147,12 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
145
147
|
const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);
|
|
146
148
|
if (undefined === persistenceUnit)
|
|
147
149
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
148
|
-
if (
|
|
150
|
+
if (!Unit_1.Unit.isUnit(persistenceUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
149
151
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
150
|
-
|
|
152
|
+
if (Unit_1.Unit.isUnit(persistenceUnit))
|
|
153
|
+
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
154
|
+
else
|
|
155
|
+
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
151
156
|
if (undefined !== kindOfQuantityProps.presentationUnits)
|
|
152
157
|
this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);
|
|
153
158
|
}
|
|
@@ -157,9 +162,12 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
157
162
|
const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);
|
|
158
163
|
if (undefined === persistenceUnit)
|
|
159
164
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
160
|
-
if (
|
|
165
|
+
if (!Unit_1.Unit.isUnit(persistenceUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
161
166
|
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
162
|
-
|
|
167
|
+
if (Unit_1.Unit.isUnit(persistenceUnit))
|
|
168
|
+
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
169
|
+
else
|
|
170
|
+
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
163
171
|
if (undefined !== kindOfQuantityProps.presentationUnits)
|
|
164
172
|
await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);
|
|
165
173
|
}
|
|
@@ -170,6 +178,23 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
170
178
|
setRelativeError(relativeError) {
|
|
171
179
|
this._relativeError = relativeError;
|
|
172
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
183
|
+
* @param item The SchemaItem to check.
|
|
184
|
+
* @returns True if the item is a KindOfQuantity, false otherwise.
|
|
185
|
+
*/
|
|
186
|
+
static isKindOfQuantity(item) {
|
|
187
|
+
return item?.schemaItemType === ECObjects_1.SchemaItemType.KindOfQuantity;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
191
|
+
* @param item The SchemaItem to check.
|
|
192
|
+
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
193
|
+
*/
|
|
194
|
+
static assertIsKindOfQuantity(item) {
|
|
195
|
+
if (!this.isKindOfQuantity(item))
|
|
196
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);
|
|
197
|
+
}
|
|
173
198
|
}
|
|
174
199
|
exports.KindOfQuantity = KindOfQuantity;
|
|
175
200
|
/**
|