@itwin/ecschema-metadata 5.0.0-dev.9 → 5.0.0-dev.92
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.d.ts +8 -0
- package/lib/cjs/Constants.d.ts.map +1 -1
- package/lib/cjs/Constants.js +30 -21
- 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 +14 -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 +117 -13
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +148 -70
- 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 +12 -2
- 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.d.ts +8 -0
- package/lib/esm/Constants.d.ts.map +1 -1
- package/lib/esm/Constants.js +29 -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 +14 -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 +117 -13
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +148 -70
- 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 +13 -3
- 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
|
@@ -9,14 +9,19 @@ import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils"
|
|
|
9
9
|
import { SchemaItemType } from "../ECObjects";
|
|
10
10
|
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
11
11
|
import { BaseFormat, FormatTraits, formatTraitsToArray, FormatType, ShowSignOption, } from "@itwin/core-quantity";
|
|
12
|
+
import { InvertedUnit } from "./InvertedUnit";
|
|
12
13
|
import { SchemaItem } from "./SchemaItem";
|
|
14
|
+
import { Unit } from "./Unit";
|
|
13
15
|
/**
|
|
14
16
|
* @beta
|
|
15
17
|
*/
|
|
16
18
|
export class Format extends SchemaItem {
|
|
19
|
+
schemaItemType = Format.schemaItemType;
|
|
20
|
+
static get schemaItemType() { return SchemaItemType.Format; }
|
|
21
|
+
_base;
|
|
22
|
+
_units;
|
|
17
23
|
constructor(schema, name) {
|
|
18
24
|
super(schema, name);
|
|
19
|
-
this.schemaItemType = SchemaItemType.Format;
|
|
20
25
|
this._base = new BaseFormat(name);
|
|
21
26
|
}
|
|
22
27
|
get roundFactor() { return this._base.roundFactor; }
|
|
@@ -80,7 +85,7 @@ export class Format extends SchemaItem {
|
|
|
80
85
|
// Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation
|
|
81
86
|
for (const unit of formatProps.composite.units) {
|
|
82
87
|
const newUnit = this.schema.lookupItemSync(unit.name);
|
|
83
|
-
if (undefined === newUnit)
|
|
88
|
+
if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))
|
|
84
89
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
|
|
85
90
|
this.addUnit(newUnit, unit.label);
|
|
86
91
|
}
|
|
@@ -93,7 +98,7 @@ export class Format extends SchemaItem {
|
|
|
93
98
|
// Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation
|
|
94
99
|
for (const unit of formatProps.composite.units) {
|
|
95
100
|
const newUnit = await this.schema.lookupItem(unit.name);
|
|
96
|
-
if (undefined === newUnit)
|
|
101
|
+
if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))
|
|
97
102
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
|
|
98
103
|
this.addUnit(newUnit, unit.label);
|
|
99
104
|
}
|
|
@@ -228,6 +233,66 @@ export class Format extends SchemaItem {
|
|
|
228
233
|
setStationSeparator(separator) {
|
|
229
234
|
this._base.stationSeparator = separator;
|
|
230
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* @alpha Used in schema editing.
|
|
238
|
+
*/
|
|
239
|
+
setStationOffsetSize(stationOffsetSize) {
|
|
240
|
+
this._base.stationOffsetSize = stationOffsetSize;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @alpha Used in schema editing.
|
|
244
|
+
*/
|
|
245
|
+
setScientificType(scientificType) {
|
|
246
|
+
this._base.scientificType = scientificType;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* @alpha Used in schema editing.
|
|
250
|
+
*/
|
|
251
|
+
setMinWidth(minWidth) {
|
|
252
|
+
this._base.minWidth = minWidth;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* @alpha Used in schema editing.
|
|
256
|
+
*/
|
|
257
|
+
setSpacer(spacer) {
|
|
258
|
+
this._base.spacer = spacer;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @alpha Used in schema editing.
|
|
262
|
+
*/
|
|
263
|
+
setIncludeZero(includeZero) {
|
|
264
|
+
this._base.includeZero = includeZero;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* @alpha Used in schema editing.
|
|
268
|
+
*/
|
|
269
|
+
setFormatTraits(formatTraits) {
|
|
270
|
+
this._base.formatTraits = formatTraits;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* @alpha Used in schema editing.
|
|
274
|
+
*/
|
|
275
|
+
setUnits(units) {
|
|
276
|
+
this._units = units;
|
|
277
|
+
}
|
|
278
|
+
/** Type guard to check if the SchemaItem is of type Format.
|
|
279
|
+
* @param item The SchemaItem to check.
|
|
280
|
+
* @returns True if the item is a Format, false otherwise.
|
|
281
|
+
*/
|
|
282
|
+
static isFormat(item) {
|
|
283
|
+
if (item && item.schemaItemType === SchemaItemType.Format)
|
|
284
|
+
return true;
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Type assertion to check if the SchemaItem is of type Format.
|
|
289
|
+
* @param item The SchemaItem to check.
|
|
290
|
+
* @returns The item cast to Format if it is a Format, undefined otherwise.
|
|
291
|
+
*/
|
|
292
|
+
static assertIsFormat(item) {
|
|
293
|
+
if (!this.isFormat(item))
|
|
294
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Format}' (Format)`);
|
|
295
|
+
}
|
|
231
296
|
}
|
|
232
297
|
/**
|
|
233
298
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Metadata/Format.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,UAAU,EAAoB,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAC3D,cAAc,GAC/B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,UAAU;IAKpC,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC;QAE5C,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,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,QA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iBAAiB,CAAC,UAA0B;QACpD,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,UAAU,CAAC;IACzC,CAAC;IAED;;OAEG;IACO,mBAAmB,CAAC,SAAiB;QAC7C,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAC1C,CAAC;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;AAED;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,MAAM;CAWjD","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":[],"mapp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ACxE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAiB;QACxC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,MAAM;YACvD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,IAAiB;QAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACtB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,MAAM,YAAY,CAAC,CAAC;IACpH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,MAAM;CAWjD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { SchemaItemFormatProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport {\n BaseFormat, DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision,\n ScientificType, ShowSignOption,\n} from \"@itwin/core-quantity\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/**\n * @beta\n */\nexport class Format extends SchemaItem {\n public override readonly schemaItemType = Format.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Format; }\n protected _base: BaseFormat;\n protected _units?: Array<[Unit | InvertedUnit, string | undefined]>;\n\n constructor(schema: Schema, name: string) {\n super(schema, name);\n this._base = new BaseFormat(name);\n }\n\n public get roundFactor(): number { return this._base.roundFactor; }\n public get type(): FormatType { return this._base.type; }\n public get precision(): DecimalPrecision | FractionalPrecision { return this._base.precision; }\n public get minWidth(): number | undefined { return this._base.minWidth; }\n public get scientificType(): ScientificType | undefined { return this._base.scientificType; }\n public get showSignOption(): ShowSignOption { return this._base.showSignOption; }\n public get decimalSeparator(): string { return this._base.decimalSeparator; }\n public get thousandSeparator(): string { return this._base.thousandSeparator; }\n public get uomSeparator(): string { return this._base.uomSeparator; }\n public get stationSeparator(): string { return this._base.stationSeparator; }\n public get stationOffsetSize(): number | undefined { return this._base.stationOffsetSize; }\n public get formatTraits(): FormatTraits { return this._base.formatTraits; }\n public get spacer(): string | undefined { return this._base.spacer; }\n public get includeZero(): boolean | undefined { return this._base.includeZero; }\n public get units(): Array<[Unit | InvertedUnit, string | undefined]> | undefined { return this._units; }\n\n private parseFormatTraits(formatTraitsFromJson: string | string[]) {\n return this._base.parseFormatTraits(formatTraitsFromJson);\n }\n\n public hasFormatTrait(formatTrait: FormatTraits) {\n return this._base.hasFormatTraitSet(formatTrait);\n }\n\n /**\n * Adds a Unit, or InvertedUnit, with an optional label override.\n * @param unit The Unit, or InvertedUnit, to add to this Format.\n * @param label A label that overrides the label defined within the Unit when a value is formatted.\n */\n protected addUnit(unit: Unit | InvertedUnit, label?: string) {\n if (undefined === this._units)\n this._units = [];\n else { // Validate that a duplicate is not added.\n for (const existingUnit of this._units) {\n if (unit.fullName.toLowerCase() === existingUnit[0].fullName.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has duplicate units, '${unit.fullName}'.`); // TODO: Validation - this should be a validation error not a hard failure.\n }\n }\n\n this._units.push([unit, label]);\n }\n\n protected setPrecision(precision: number) { this._base.precision = precision; }\n\n private typecheck(formatProps: SchemaItemFormatProps) {\n this._base.loadFormatProperties(formatProps);\n\n if (undefined !== formatProps.composite) { // TODO: This is duplicated below when the units need to be processed...\n if (undefined !== formatProps.composite.includeZero)\n this._base.includeZero = formatProps.composite.includeZero;\n\n if (undefined !== formatProps.composite.spacer) {\n if (formatProps.composite.spacer.length > 1)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has a composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._base.spacer = formatProps.composite.spacer;\n }\n\n // Composite requires 1-4 units\n if (formatProps.composite.units.length <= 0 || formatProps.composite.units.length > 4)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Format ${this.fullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);\n }\n }\n\n public override fromJSONSync(formatProps: SchemaItemFormatProps) {\n super.fromJSONSync(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = this.schema.lookupItemSync(unit.name);\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n public override async fromJSON(formatProps: SchemaItemFormatProps) {\n await super.fromJSON(formatProps);\n this.typecheck(formatProps);\n if (undefined === formatProps.composite)\n return;\n\n // Units are separated from the rest of the deserialization because of the need to have separate sync and async implementation\n for (const unit of formatProps.composite.units) {\n const newUnit = await this.schema.lookupItem(unit.name);\n if (undefined === newUnit || (!Unit.isUnit(newUnit) && !InvertedUnit.isInvertedUnit(newUnit)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n this.addUnit(newUnit, unit.label);\n }\n }\n\n /**\n * Save this Format's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): SchemaItemFormatProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.type = this.type;\n schemaJson.precision = this.precision;\n\n // this._spacer = \" \";\n // this._includeZero = true;\n\n // Serialize the minimal amount of information needed so anything that is the same as the default, do not serialize.\n if (0.0 !== this.roundFactor)\n schemaJson.roundFactor = this.roundFactor;\n if (ShowSignOption.OnlyNegative !== this.showSignOption)\n schemaJson.showSignOption = this.showSignOption;\n if (FormatTraits.Uninitialized !== this.formatTraits)\n schemaJson.formatTraits = formatTraitsToArray(this.formatTraits);\n if (\".\" !== this.decimalSeparator)\n schemaJson.decimalSeparator = this.decimalSeparator;\n if (\",\" !== this.thousandSeparator)\n schemaJson.thousandSeparator = this.thousandSeparator;\n if (\" \" !== this.uomSeparator)\n schemaJson.uomSeparator = this.uomSeparator;\n\n if (undefined !== this.minWidth)\n schemaJson.minWidth = this.minWidth;\n\n if (FormatType.Scientific === this.type && undefined !== this.scientificType)\n schemaJson.scientificType = this.scientificType;\n\n if (FormatType.Station === this.type) {\n if (undefined !== this.stationOffsetSize)\n schemaJson.stationOffsetSize = this.stationOffsetSize;\n if (\" \" !== this.stationSeparator)\n schemaJson.stationSeparator = this.stationSeparator;\n }\n\n if (undefined === this.units)\n return schemaJson;\n\n schemaJson.composite = {};\n\n if (\" \" !== this.spacer)\n schemaJson.composite.spacer = this.spacer;\n\n if (true !== this.includeZero)\n schemaJson.composite.includeZero = this.includeZero;\n\n schemaJson.composite.units = [];\n for (const unit of this.units) {\n schemaJson.composite.units.push({\n name: unit[0].fullName,\n label: unit[1],\n });\n }\n\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"type\", this.type.toLowerCase());\n itemElement.setAttribute(\"precision\", this.precision.toString());\n itemElement.setAttribute(\"roundFactor\", this.roundFactor.toString());\n itemElement.setAttribute(\"showSignOption\", this.showSignOption);\n itemElement.setAttribute(\"decimalSeparator\", this.decimalSeparator);\n itemElement.setAttribute(\"thousandSeparator\", this.thousandSeparator);\n itemElement.setAttribute(\"uomSeparator\", this.uomSeparator);\n itemElement.setAttribute(\"stationSeparator\", this.stationSeparator);\n\n if (undefined !== this.minWidth)\n itemElement.setAttribute(\"minWidth\", this.minWidth.toString());\n if (undefined !== this.scientificType)\n itemElement.setAttribute(\"scientificType\", this.scientificType);\n if (undefined !== this.stationOffsetSize)\n itemElement.setAttribute(\"stationOffsetSize\", this.stationOffsetSize.toString());\n\n const formatTraits = formatTraitsToArray(this.formatTraits);\n if (formatTraits.length > 0)\n itemElement.setAttribute(\"formatTraits\", formatTraits.join(\"|\"));\n\n if (undefined !== this.units) {\n const compositeElement = schemaXml.createElement(\"Composite\");\n if (undefined !== this.spacer)\n compositeElement.setAttribute(\"spacer\", this.spacer);\n if (undefined !== this.includeZero)\n compositeElement.setAttribute(\"includeZero\", this.includeZero.toString());\n\n this.units.forEach(([unit, label]) => {\n const unitElement = schemaXml.createElement(\"Unit\");\n if (undefined !== label)\n unitElement.setAttribute(\"label\", label);\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, unit.schema, unit.name);\n unitElement.textContent = unitName;\n compositeElement.appendChild(unitElement);\n });\n\n itemElement.appendChild(compositeElement);\n }\n\n return itemElement;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatType(formatType: FormatType) {\n this._base.type = formatType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setRoundFactor(roundFactor: number) {\n this._base.roundFactor = roundFactor;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setShowSignOption(signOption: ShowSignOption) {\n this._base.showSignOption = signOption;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setDecimalSeparator(separator: string) {\n this._base.decimalSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setThousandSeparator(separator: string) {\n this._base.thousandSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUomSeparator(separator: string) {\n this._base.uomSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationSeparator(separator: string) {\n this._base.stationSeparator = separator;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setStationOffsetSize(stationOffsetSize: number) {\n this._base.stationOffsetSize = stationOffsetSize;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setScientificType(scientificType: ScientificType) {\n this._base.scientificType = scientificType;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setMinWidth(minWidth: number) {\n this._base.minWidth = minWidth;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setSpacer(spacer: string) {\n this._base.spacer = spacer;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setIncludeZero(includeZero: boolean) {\n this._base.includeZero = includeZero;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setFormatTraits(formatTraits: FormatTraits) {\n this._base.formatTraits = formatTraits;\n }\n\n /**\n * @alpha Used in schema editing.\n */\n protected setUnits(units: Array<[Unit | InvertedUnit, string | undefined]>) {\n this._units = units;\n }\n\n /** Type guard to check if the SchemaItem is of type Format.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Format, false otherwise.\n */\n public static isFormat(item?: SchemaItem): item is Format {\n if (item && item.schemaItemType === SchemaItemType.Format)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Format.\n * @param item The SchemaItem to check.\n * @returns The item cast to Format if it is a Format, undefined otherwise.\n */\n public static assertIsFormat(item?: SchemaItem): asserts item is Format {\n if (!this.isFormat(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Format}' (Format)`);\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableFormat extends Format {\n public abstract override addUnit(unit: Unit | InvertedUnit, label?: string): void;\n public abstract override setPrecision(precision: number): void;\n public abstract override setFormatType(formatType: FormatType): void;\n public abstract override setRoundFactor(roundFactor: number): void;\n public abstract override setShowSignOption(signOption: ShowSignOption): void;\n public abstract override setDecimalSeparator(separator: string): void;\n public abstract override setThousandSeparator(separator: string): void;\n public abstract override setUomSeparator(separator: string): void;\n public abstract override setStationSeparator(separator: string): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -4,23 +4,28 @@
|
|
|
4
4
|
import { InvertedUnitProps } from "../Deserialization/JsonProps";
|
|
5
5
|
import { SchemaItemType } from "../ECObjects";
|
|
6
6
|
import { LazyLoadedUnit, LazyLoadedUnitSystem } from "../Interfaces";
|
|
7
|
-
import { Schema } from "./Schema";
|
|
8
7
|
import { SchemaItem } from "./SchemaItem";
|
|
9
8
|
/**
|
|
10
9
|
* An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
|
|
11
10
|
* @beta
|
|
12
11
|
*/
|
|
13
12
|
export declare class InvertedUnit extends SchemaItem {
|
|
14
|
-
readonly schemaItemType: SchemaItemType
|
|
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;;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,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,SAAyB,cAAc,iBAA+B;IACtE,WAA2B,cAAc,mBAA0C;IACnF,SAAS,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC;IACxC,SAAS,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IAE7C,IAAW,WAAW,IAAI,cAAc,GAAG,SAAS,CAA8B;IAClF,IAAW,UAAU,IAAI,oBAAoB,GAAG,SAAS,CAA6B;IAEtF;;OAEG;WACW,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,YAAY;IAIjE;;;;OAIG;WACW,oBAAoB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY;IAKnF;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,iBAAiB;IAO7G,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBlD,YAAY,CAAC,iBAAiB,EAAE,iBAAiB;IAuB3C,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB;IAInE;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc;IAIpD;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,oBAAoB;CAGzD;AAED;;;GAGG;AACH,8BAAsB,mBAAoB,SAAQ,YAAY;aACnC,cAAc,CAAC,WAAW,EAAE,cAAc,GAAG,IAAI;aACjD,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;aACrD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -10,15 +10,17 @@ import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils"
|
|
|
10
10
|
import { SchemaItemType } from "../ECObjects";
|
|
11
11
|
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
12
12
|
import { SchemaItem } from "./SchemaItem";
|
|
13
|
+
import { Unit } from "./Unit";
|
|
14
|
+
import { UnitSystem } from "./UnitSystem";
|
|
13
15
|
/**
|
|
14
16
|
* An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
|
|
15
17
|
* @beta
|
|
16
18
|
*/
|
|
17
19
|
export class InvertedUnit extends SchemaItem {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
schemaItemType = InvertedUnit.schemaItemType;
|
|
21
|
+
static get schemaItemType() { return SchemaItemType.InvertedUnit; }
|
|
22
|
+
_invertsUnit; // required
|
|
23
|
+
_unitSystem; // required
|
|
22
24
|
get invertsUnit() { return this._invertsUnit; }
|
|
23
25
|
get unitSystem() { return this._unitSystem; }
|
|
24
26
|
/**
|
|
@@ -27,6 +29,15 @@ export class InvertedUnit extends SchemaItem {
|
|
|
27
29
|
static isInvertedUnit(object) {
|
|
28
30
|
return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.InvertedUnit;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Type assertion to check if the SchemaItem is of type InvertedUnit.
|
|
34
|
+
* @param item The SchemaItem to check.
|
|
35
|
+
* @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
|
|
36
|
+
*/
|
|
37
|
+
static assertIsInvertedUnit(item) {
|
|
38
|
+
if (!this.isInvertedUnit(item))
|
|
39
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);
|
|
40
|
+
}
|
|
30
41
|
/**
|
|
31
42
|
* Save this InvertedUnit's properties to an object for serializing to JSON.
|
|
32
43
|
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
@@ -57,7 +68,7 @@ export class InvertedUnit extends SchemaItem {
|
|
|
57
68
|
super.fromJSONSync(invertedUnitProps);
|
|
58
69
|
const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);
|
|
59
70
|
this._invertsUnit = new DelayedPromiseWithProps(unitSchemaItemKey, async () => {
|
|
60
|
-
const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey);
|
|
71
|
+
const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);
|
|
61
72
|
if (undefined === invertsUnit)
|
|
62
73
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);
|
|
63
74
|
return invertsUnit;
|
|
@@ -66,7 +77,7 @@ export class InvertedUnit extends SchemaItem {
|
|
|
66
77
|
if (!unitSystemSchemaItemKey)
|
|
67
78
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
|
|
68
79
|
this._unitSystem = new DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
|
|
69
|
-
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
|
|
80
|
+
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);
|
|
70
81
|
if (undefined === unitSystem)
|
|
71
82
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
|
|
72
83
|
return unitSystem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,UAAU;IACjB,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;IAC/D,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAA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,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAuB,CAA4B,uBAAuB,EAC/F,KAAK,IAAI,EAAE;YACT,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;YACrF,IAAI,SAAS,KAAK,UAAU;gBAC1B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,aAAa,EAAE,mCAAmC,iBAAiB,CAAC,UAAU,GAAG,CAAC,CAAC;YAC9H,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,iBAAoC;QACjE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAA2B;QAClD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,UAAgC;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,YAAY;CAI7D","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { InvertedUnitProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedUnit, LazyLoadedUnitSystem } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\nimport { UnitSystem } from \"./UnitSystem\";\n\n/**\n * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.\n * @beta\n */\nexport class InvertedUnit extends SchemaItem {\n public override readonly schemaItemType = InvertedUnit.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.InvertedUnit; }\n protected _invertsUnit?: LazyLoadedUnit; // required\n protected _unitSystem?: LazyLoadedUnitSystem; // required\n\n public get invertsUnit(): LazyLoadedUnit | undefined { return this._invertsUnit; }\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\n\n /**\n * @alpha\n */\n public static isInvertedUnit(object: any): object is InvertedUnit {\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.InvertedUnit;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type InvertedUnit.\n * @param item The SchemaItem to check.\n * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.\n */\n public static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit {\n if(!this.isInvertedUnit(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);\n }\n\n /**\n * Save this InvertedUnit's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): InvertedUnitProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.invertsUnit = this.invertsUnit!.fullName;\n schemaJson.unitSystem = this.unitSystem!.fullName;\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const unitSystem = await this.unitSystem;\n if (undefined !== unitSystem) {\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\n }\n\n const invertsUnit = await this.invertsUnit;\n if (undefined !== invertsUnit) {\n const invertsUnitName = XmlSerializationUtils.createXmlTypedName(this.schema, invertsUnit.schema, invertsUnit.name);\n itemElement.setAttribute(\"invertsUnit\", invertsUnitName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(invertedUnitProps: InvertedUnitProps) {\n super.fromJSONSync(invertedUnitProps);\n const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);\n this._invertsUnit = new DelayedPromiseWithProps<SchemaItemKey, Unit>(unitSchemaItemKey,\n async () => {\n const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);\n if (undefined === invertsUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);\n return invertsUnit;\n });\n\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);\n if (!unitSystemSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\n async () => {\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\n if (undefined === unitSystem)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n return unitSystem;\n });\n }\n\n public override async fromJSON(invertedUnitProps: InvertedUnitProps) {\n this.fromJSONSync(invertedUnitProps);\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\n this._invertsUnit = invertsUnit;\n }\n\n /**\n * @alpha\n * Used for schema editing\n */\n protected setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\n this._unitSystem = unitSystem;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableInvertedUnit extends InvertedUnit {\n public abstract override setInvertsUnit(invertsUnit: LazyLoadedUnit): void;\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -7,14 +7,14 @@ import { LazyLoadedInvertedUnit, LazyLoadedUnit } from "../Interfaces";
|
|
|
7
7
|
import { Format } from "./Format";
|
|
8
8
|
import { InvertedUnit } from "./InvertedUnit";
|
|
9
9
|
import { OverrideFormat } from "./OverrideFormat";
|
|
10
|
-
import { Schema } from "./Schema";
|
|
11
10
|
import { SchemaItem } from "./SchemaItem";
|
|
12
11
|
import { Unit } from "./Unit";
|
|
13
12
|
/** A Typescript class representation of a KindOfQuantity.
|
|
14
13
|
* @beta
|
|
15
14
|
*/
|
|
16
15
|
export declare class KindOfQuantity extends SchemaItem {
|
|
17
|
-
readonly schemaItemType: SchemaItemType
|
|
16
|
+
readonly schemaItemType: SchemaItemType;
|
|
17
|
+
static get schemaItemType(): SchemaItemType;
|
|
18
18
|
protected _relativeError: number;
|
|
19
19
|
protected _presentationFormats: Array<Format | OverrideFormat>;
|
|
20
20
|
protected _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;
|
|
@@ -25,7 +25,6 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
25
25
|
get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined;
|
|
26
26
|
protected set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined);
|
|
27
27
|
get relativeError(): number;
|
|
28
|
-
constructor(schema: Schema, name: string);
|
|
29
28
|
/**
|
|
30
29
|
*
|
|
31
30
|
* @param format The Format to add to this KindOfQuantity
|
|
@@ -55,6 +54,18 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
55
54
|
* Used for schema editing.
|
|
56
55
|
*/
|
|
57
56
|
protected setRelativeError(relativeError: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
59
|
+
* @param item The SchemaItem to check.
|
|
60
|
+
* @returns True if the item is a KindOfQuantity, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity;
|
|
63
|
+
/**
|
|
64
|
+
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
65
|
+
* @param item The SchemaItem to check.
|
|
66
|
+
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
67
|
+
*/
|
|
68
|
+
static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity;
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantity.d.ts","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"KindOfQuantity.d.ts","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,g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mB;IAS/G,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAsBlD,YAAY,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,IAAI;IAoBtD,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBvF;;;OAGG;IACH,SAAS,CAAC,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAIvD;;;;OAIG;WACW,gBAAgB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,cAAc;IAIzE;;;;OAIG;WACW,sBAAsB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,cAAc;CAIxF;AACD;;;GAGG;AACH,8BAAsB,qBAAsB,SAAQ,cAAc;aACvC,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;aAChF,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,GAAG,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,cAAc;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -9,12 +9,20 @@ import { DelayedPromiseWithProps } from "../DelayedPromise";
|
|
|
9
9
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
10
10
|
import { SchemaItemType } from "../ECObjects";
|
|
11
11
|
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
12
|
+
import { Format } from "./Format";
|
|
13
|
+
import { InvertedUnit } from "./InvertedUnit";
|
|
12
14
|
import { OverrideFormat } from "./OverrideFormat";
|
|
13
15
|
import { SchemaItem } from "./SchemaItem";
|
|
16
|
+
import { Unit } from "./Unit";
|
|
14
17
|
/** A Typescript class representation of a KindOfQuantity.
|
|
15
18
|
* @beta
|
|
16
19
|
*/
|
|
17
20
|
export class KindOfQuantity extends SchemaItem {
|
|
21
|
+
schemaItemType = KindOfQuantity.schemaItemType;
|
|
22
|
+
static get schemaItemType() { return SchemaItemType.KindOfQuantity; }
|
|
23
|
+
_relativeError = 1.0;
|
|
24
|
+
_presentationFormats = new Array();
|
|
25
|
+
_persistenceUnit;
|
|
18
26
|
/** The first presentation format in the list of Formats. */
|
|
19
27
|
get defaultPresentationFormat() { return this.presentationFormats[0]; }
|
|
20
28
|
/** A list of presentation formats. */
|
|
@@ -22,12 +30,6 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
22
30
|
get persistenceUnit() { return this._persistenceUnit; }
|
|
23
31
|
set persistenceUnit(value) { this._persistenceUnit = value; }
|
|
24
32
|
get relativeError() { return this._relativeError; }
|
|
25
|
-
constructor(schema, name) {
|
|
26
|
-
super(schema, name);
|
|
27
|
-
this._relativeError = 1.0;
|
|
28
|
-
this._presentationFormats = new Array();
|
|
29
|
-
this.schemaItemType = SchemaItemType.KindOfQuantity; // Needed to allow both run-time and compile-time check.
|
|
30
|
-
}
|
|
31
33
|
/**
|
|
32
34
|
*
|
|
33
35
|
* @param format The Format to add to this KindOfQuantity
|
|
@@ -54,7 +56,7 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
54
56
|
const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(";");
|
|
55
57
|
for (const formatString of presUnitsArr) {
|
|
56
58
|
const presFormatOverride = OverrideFormat.parseFormatString(formatString);
|
|
57
|
-
const format = await this.schema.lookupItem(presFormatOverride.name);
|
|
59
|
+
const format = await this.schema.lookupItem(presFormatOverride.name, Format);
|
|
58
60
|
if (undefined === format || format.schemaItemType !== SchemaItemType.Format)
|
|
59
61
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
60
62
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
@@ -67,10 +69,10 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
67
69
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
|
|
68
70
|
unitAndLabels = [];
|
|
69
71
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
70
|
-
const
|
|
71
|
-
if (undefined ===
|
|
72
|
+
const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);
|
|
73
|
+
if (undefined === unitOrInverted || (!Unit.isUnit(unitOrInverted) && !InvertedUnit.isInvertedUnit(unitOrInverted)))
|
|
72
74
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
73
|
-
unitAndLabels.push([
|
|
75
|
+
unitAndLabels.push([unitOrInverted, unitOverride[1]]);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -81,7 +83,7 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
81
83
|
const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(";");
|
|
82
84
|
for (const formatString of presUnitsArr) {
|
|
83
85
|
const presFormatOverride = OverrideFormat.parseFormatString(formatString);
|
|
84
|
-
const format = this.schema.lookupItemSync(presFormatOverride.name);
|
|
86
|
+
const format = this.schema.lookupItemSync(presFormatOverride.name, Format);
|
|
85
87
|
if (undefined === format || format.schemaItemType !== SchemaItemType.Format)
|
|
86
88
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
87
89
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
@@ -94,10 +96,10 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
94
96
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
|
|
95
97
|
unitAndLabels = [];
|
|
96
98
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
97
|
-
const
|
|
98
|
-
if (undefined ===
|
|
99
|
+
const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);
|
|
100
|
+
if (undefined === unitOrInverted || (!Unit.isUnit(unitOrInverted) && !InvertedUnit.isInvertedUnit(unitOrInverted)))
|
|
99
101
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
100
|
-
unitAndLabels.push([
|
|
102
|
+
unitAndLabels.push([unitOrInverted, unitOverride[1]]);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -142,9 +144,12 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
142
144
|
const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);
|
|
143
145
|
if (undefined === persistenceUnit)
|
|
144
146
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
145
|
-
if (persistenceUnit
|
|
147
|
+
if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
146
148
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
147
|
-
|
|
149
|
+
if (Unit.isUnit(persistenceUnit))
|
|
150
|
+
this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
151
|
+
else
|
|
152
|
+
this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
148
153
|
if (undefined !== kindOfQuantityProps.presentationUnits)
|
|
149
154
|
this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);
|
|
150
155
|
}
|
|
@@ -154,9 +159,12 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
154
159
|
const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);
|
|
155
160
|
if (undefined === persistenceUnit)
|
|
156
161
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
157
|
-
if (persistenceUnit
|
|
162
|
+
if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
158
163
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
159
|
-
|
|
164
|
+
if (Unit.isUnit(persistenceUnit))
|
|
165
|
+
this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
166
|
+
else
|
|
167
|
+
this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
160
168
|
if (undefined !== kindOfQuantityProps.presentationUnits)
|
|
161
169
|
await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);
|
|
162
170
|
}
|
|
@@ -167,6 +175,23 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
167
175
|
setRelativeError(relativeError) {
|
|
168
176
|
this._relativeError = relativeError;
|
|
169
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
180
|
+
* @param item The SchemaItem to check.
|
|
181
|
+
* @returns True if the item is a KindOfQuantity, false otherwise.
|
|
182
|
+
*/
|
|
183
|
+
static isKindOfQuantity(item) {
|
|
184
|
+
return item?.schemaItemType === SchemaItemType.KindOfQuantity;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
188
|
+
* @param item The SchemaItem to check.
|
|
189
|
+
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
190
|
+
*/
|
|
191
|
+
static assertIsKindOfQuantity(item) {
|
|
192
|
+
if (!this.isKindOfQuantity(item))
|
|
193
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);
|
|
194
|
+
}
|
|
170
195
|
}
|
|
171
196
|
/**
|
|
172
197
|
* @internal
|