@itwin/ecschema-metadata 5.0.0-dev.99 → 5.1.0-dev.1
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 +6 -1
- package/lib/cjs/Context.d.ts +3 -3
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +6 -6
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.d.ts +9 -8
- package/lib/cjs/DelayedPromise.d.ts.map +1 -1
- package/lib/cjs/DelayedPromise.js +2 -2
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +27 -26
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +150 -150
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +34 -34
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js +3 -3
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +49 -49
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +6 -11
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.d.ts +2 -2
- package/lib/cjs/ECName.js +4 -4
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +23 -11
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +47 -24
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.d.ts +4 -4
- package/lib/cjs/Exception.d.ts.map +1 -1
- package/lib/cjs/Exception.js +60 -60
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +30 -34
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +107 -19
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +127 -47
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +12 -9
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +12 -9
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +5 -3
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +7 -5
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +20 -3
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +32 -14
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +16 -9
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +20 -13
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +32 -24
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +47 -27
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +11 -7
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +16 -10
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +24 -15
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +54 -29
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +16 -3
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +20 -7
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +27 -19
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +10 -2
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +11 -3
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +46 -28
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +46 -22
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +6 -3
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +12 -5
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +48 -25
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +54 -34
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +50 -28
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +64 -42
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +10 -19
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +12 -20
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +17 -21
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +20 -22
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +3 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +4 -2
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts +11 -11
- package/lib/cjs/PropertyTypes.d.ts.map +1 -1
- package/lib/cjs/PropertyTypes.js +28 -20
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
- package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/SchemaFormatsProvider.js +146 -0
- package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
- package/lib/cjs/SchemaJsonLocater.d.ts +5 -5
- package/lib/cjs/SchemaJsonLocater.js +4 -4
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +6 -6
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +9 -9
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +3 -3
- package/lib/cjs/SchemaLoader.js +4 -4
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/cjs/SchemaPartVisitorDelegate.js +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +2 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +1 -0
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +3 -3
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Context.d.ts +3 -3
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +7 -7
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.d.ts +9 -8
- package/lib/esm/DelayedPromise.d.ts.map +1 -1
- package/lib/esm/DelayedPromise.js +2 -2
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +28 -27
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +151 -151
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +34 -34
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js +3 -3
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +50 -50
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +7 -12
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.d.ts +2 -2
- package/lib/esm/ECName.js +5 -5
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +23 -11
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +48 -25
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.d.ts +4 -4
- package/lib/esm/Exception.d.ts.map +1 -1
- package/lib/esm/Exception.js +58 -58
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +30 -34
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +107 -19
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +128 -48
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +12 -9
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +13 -10
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +5 -3
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +8 -6
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +20 -3
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +33 -15
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +16 -9
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +21 -14
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +32 -24
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +48 -28
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +11 -7
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +17 -11
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +24 -15
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +55 -30
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +16 -3
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +21 -8
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +28 -20
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +10 -2
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +12 -4
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +46 -28
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +47 -23
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +6 -3
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +13 -6
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +48 -25
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +55 -35
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +50 -28
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +65 -43
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +10 -19
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +13 -21
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +17 -21
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +21 -23
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +3 -1
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +5 -3
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.d.ts +11 -11
- package/lib/esm/PropertyTypes.d.ts.map +1 -1
- package/lib/esm/PropertyTypes.js +29 -21
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
- package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/esm/SchemaFormatsProvider.js +142 -0
- package/lib/esm/SchemaFormatsProvider.js.map +1 -0
- package/lib/esm/SchemaJsonLocater.d.ts +5 -5
- package/lib/esm/SchemaJsonLocater.js +4 -4
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +6 -6
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +10 -10
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +3 -3
- package/lib/esm/SchemaLoader.js +5 -5
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/esm/SchemaPartVisitorDelegate.js +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +2 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +1 -0
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +4 -4
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +8 -6
|
@@ -7,23 +7,27 @@ import { LazyLoadedUnit, LazyLoadedUnitSystem } from "../Interfaces";
|
|
|
7
7
|
import { SchemaItem } from "./SchemaItem";
|
|
8
8
|
/**
|
|
9
9
|
* An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
|
|
10
|
-
* @
|
|
10
|
+
* @public @preview
|
|
11
11
|
*/
|
|
12
12
|
export declare class InvertedUnit extends SchemaItem {
|
|
13
13
|
readonly schemaItemType: SchemaItemType;
|
|
14
|
+
/** @internal */
|
|
14
15
|
static get schemaItemType(): SchemaItemType;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
private _invertsUnit?;
|
|
17
|
+
private _unitSystem?;
|
|
17
18
|
get invertsUnit(): LazyLoadedUnit | undefined;
|
|
18
19
|
get unitSystem(): LazyLoadedUnitSystem | undefined;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Type guard to check if the SchemaItem is of type InvertedUnit.
|
|
22
|
+
* @param item The SchemaItem to check.
|
|
23
|
+
* @returns True if the item is a InvertedUnit, false otherwise.
|
|
21
24
|
*/
|
|
22
|
-
static isInvertedUnit(
|
|
25
|
+
static isInvertedUnit(item?: SchemaItem): item is InvertedUnit;
|
|
23
26
|
/**
|
|
24
27
|
* Type assertion to check if the SchemaItem is of type InvertedUnit.
|
|
25
28
|
* @param item The SchemaItem to check.
|
|
26
29
|
* @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
|
|
30
|
+
* @internal
|
|
27
31
|
*/
|
|
28
32
|
static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit;
|
|
29
33
|
/**
|
|
@@ -37,12 +41,12 @@ export declare class InvertedUnit extends SchemaItem {
|
|
|
37
41
|
fromJSONSync(invertedUnitProps: InvertedUnitProps): void;
|
|
38
42
|
fromJSON(invertedUnitProps: InvertedUnitProps): Promise<void>;
|
|
39
43
|
/**
|
|
40
|
-
* @
|
|
44
|
+
* @internal
|
|
41
45
|
* Used for schema editing
|
|
42
46
|
*/
|
|
43
47
|
protected setInvertsUnit(invertsUnit: LazyLoadedUnit): void;
|
|
44
48
|
/**
|
|
45
|
-
* @
|
|
49
|
+
* @internal
|
|
46
50
|
* Used for schema editing
|
|
47
51
|
*/
|
|
48
52
|
protected setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;
|
|
@@ -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,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,SAAyB,cAAc,iBAA+B;IACtE,WAA2B,cAAc,mBAA0C;IACnF,
|
|
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,gBAAgB;IAChB,WAA2B,cAAc,mBAA0C;IACnF,OAAO,CAAC,YAAY,CAAC,CAAiB;IACtC,OAAO,CAAC,WAAW,CAAC,CAAuB;IAE3C,IAAW,WAAW,IAAI,cAAc,GAAG,SAAS,CAA8B;IAClF,IAAW,UAAU,IAAI,oBAAoB,GAAG,SAAS,CAA6B;IAEtF;;;;OAIG;WACW,cAAc,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,YAAY;IAOrE;;;;;OAKG;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"}
|
|
@@ -17,29 +17,35 @@ const Unit_1 = require("./Unit");
|
|
|
17
17
|
const UnitSystem_1 = require("./UnitSystem");
|
|
18
18
|
/**
|
|
19
19
|
* An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.
|
|
20
|
-
* @
|
|
20
|
+
* @public @preview
|
|
21
21
|
*/
|
|
22
22
|
class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
23
23
|
schemaItemType = InvertedUnit.schemaItemType;
|
|
24
|
+
/** @internal */
|
|
24
25
|
static get schemaItemType() { return ECObjects_1.SchemaItemType.InvertedUnit; }
|
|
25
26
|
_invertsUnit; // required
|
|
26
27
|
_unitSystem; // required
|
|
27
28
|
get invertsUnit() { return this._invertsUnit; }
|
|
28
29
|
get unitSystem() { return this._unitSystem; }
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
+
* Type guard to check if the SchemaItem is of type InvertedUnit.
|
|
32
|
+
* @param item The SchemaItem to check.
|
|
33
|
+
* @returns True if the item is a InvertedUnit, false otherwise.
|
|
31
34
|
*/
|
|
32
|
-
static isInvertedUnit(
|
|
33
|
-
|
|
35
|
+
static isInvertedUnit(item) {
|
|
36
|
+
if (item && item.schemaItemType === ECObjects_1.SchemaItemType.InvertedUnit)
|
|
37
|
+
return true;
|
|
38
|
+
return false;
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* Type assertion to check if the SchemaItem is of type InvertedUnit.
|
|
37
42
|
* @param item The SchemaItem to check.
|
|
38
43
|
* @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.
|
|
44
|
+
* @internal
|
|
39
45
|
*/
|
|
40
46
|
static assertIsInvertedUnit(item) {
|
|
41
47
|
if (!this.isInvertedUnit(item))
|
|
42
|
-
throw new Exception_1.
|
|
48
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.InvertedUnit}' (InvertedUnit)`);
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* Save this InvertedUnit's properties to an object for serializing to JSON.
|
|
@@ -73,16 +79,16 @@ class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
|
73
79
|
this._invertsUnit = new DelayedPromise_1.DelayedPromiseWithProps(unitSchemaItemKey, async () => {
|
|
74
80
|
const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit_1.Unit);
|
|
75
81
|
if (undefined === invertsUnit)
|
|
76
|
-
throw new Exception_1.
|
|
82
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);
|
|
77
83
|
return invertsUnit;
|
|
78
84
|
});
|
|
79
85
|
const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);
|
|
80
86
|
if (!unitSystemSchemaItemKey)
|
|
81
|
-
throw new Exception_1.
|
|
87
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
|
|
82
88
|
this._unitSystem = new DelayedPromise_1.DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
|
|
83
89
|
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem_1.UnitSystem);
|
|
84
90
|
if (undefined === unitSystem)
|
|
85
|
-
throw new Exception_1.
|
|
91
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);
|
|
86
92
|
return unitSystem;
|
|
87
93
|
});
|
|
88
94
|
}
|
|
@@ -90,14 +96,14 @@ class InvertedUnit extends SchemaItem_1.SchemaItem {
|
|
|
90
96
|
this.fromJSONSync(invertedUnitProps);
|
|
91
97
|
}
|
|
92
98
|
/**
|
|
93
|
-
* @
|
|
99
|
+
* @internal
|
|
94
100
|
* Used for schema editing
|
|
95
101
|
*/
|
|
96
102
|
setInvertsUnit(invertsUnit) {
|
|
97
103
|
this._invertsUnit = invertsUnit;
|
|
98
104
|
}
|
|
99
105
|
/**
|
|
100
|
-
* @
|
|
106
|
+
* @internal
|
|
101
107
|
* Used for schema editing
|
|
102
108
|
*/
|
|
103
109
|
setUnitSystem(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,
|
|
1
|
+
{"version":3,"file":"InvertedUnit.js","sourceRoot":"","sources":["../../../src/Metadata/InvertedUnit.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAG7D,6CAA0C;AAC1C,iCAA8B;AAC9B,6CAA0C;AAE1C;;;GAGG;AACH,MAAa,YAAa,SAAQ,uBAAU;IACjB,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;IACtE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3E,YAAY,CAAkB,CAAC,WAAW;IAC1C,WAAW,CAAwB,CAAC,WAAW;IAEvD,IAAW,WAAW,KAAiC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAClF,IAAW,UAAU,KAAuC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAEtF;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,IAAiB;QAC5C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,YAAY;YAC7D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,oBAAoB,CAAC,IAAiB;QAClD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC5B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,YAAY,kBAAkB,CAAC,CAAC;IAC9H,CAAC;IAED;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QACvF,MAAM,UAAU,GAAG,KA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H,MAAsB,mBAAoB,SAAQ,YAAY;CAI7D;AAJD,kDAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { InvertedUnitProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedUnit, LazyLoadedUnitSystem } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\nimport { UnitSystem } from \"./UnitSystem\";\n\n/**\n * An InvertedUnit is a specific type of Unit that describes the inverse of a single Unit whose dimensional derivation is unit-less.\n * @public @preview\n */\nexport class InvertedUnit extends SchemaItem {\n public override readonly schemaItemType = InvertedUnit.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.InvertedUnit; }\n private _invertsUnit?: LazyLoadedUnit; // required\n private _unitSystem?: LazyLoadedUnitSystem; // required\n\n public get invertsUnit(): LazyLoadedUnit | undefined { return this._invertsUnit; }\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\n\n /**\n * Type guard to check if the SchemaItem is of type InvertedUnit.\n * @param item The SchemaItem to check.\n * @returns True if the item is a InvertedUnit, false otherwise.\n */\n public static isInvertedUnit(item?: SchemaItem): item is InvertedUnit {\n if (item && item.schemaItemType === SchemaItemType.InvertedUnit)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type InvertedUnit.\n * @param item The SchemaItem to check.\n * @returns The item cast to InvertedUnit if it is an InvertedUnit, undefined otherwise.\n * @internal\n */\n public static assertIsInvertedUnit(item?: SchemaItem): asserts item is InvertedUnit {\n if (!this.isInvertedUnit(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.InvertedUnit}' (InvertedUnit)`);\n }\n\n /**\n * Save this InvertedUnit's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): InvertedUnitProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.invertsUnit = this.invertsUnit!.fullName;\n schemaJson.unitSystem = this.unitSystem!.fullName;\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const unitSystem = await this.unitSystem;\n if (undefined !== unitSystem) {\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\n }\n\n const invertsUnit = await this.invertsUnit;\n if (undefined !== invertsUnit) {\n const invertsUnitName = XmlSerializationUtils.createXmlTypedName(this.schema, invertsUnit.schema, invertsUnit.name);\n itemElement.setAttribute(\"invertsUnit\", invertsUnitName);\n }\n\n return itemElement;\n }\n\n public override fromJSONSync(invertedUnitProps: InvertedUnitProps) {\n super.fromJSONSync(invertedUnitProps);\n const unitSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.invertsUnit);\n this._invertsUnit = new DelayedPromiseWithProps<SchemaItemKey, Unit>(unitSchemaItemKey,\n async () => {\n const invertsUnit = await this.schema.lookupItem(unitSchemaItemKey, Unit);\n if (undefined === invertsUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the invertsUnit ${invertedUnitProps.invertsUnit}.`);\n return invertsUnit;\n });\n\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(invertedUnitProps.unitSystem);\n if (!unitSystemSchemaItemKey)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\n async () => {\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\n if (undefined === unitSystem)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the unitSystem ${invertedUnitProps.unitSystem}.`);\n return unitSystem;\n });\n }\n\n public override async fromJSON(invertedUnitProps: InvertedUnitProps) {\n this.fromJSONSync(invertedUnitProps);\n }\n\n /**\n * @internal\n * Used for schema editing\n */\n protected setInvertsUnit(invertsUnit: LazyLoadedUnit) {\n this._invertsUnit = invertsUnit;\n }\n\n /**\n * @internal\n * Used for schema editing\n */\n protected setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\n this._unitSystem = unitSystem;\n }\n}\n\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableInvertedUnit extends InvertedUnit {\n public abstract override setInvertsUnit(invertsUnit: LazyLoadedUnit): void;\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -3,40 +3,41 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { KindOfQuantityProps } from "../Deserialization/JsonProps";
|
|
5
5
|
import { SchemaItemType } from "../ECObjects";
|
|
6
|
-
import { LazyLoadedInvertedUnit, LazyLoadedUnit } from "../Interfaces";
|
|
6
|
+
import { LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit } from "../Interfaces";
|
|
7
7
|
import { Format } from "./Format";
|
|
8
|
-
import { InvertedUnit } from "./InvertedUnit";
|
|
9
8
|
import { OverrideFormat } from "./OverrideFormat";
|
|
10
9
|
import { SchemaItem } from "./SchemaItem";
|
|
11
|
-
import { Unit } from "./Unit";
|
|
12
10
|
/** A Typescript class representation of a KindOfQuantity.
|
|
13
|
-
* @
|
|
11
|
+
* @public @preview
|
|
14
12
|
*/
|
|
15
13
|
export declare class KindOfQuantity extends SchemaItem {
|
|
16
14
|
readonly schemaItemType: SchemaItemType;
|
|
15
|
+
/** @internal */
|
|
17
16
|
static get schemaItemType(): SchemaItemType;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
private _relativeError;
|
|
18
|
+
private _presentationFormats;
|
|
19
|
+
private _persistenceUnit?;
|
|
21
20
|
/** The first presentation format in the list of Formats. */
|
|
22
|
-
get defaultPresentationFormat():
|
|
21
|
+
get defaultPresentationFormat(): LazyLoadedFormat | OverrideFormat | undefined;
|
|
23
22
|
/** A list of presentation formats. */
|
|
24
|
-
get presentationFormats(): Array<
|
|
23
|
+
get presentationFormats(): Array<LazyLoadedFormat | OverrideFormat>;
|
|
24
|
+
/** Persistence unit */
|
|
25
25
|
get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined;
|
|
26
|
-
protected set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined);
|
|
27
26
|
get relativeError(): number;
|
|
28
27
|
/**
|
|
29
28
|
*
|
|
30
29
|
* @param format The Format to add to this KindOfQuantity
|
|
31
30
|
* @param isDefault
|
|
31
|
+
* @internal
|
|
32
32
|
*/
|
|
33
|
-
protected addPresentationFormat(format:
|
|
33
|
+
protected addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault?: boolean): void;
|
|
34
34
|
/** Creates an OverrideFormat in the context of this KindOfQuantity.
|
|
35
35
|
* @param parent The Format to override.
|
|
36
36
|
* @param precision The precision override
|
|
37
37
|
* @param unitLabelOverrides The list of unit and label overrides.
|
|
38
|
+
* @internal
|
|
38
39
|
*/
|
|
39
|
-
protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[
|
|
40
|
+
protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;
|
|
40
41
|
private processPresentationUnits;
|
|
41
42
|
private processPresentationUnitsSync;
|
|
42
43
|
/**
|
|
@@ -50,10 +51,15 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
50
51
|
fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void;
|
|
51
52
|
fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void>;
|
|
52
53
|
/**
|
|
53
|
-
* @alpha
|
|
54
54
|
* Used for schema editing.
|
|
55
|
+
* @internal
|
|
55
56
|
*/
|
|
56
57
|
protected setRelativeError(relativeError: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* Used for schema editing.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
protected setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;
|
|
57
63
|
/**
|
|
58
64
|
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
59
65
|
* @param item The SchemaItem to check.
|
|
@@ -64,6 +70,7 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
64
70
|
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
65
71
|
* @param item The SchemaItem to check.
|
|
66
72
|
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
73
|
+
* @internal
|
|
67
74
|
*/
|
|
68
75
|
static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity;
|
|
69
76
|
}
|
|
@@ -72,8 +79,10 @@ export declare class KindOfQuantity extends SchemaItem {
|
|
|
72
79
|
* An abstract class used for schema editing.
|
|
73
80
|
*/
|
|
74
81
|
export declare abstract class MutableKindOfQuantity extends KindOfQuantity {
|
|
75
|
-
abstract addPresentationFormat(format:
|
|
76
|
-
abstract createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[
|
|
82
|
+
abstract addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;
|
|
83
|
+
abstract createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;
|
|
77
84
|
abstract setDisplayLabel(displayLabel: string): void;
|
|
85
|
+
abstract setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;
|
|
86
|
+
abstract setRelativeError(relativeError: number): void;
|
|
78
87
|
}
|
|
79
88
|
//# sourceMappingURL=KindOfQuantity.d.ts.map
|
|
@@ -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;
|
|
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,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,SAAyB,cAAc,iBAAiC;IACxE,gBAAgB;IAChB,WAA2B,cAAc,mBAA4C;IACrF,OAAO,CAAC,cAAc,CAAe;IACrC,OAAO,CAAC,oBAAoB,CAAgD;IAC5E,OAAO,CAAC,gBAAgB,CAAC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KG;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,gBAAgB,GAAG,cAAc,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;aAC1F,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,KAAK,CAAC,CAAC,cAAc,GAAG,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,cAAc;aACnK,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;aAC3C,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,sBAAsB,GAAG,SAAS,GAAG,IAAI;aACpF,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CACvE"}
|
|
@@ -18,40 +18,44 @@ const OverrideFormat_1 = require("./OverrideFormat");
|
|
|
18
18
|
const SchemaItem_1 = require("./SchemaItem");
|
|
19
19
|
const Unit_1 = require("./Unit");
|
|
20
20
|
/** A Typescript class representation of a KindOfQuantity.
|
|
21
|
-
* @
|
|
21
|
+
* @public @preview
|
|
22
22
|
*/
|
|
23
23
|
class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
24
24
|
schemaItemType = KindOfQuantity.schemaItemType;
|
|
25
|
+
/** @internal */
|
|
25
26
|
static get schemaItemType() { return ECObjects_1.SchemaItemType.KindOfQuantity; }
|
|
26
27
|
_relativeError = 1.0;
|
|
27
|
-
_presentationFormats =
|
|
28
|
+
_presentationFormats = [];
|
|
28
29
|
_persistenceUnit;
|
|
29
30
|
/** The first presentation format in the list of Formats. */
|
|
30
31
|
get defaultPresentationFormat() { return this.presentationFormats[0]; }
|
|
31
32
|
/** A list of presentation formats. */
|
|
32
33
|
get presentationFormats() { return this._presentationFormats; }
|
|
34
|
+
/** Persistence unit */
|
|
33
35
|
get persistenceUnit() { return this._persistenceUnit; }
|
|
34
|
-
set persistenceUnit(value) { this._persistenceUnit = value; }
|
|
35
36
|
get relativeError() { return this._relativeError; }
|
|
36
37
|
/**
|
|
37
38
|
*
|
|
38
39
|
* @param format The Format to add to this KindOfQuantity
|
|
39
40
|
* @param isDefault
|
|
41
|
+
* @internal
|
|
40
42
|
*/
|
|
41
43
|
addPresentationFormat(format, isDefault = false) {
|
|
42
44
|
// TODO: Add some sort of validation?
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
43
46
|
(isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);
|
|
44
47
|
}
|
|
45
48
|
/** Creates an OverrideFormat in the context of this KindOfQuantity.
|
|
46
49
|
* @param parent The Format to override.
|
|
47
50
|
* @param precision The precision override
|
|
48
51
|
* @param unitLabelOverrides The list of unit and label overrides.
|
|
52
|
+
* @internal
|
|
49
53
|
*/
|
|
50
54
|
createFormatOverride(parent, precision, unitLabelOverrides) {
|
|
51
55
|
if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)
|
|
52
|
-
throw new Exception_1.
|
|
56
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);
|
|
53
57
|
if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)
|
|
54
|
-
throw new Exception_1.
|
|
58
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);
|
|
55
59
|
// TODO: Check compatibility of Unit overrides with the persistence unit
|
|
56
60
|
return new OverrideFormat_1.OverrideFormat(parent, precision, unitLabelOverrides);
|
|
57
61
|
}
|
|
@@ -61,21 +65,24 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
61
65
|
const presFormatOverride = OverrideFormat_1.OverrideFormat.parseFormatString(formatString);
|
|
62
66
|
const format = await this.schema.lookupItem(presFormatOverride.name, Format_1.Format);
|
|
63
67
|
if (undefined === format || format.schemaItemType !== ECObjects_1.SchemaItemType.Format)
|
|
64
|
-
throw new Exception_1.
|
|
68
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
65
69
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
66
|
-
this.addPresentationFormat(format);
|
|
70
|
+
this.addPresentationFormat(new DelayedPromise_1.DelayedPromiseWithProps(format.key, async () => format));
|
|
67
71
|
continue;
|
|
68
72
|
}
|
|
69
73
|
let unitAndLabels;
|
|
70
74
|
if (undefined !== presFormatOverride.unitAndLabels) {
|
|
71
75
|
if (4 < presFormatOverride.unitAndLabels.length)
|
|
72
|
-
throw new Exception_1.
|
|
76
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, ``);
|
|
73
77
|
unitAndLabels = [];
|
|
74
78
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
75
79
|
const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
if (Unit_1.Unit.isUnit(unitOrInverted))
|
|
81
|
+
unitAndLabels.push([new DelayedPromise_1.DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
82
|
+
else if (InvertedUnit_1.InvertedUnit.isInvertedUnit(unitOrInverted))
|
|
83
|
+
unitAndLabels.push([new DelayedPromise_1.DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
84
|
+
else
|
|
85
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -88,21 +95,24 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
88
95
|
const presFormatOverride = OverrideFormat_1.OverrideFormat.parseFormatString(formatString);
|
|
89
96
|
const format = this.schema.lookupItemSync(presFormatOverride.name, Format_1.Format);
|
|
90
97
|
if (undefined === format || format.schemaItemType !== ECObjects_1.SchemaItemType.Format)
|
|
91
|
-
throw new Exception_1.
|
|
98
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
92
99
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
93
|
-
this.addPresentationFormat(format);
|
|
100
|
+
this.addPresentationFormat(new DelayedPromise_1.DelayedPromiseWithProps(format.key, async () => format));
|
|
94
101
|
continue;
|
|
95
102
|
}
|
|
96
103
|
let unitAndLabels;
|
|
97
104
|
if (undefined !== presFormatOverride.unitAndLabels) {
|
|
98
105
|
if (4 < presFormatOverride.unitAndLabels.length)
|
|
99
|
-
throw new Exception_1.
|
|
106
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, ``);
|
|
100
107
|
unitAndLabels = [];
|
|
101
108
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
102
109
|
const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
if (Unit_1.Unit.isUnit(unitOrInverted))
|
|
111
|
+
unitAndLabels.push([new DelayedPromise_1.DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
112
|
+
else if (InvertedUnit_1.InvertedUnit.isInvertedUnit(unitOrInverted))
|
|
113
|
+
unitAndLabels.push([new DelayedPromise_1.DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
114
|
+
else
|
|
115
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -131,11 +141,16 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
131
141
|
itemElement.setAttribute("persistenceUnit", unitName);
|
|
132
142
|
}
|
|
133
143
|
if (undefined !== this.presentationFormats) {
|
|
134
|
-
const presUnitStrings =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
const presUnitStrings = [];
|
|
145
|
+
for (const format of this.presentationFormats) {
|
|
146
|
+
if (!OverrideFormat_1.OverrideFormat.isOverrideFormat(format)) {
|
|
147
|
+
const resolvedFormat = await format;
|
|
148
|
+
presUnitStrings.push(XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
presUnitStrings.push(format.fullNameXml(this.schema));
|
|
152
|
+
}
|
|
153
|
+
;
|
|
139
154
|
itemElement.setAttribute("presentationUnits", presUnitStrings.join(";"));
|
|
140
155
|
}
|
|
141
156
|
itemElement.setAttribute("relativeError", this.relativeError.toString());
|
|
@@ -146,9 +161,9 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
146
161
|
this._relativeError = kindOfQuantityProps.relativeError;
|
|
147
162
|
const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);
|
|
148
163
|
if (undefined === persistenceUnit)
|
|
149
|
-
throw new Exception_1.
|
|
164
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
150
165
|
if (!Unit_1.Unit.isUnit(persistenceUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
151
|
-
throw new Exception_1.
|
|
166
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
152
167
|
if (Unit_1.Unit.isUnit(persistenceUnit))
|
|
153
168
|
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
154
169
|
else
|
|
@@ -161,9 +176,9 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
161
176
|
this._relativeError = kindOfQuantityProps.relativeError;
|
|
162
177
|
const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);
|
|
163
178
|
if (undefined === persistenceUnit)
|
|
164
|
-
throw new Exception_1.
|
|
179
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
165
180
|
if (!Unit_1.Unit.isUnit(persistenceUnit) && !InvertedUnit_1.InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
166
|
-
throw new Exception_1.
|
|
181
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
167
182
|
if (Unit_1.Unit.isUnit(persistenceUnit))
|
|
168
183
|
this._persistenceUnit = new DelayedPromise_1.DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
169
184
|
else
|
|
@@ -172,28 +187,38 @@ class KindOfQuantity extends SchemaItem_1.SchemaItem {
|
|
|
172
187
|
await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);
|
|
173
188
|
}
|
|
174
189
|
/**
|
|
175
|
-
* @alpha
|
|
176
190
|
* Used for schema editing.
|
|
191
|
+
* @internal
|
|
177
192
|
*/
|
|
178
193
|
setRelativeError(relativeError) {
|
|
179
194
|
this._relativeError = relativeError;
|
|
180
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Used for schema editing.
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
setPersistenceUnit(value) {
|
|
201
|
+
this._persistenceUnit = value;
|
|
202
|
+
}
|
|
181
203
|
/**
|
|
182
204
|
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
183
205
|
* @param item The SchemaItem to check.
|
|
184
206
|
* @returns True if the item is a KindOfQuantity, false otherwise.
|
|
185
207
|
*/
|
|
186
208
|
static isKindOfQuantity(item) {
|
|
187
|
-
|
|
209
|
+
if (item && item.schemaItemType === ECObjects_1.SchemaItemType.KindOfQuantity)
|
|
210
|
+
return true;
|
|
211
|
+
return false;
|
|
188
212
|
}
|
|
189
213
|
/**
|
|
190
214
|
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
191
215
|
* @param item The SchemaItem to check.
|
|
192
216
|
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
217
|
+
* @internal
|
|
193
218
|
*/
|
|
194
219
|
static assertIsKindOfQuantity(item) {
|
|
195
220
|
if (!this.isKindOfQuantity(item))
|
|
196
|
-
throw new Exception_1.
|
|
221
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);
|
|
197
222
|
}
|
|
198
223
|
}
|
|
199
224
|
exports.KindOfQuantity = KindOfQuantity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4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AgB,GAAG,IAAI,wCAAuB,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC;QAGxG,IAAI,SAAS,KAAK,mBAAmB,CAAC,iBAAiB;YACrD,MAAM,IAAI,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACO,gBAAgB,CAAC,aAAqB;QAC9C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,OAAO,IAAI,EAAE,cAAc,KAAK,0BAAc,CAAC,cAAc,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,sBAAsB,CAAC,IAAiB;QACpD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC9B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IACpI,CAAC;CACF;AAzND,wCAyNC;AACD;;;GAGG;AACH,MAAsB,qBAAsB,SAAQ,cAAc;CAIjE;AAJD,sDAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { KindOfQuantityProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { OverrideFormat, OverrideFormatProps } from \"./OverrideFormat\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/** A Typescript class representation of a KindOfQuantity.\n * @beta\n */\nexport class KindOfQuantity extends SchemaItem {\n public override readonly schemaItemType = KindOfQuantity.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.KindOfQuantity; }\n protected _relativeError: number = 1.0;\n protected _presentationFormats: Array<Format | OverrideFormat> = new Array<Format | OverrideFormat>();\n protected _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;\n\n /** The first presentation format in the list of Formats. */\n public get defaultPresentationFormat(): Format | OverrideFormat | undefined { return this.presentationFormats[0]; }\n\n /** A list of presentation formats. */\n public get presentationFormats(): Array<Format | OverrideFormat> { return this._presentationFormats; }\n\n public get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined { return this._persistenceUnit; }\n protected set persistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined) { this._persistenceUnit = value; }\n\n public get relativeError() { return this._relativeError; }\n\n /**\n *\n * @param format The Format to add to this KindOfQuantity\n * @param isDefault\n */\n protected addPresentationFormat(format: Format | OverrideFormat, isDefault: boolean = false) {\n // TODO: Add some sort of validation?\n (isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);\n }\n\n /** Creates an OverrideFormat in the context of this KindOfQuantity.\n * @param parent The Format to override.\n * @param precision The precision override\n * @param unitLabelOverrides The list of unit and label overrides.\n */\n protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): OverrideFormat {\n if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);\n\n if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);\n\n // TODO: Check compatibility of Unit overrides with the persistence unit\n\n return new OverrideFormat(parent, precision, unitLabelOverrides);\n }\n\n private async processPresentationUnits(presentationUnitsJson: string | string[]): Promise<void> {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = await this.schema.lookupItem(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(format);\n continue;\n }\n\n let unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);\n if (undefined === unitOrInverted || (!Unit.isUnit(unitOrInverted) && !InvertedUnit.isInvertedUnit(unitOrInverted)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n\n unitAndLabels.push([unitOrInverted, unitOverride[1]]);\n }\n }\n\n const overrideFormat: OverrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n private processPresentationUnitsSync(presentationUnitsJson: string | string[]): void {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = this.schema.lookupItemSync(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(format);\n continue;\n }\n\n let unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);\n if (undefined === unitOrInverted || (!Unit.isUnit(unitOrInverted) && !InvertedUnit.isInvertedUnit(unitOrInverted)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n\n unitAndLabels.push([unitOrInverted, unitOverride[1]]);\n }\n }\n\n const overrideFormat: OverrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n /**\n * Save this KindOfQuantity's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): KindOfQuantityProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.relativeError = this.relativeError;\n schemaJson.persistenceUnit = this.persistenceUnit!.fullName;\n if (undefined !== this.presentationFormats && 0 < this.presentationFormats.length)\n schemaJson.presentationUnits = this.presentationFormats.map((format: Format | OverrideFormat) => format.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const persistenceUnit = await this.persistenceUnit;\n if (undefined !== persistenceUnit) {\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, persistenceUnit.schema, persistenceUnit.name);\n itemElement.setAttribute(\"persistenceUnit\", unitName);\n }\n\n if (undefined !== this.presentationFormats) {\n const presUnitStrings = this.presentationFormats.map((format: Format | OverrideFormat) => {\n if (!OverrideFormat.isOverrideFormat(format))\n return XmlSerializationUtils.createXmlTypedName(this.schema, format.schema, format.name);\n return format.fullNameXml(this.schema);\n });\n itemElement.setAttribute(\"presentationUnits\", presUnitStrings.join(\";\"));\n }\n itemElement.setAttribute(\"relativeError\", this.relativeError.toString());\n\n return itemElement;\n }\n\n public override fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void {\n super.fromJSONSync(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if(Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);\n }\n\n public override async fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void> {\n await super.fromJSON(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if(Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setRelativeError(relativeError: number): void {\n this._relativeError = relativeError;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns True if the item is a KindOfQuantity, false otherwise.\n */\n public static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity {\n return item?.schemaItemType === SchemaItemType.KindOfQuantity;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.\n */\n public static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity {\n if (!this.isKindOfQuantity(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: Format | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAE5D,oFAAiF;AACjF,4CAA8C;AAC9C,4CAA6D;AAE7D,qCAAkC;AAClC,iDAA8C;AAC9C,qDAAuE;AACvE,6CAA0C;AAC1C,iCAA8B;AAE9B;;GAEG;AACH,MAAa,cAAe,SAAQ,uBAAU;IACnB,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;IACxE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IAC7E,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAA6C,EAAE,CAAC;IACpE,gBAAgB,CAA2C;IAEnE,4DAA4D;IAC5D,IAAW,yBAAyB,KAAoD,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7H,sCAAsC;IACtC,IAAW,mBAAmB,KAA+C,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAEhH,uBAAuB;IACvB,IAAW,eAAe,KAA0D,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEnH,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAE1D;;;;;OAKG;IACO,qBAAqB,CAAC,MAAyC,EAAE,YAAqB,KAAK;QACnG,qCAAqC;QACrC,mEAAmE;QACnE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxG,CAAC;IAED;;;;;OAKG;IACO,oBAAoB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AAG,KAAK,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAiB;QAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,0BAAc,CAAC,cAAc;YAC/D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,sBAAsB,CAAC,IAAiB;QACpD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC9B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IAClI,CAAC;CACF;AAlPD,wCAkPC;AACD;;;GAGG;AACH,MAAsB,qBAAsB,SAAQ,cAAc;CAMjE;AAND,sDAMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { KindOfQuantityProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedFormat, LazyLoadedInvertedUnit, LazyLoadedUnit } from \"../Interfaces\";\nimport { Format } from \"./Format\";\nimport { InvertedUnit } from \"./InvertedUnit\";\nimport { OverrideFormat, OverrideFormatProps } from \"./OverrideFormat\";\nimport { SchemaItem } from \"./SchemaItem\";\nimport { Unit } from \"./Unit\";\n\n/** A Typescript class representation of a KindOfQuantity.\n * @public @preview\n */\nexport class KindOfQuantity extends SchemaItem {\n public override readonly schemaItemType = KindOfQuantity.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.KindOfQuantity; }\n private _relativeError: number = 1.0;\n private _presentationFormats: Array<LazyLoadedFormat | OverrideFormat> = [];\n private _persistenceUnit?: LazyLoadedUnit | LazyLoadedInvertedUnit;\n\n /** The first presentation format in the list of Formats. */\n public get defaultPresentationFormat(): LazyLoadedFormat | OverrideFormat | undefined { return this.presentationFormats[0]; }\n\n /** A list of presentation formats. */\n public get presentationFormats(): Array<LazyLoadedFormat | OverrideFormat> { return this._presentationFormats; }\n\n /** Persistence unit */\n public get persistenceUnit(): LazyLoadedUnit | LazyLoadedInvertedUnit | undefined { return this._persistenceUnit; }\n\n public get relativeError() { return this._relativeError; }\n\n /**\n *\n * @param format The Format to add to this KindOfQuantity\n * @param isDefault\n * @internal\n */\n protected addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean = false) {\n // TODO: Add some sort of validation?\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);\n }\n\n /** Creates an OverrideFormat in the context of this KindOfQuantity.\n * @param parent The Format to override.\n * @param precision The precision override\n * @param unitLabelOverrides The list of unit and label overrides.\n * @internal\n */\n protected createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat {\n if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add presentation format to KindOfQuantity '${this.name}' because the number of unit overrides is inconsistent with the number in the Format '${parent.name}'.`);\n\n if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);\n\n // TODO: Check compatibility of Unit overrides with the persistence unit\n\n return new OverrideFormat(parent, precision, unitLabelOverrides);\n }\n\n private async processPresentationUnits(presentationUnitsJson: string | string[]): Promise<void> {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = await this.schema.lookupItem(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);\n \n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n private processPresentationUnitsSync(presentationUnitsJson: string | string[]): void {\n const presUnitsArr = Array.isArray(presentationUnitsJson) ? presentationUnitsJson : presentationUnitsJson.split(\";\");\n for (const formatString of presUnitsArr) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(formatString);\n\n const format = this.schema.lookupItemSync(presFormatOverride.name, Format);\n if (undefined === format || format.schemaItemType !== SchemaItemType.Format)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);\n\n if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {\n this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));\n continue;\n }\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== presFormatOverride.unitAndLabels) {\n if (4 < presFormatOverride.unitAndLabels.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);\n\n unitAndLabels = [];\n for (const unitOverride of presFormatOverride.unitAndLabels) {\n const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);\n if(Unit.isUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unitOrInverted))\n unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);\n else\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);\n }\n }\n\n const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);\n this.addPresentationFormat(overrideFormat);\n }\n }\n\n /**\n * Save this KindOfQuantity's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): KindOfQuantityProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.relativeError = this.relativeError;\n schemaJson.persistenceUnit = this.persistenceUnit!.fullName;\n if (undefined !== this.presentationFormats && 0 < this.presentationFormats.length)\n schemaJson.presentationUnits = this.presentationFormats.map((format) => format.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n const persistenceUnit = await this.persistenceUnit;\n if (undefined !== persistenceUnit) {\n const unitName = XmlSerializationUtils.createXmlTypedName(this.schema, persistenceUnit.schema, persistenceUnit.name);\n itemElement.setAttribute(\"persistenceUnit\", unitName);\n }\n\n if (undefined !== this.presentationFormats) {\n const presUnitStrings: string[] = [];\n for(const format of this.presentationFormats) {\n if (!OverrideFormat.isOverrideFormat(format)) {\n const resolvedFormat = await format;\n presUnitStrings.push(XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));\n continue;\n }\n presUnitStrings.push(format.fullNameXml(this.schema));\n };\n itemElement.setAttribute(\"presentationUnits\", presUnitStrings.join(\";\"));\n }\n itemElement.setAttribute(\"relativeError\", this.relativeError.toString());\n\n return itemElement;\n }\n\n public override fromJSONSync(kindOfQuantityProps: KindOfQuantityProps): void {\n super.fromJSONSync(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if (Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n this.processPresentationUnitsSync(kindOfQuantityProps.presentationUnits);\n }\n\n public override async fromJSON(kindOfQuantityProps: KindOfQuantityProps): Promise<void> {\n await super.fromJSON(kindOfQuantityProps);\n this._relativeError = kindOfQuantityProps.relativeError;\n\n const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);\n if (undefined === persistenceUnit)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);\n\n if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);\n\n if (Unit.isUnit(persistenceUnit))\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n else\n this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);\n\n\n if (undefined !== kindOfQuantityProps.presentationUnits)\n await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setRelativeError(relativeError: number): void {\n this._relativeError = relativeError;\n }\n\n /**\n * Used for schema editing.\n * @internal\n */\n protected setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void {\n this._persistenceUnit = value;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns True if the item is a KindOfQuantity, false otherwise.\n */\n public static isKindOfQuantity(item?: SchemaItem): item is KindOfQuantity {\n if (item && item.schemaItemType === SchemaItemType.KindOfQuantity)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type KindOfQuantity.\n * @param item The SchemaItem to check.\n * @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.\n * @internal\n */\n public static assertIsKindOfQuantity(item?: SchemaItem): asserts item is KindOfQuantity {\n if (!this.isKindOfQuantity(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableKindOfQuantity extends KindOfQuantity {\n public abstract override addPresentationFormat(format: LazyLoadedFormat | OverrideFormat, isDefault: boolean): void;\n public abstract override createFormatOverride(parent: Format, precision?: number, unitLabelOverrides?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): OverrideFormat;\n public abstract override setDisplayLabel(displayLabel: string): void;\n public abstract override setPersistenceUnit(value: LazyLoadedUnit | LazyLoadedInvertedUnit | undefined): void;\n public abstract override setRelativeError(relativeError: number): void;\n}\n"]}
|