@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
|
@@ -8,47 +8,51 @@
|
|
|
8
8
|
import { DelayedPromiseWithProps } from "../DelayedPromise";
|
|
9
9
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
10
10
|
import { SchemaItemType } from "../ECObjects";
|
|
11
|
-
import {
|
|
11
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
12
12
|
import { Format } from "./Format";
|
|
13
13
|
import { InvertedUnit } from "./InvertedUnit";
|
|
14
14
|
import { OverrideFormat } from "./OverrideFormat";
|
|
15
15
|
import { SchemaItem } from "./SchemaItem";
|
|
16
16
|
import { Unit } from "./Unit";
|
|
17
17
|
/** A Typescript class representation of a KindOfQuantity.
|
|
18
|
-
* @
|
|
18
|
+
* @public @preview
|
|
19
19
|
*/
|
|
20
20
|
export class KindOfQuantity extends SchemaItem {
|
|
21
21
|
schemaItemType = KindOfQuantity.schemaItemType;
|
|
22
|
+
/** @internal */
|
|
22
23
|
static get schemaItemType() { return SchemaItemType.KindOfQuantity; }
|
|
23
24
|
_relativeError = 1.0;
|
|
24
|
-
_presentationFormats =
|
|
25
|
+
_presentationFormats = [];
|
|
25
26
|
_persistenceUnit;
|
|
26
27
|
/** The first presentation format in the list of Formats. */
|
|
27
28
|
get defaultPresentationFormat() { return this.presentationFormats[0]; }
|
|
28
29
|
/** A list of presentation formats. */
|
|
29
30
|
get presentationFormats() { return this._presentationFormats; }
|
|
31
|
+
/** Persistence unit */
|
|
30
32
|
get persistenceUnit() { return this._persistenceUnit; }
|
|
31
|
-
set persistenceUnit(value) { this._persistenceUnit = value; }
|
|
32
33
|
get relativeError() { return this._relativeError; }
|
|
33
34
|
/**
|
|
34
35
|
*
|
|
35
36
|
* @param format The Format to add to this KindOfQuantity
|
|
36
37
|
* @param isDefault
|
|
38
|
+
* @internal
|
|
37
39
|
*/
|
|
38
40
|
addPresentationFormat(format, isDefault = false) {
|
|
39
41
|
// TODO: Add some sort of validation?
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
40
43
|
(isDefault) ? this._presentationFormats.splice(0, 0, format) : this._presentationFormats.push(format);
|
|
41
44
|
}
|
|
42
45
|
/** Creates an OverrideFormat in the context of this KindOfQuantity.
|
|
43
46
|
* @param parent The Format to override.
|
|
44
47
|
* @param precision The precision override
|
|
45
48
|
* @param unitLabelOverrides The list of unit and label overrides.
|
|
49
|
+
* @internal
|
|
46
50
|
*/
|
|
47
51
|
createFormatOverride(parent, precision, unitLabelOverrides) {
|
|
48
52
|
if (unitLabelOverrides && parent.units && parent.units.length !== unitLabelOverrides.length)
|
|
49
|
-
throw new
|
|
53
|
+
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}'.`);
|
|
50
54
|
if (parent.units && 0 === parent.units.length && unitLabelOverrides && 0 < unitLabelOverrides.length)
|
|
51
|
-
throw new
|
|
55
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Cannot add a presentation format to KindOfQuantity '${this.name}' without any units and no unit overrides.`);
|
|
52
56
|
// TODO: Check compatibility of Unit overrides with the persistence unit
|
|
53
57
|
return new OverrideFormat(parent, precision, unitLabelOverrides);
|
|
54
58
|
}
|
|
@@ -58,21 +62,24 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
58
62
|
const presFormatOverride = OverrideFormat.parseFormatString(formatString);
|
|
59
63
|
const format = await this.schema.lookupItem(presFormatOverride.name, Format);
|
|
60
64
|
if (undefined === format || format.schemaItemType !== SchemaItemType.Format)
|
|
61
|
-
throw new
|
|
65
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
62
66
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
63
|
-
this.addPresentationFormat(format);
|
|
67
|
+
this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));
|
|
64
68
|
continue;
|
|
65
69
|
}
|
|
66
70
|
let unitAndLabels;
|
|
67
71
|
if (undefined !== presFormatOverride.unitAndLabels) {
|
|
68
72
|
if (4 < presFormatOverride.unitAndLabels.length)
|
|
69
|
-
throw new
|
|
73
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);
|
|
70
74
|
unitAndLabels = [];
|
|
71
75
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
72
76
|
const unitOrInverted = await this.schema.lookupItem(unitOverride[0]);
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
if (Unit.isUnit(unitOrInverted))
|
|
78
|
+
unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
79
|
+
else if (InvertedUnit.isInvertedUnit(unitOrInverted))
|
|
80
|
+
unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
81
|
+
else
|
|
82
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -85,21 +92,24 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
85
92
|
const presFormatOverride = OverrideFormat.parseFormatString(formatString);
|
|
86
93
|
const format = this.schema.lookupItemSync(presFormatOverride.name, Format);
|
|
87
94
|
if (undefined === format || format.schemaItemType !== SchemaItemType.Format)
|
|
88
|
-
throw new
|
|
95
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate Format '${presFormatOverride.name}' for the presentation unit on KindOfQuantity ${this.fullName}.`);
|
|
89
96
|
if (undefined === presFormatOverride.precision && undefined === presFormatOverride.unitAndLabels) {
|
|
90
|
-
this.addPresentationFormat(format);
|
|
97
|
+
this.addPresentationFormat(new DelayedPromiseWithProps(format.key, async () => format));
|
|
91
98
|
continue;
|
|
92
99
|
}
|
|
93
100
|
let unitAndLabels;
|
|
94
101
|
if (undefined !== presFormatOverride.unitAndLabels) {
|
|
95
102
|
if (4 < presFormatOverride.unitAndLabels.length)
|
|
96
|
-
throw new
|
|
103
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, ``);
|
|
97
104
|
unitAndLabels = [];
|
|
98
105
|
for (const unitOverride of presFormatOverride.unitAndLabels) {
|
|
99
106
|
const unitOrInverted = this.schema.lookupItemSync(unitOverride[0]);
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
if (Unit.isUnit(unitOrInverted))
|
|
108
|
+
unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
109
|
+
else if (InvertedUnit.isInvertedUnit(unitOrInverted))
|
|
110
|
+
unitAndLabels.push([new DelayedPromiseWithProps(unitOrInverted.key, async () => unitOrInverted), unitOverride[1]]);
|
|
111
|
+
else
|
|
112
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${unitOverride[0]}.`);
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
const overrideFormat = this.createFormatOverride(format, presFormatOverride.precision, unitAndLabels);
|
|
@@ -128,11 +138,16 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
128
138
|
itemElement.setAttribute("persistenceUnit", unitName);
|
|
129
139
|
}
|
|
130
140
|
if (undefined !== this.presentationFormats) {
|
|
131
|
-
const presUnitStrings =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
const presUnitStrings = [];
|
|
142
|
+
for (const format of this.presentationFormats) {
|
|
143
|
+
if (!OverrideFormat.isOverrideFormat(format)) {
|
|
144
|
+
const resolvedFormat = await format;
|
|
145
|
+
presUnitStrings.push(XmlSerializationUtils.createXmlTypedName(this.schema, resolvedFormat.schema, format.name));
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
presUnitStrings.push(format.fullNameXml(this.schema));
|
|
149
|
+
}
|
|
150
|
+
;
|
|
136
151
|
itemElement.setAttribute("presentationUnits", presUnitStrings.join(";"));
|
|
137
152
|
}
|
|
138
153
|
itemElement.setAttribute("relativeError", this.relativeError.toString());
|
|
@@ -143,9 +158,9 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
143
158
|
this._relativeError = kindOfQuantityProps.relativeError;
|
|
144
159
|
const persistenceUnit = this.schema.lookupItemSync(kindOfQuantityProps.persistenceUnit);
|
|
145
160
|
if (undefined === persistenceUnit)
|
|
146
|
-
throw new
|
|
161
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
147
162
|
if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
148
|
-
throw new
|
|
163
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
149
164
|
if (Unit.isUnit(persistenceUnit))
|
|
150
165
|
this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
151
166
|
else
|
|
@@ -158,9 +173,9 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
158
173
|
this._relativeError = kindOfQuantityProps.relativeError;
|
|
159
174
|
const persistenceUnit = await this.schema.lookupItem(kindOfQuantityProps.persistenceUnit);
|
|
160
175
|
if (undefined === persistenceUnit)
|
|
161
|
-
throw new
|
|
176
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${kindOfQuantityProps.persistenceUnit} does not exist.`);
|
|
162
177
|
if (!Unit.isUnit(persistenceUnit) && !InvertedUnit.isInvertedUnit(persistenceUnit))
|
|
163
|
-
throw new
|
|
178
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The item ${kindOfQuantityProps.persistenceUnit} is not a Unit or InvertedUnit.`);
|
|
164
179
|
if (Unit.isUnit(persistenceUnit))
|
|
165
180
|
this._persistenceUnit = new DelayedPromiseWithProps(persistenceUnit.key, async () => persistenceUnit);
|
|
166
181
|
else
|
|
@@ -169,28 +184,38 @@ export class KindOfQuantity extends SchemaItem {
|
|
|
169
184
|
await this.processPresentationUnits(kindOfQuantityProps.presentationUnits);
|
|
170
185
|
}
|
|
171
186
|
/**
|
|
172
|
-
* @alpha
|
|
173
187
|
* Used for schema editing.
|
|
188
|
+
* @internal
|
|
174
189
|
*/
|
|
175
190
|
setRelativeError(relativeError) {
|
|
176
191
|
this._relativeError = relativeError;
|
|
177
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Used for schema editing.
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
setPersistenceUnit(value) {
|
|
198
|
+
this._persistenceUnit = value;
|
|
199
|
+
}
|
|
178
200
|
/**
|
|
179
201
|
* Type guard to check if the SchemaItem is of type KindOfQuantity.
|
|
180
202
|
* @param item The SchemaItem to check.
|
|
181
203
|
* @returns True if the item is a KindOfQuantity, false otherwise.
|
|
182
204
|
*/
|
|
183
205
|
static isKindOfQuantity(item) {
|
|
184
|
-
|
|
206
|
+
if (item && item.schemaItemType === SchemaItemType.KindOfQuantity)
|
|
207
|
+
return true;
|
|
208
|
+
return false;
|
|
185
209
|
}
|
|
186
210
|
/**
|
|
187
211
|
* Type assertion to check if the SchemaItem is of type KindOfQuantity.
|
|
188
212
|
* @param item The SchemaItem to check.
|
|
189
213
|
* @returns The item cast to KindOfQuantity if it is a KindOfQuantity, undefined otherwise.
|
|
214
|
+
* @internal
|
|
190
215
|
*/
|
|
191
216
|
static assertIsKindOfQuantity(item) {
|
|
192
217
|
if (!this.isKindOfQuantity(item))
|
|
193
|
-
throw new
|
|
218
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.KindOfQuantity}' (KindOfQuantity)`);
|
|
194
219
|
}
|
|
195
220
|
}
|
|
196
221
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantity.js","sourceRoot":"","sources":["../../../src/Metadata/KindOfQuantity.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;AAE/D,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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IACnB,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;IACjE,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3E,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAAmC,IAAI,KAAK,EAA2B,CAAC;IAC5F,gBAAgB,CAA2C;IAErE,4DAA4D;IAC5D,IAAW,yBAAyB,KAA0C,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnH,sCAAsC;IACtC,IAAW,mBAAmB,KAAqC,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAA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CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IACpI,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,cAAc;CAIjE","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,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,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,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C9B,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,cAAc,oBAAoB,CAAC,CAAC;IAClI,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,cAAc;CAMjE","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"]}
|
|
@@ -12,24 +12,36 @@ import { Schema } from "./Schema";
|
|
|
12
12
|
import { SchemaItem } from "./SchemaItem";
|
|
13
13
|
/**
|
|
14
14
|
* A Typescript class representation of a Mixin.
|
|
15
|
-
* @
|
|
15
|
+
* @public @preview
|
|
16
16
|
*/
|
|
17
17
|
export declare class Mixin extends ECClass {
|
|
18
18
|
readonly schemaItemType: SchemaItemType;
|
|
19
|
+
/** @internal */
|
|
19
20
|
static get schemaItemType(): SchemaItemType;
|
|
20
|
-
|
|
21
|
+
private _appliesTo?;
|
|
21
22
|
get appliesTo(): LazyLoadedEntityClass | undefined;
|
|
23
|
+
/** @internal */
|
|
22
24
|
constructor(schema: Schema, name: string);
|
|
23
25
|
/**
|
|
24
26
|
*
|
|
25
27
|
* @param name
|
|
26
28
|
* @param relationship
|
|
27
29
|
* @param direction
|
|
30
|
+
* @internal
|
|
28
31
|
*/
|
|
29
32
|
protected createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param name
|
|
36
|
+
* @param relationship
|
|
37
|
+
* @param direction
|
|
38
|
+
* @returns
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
30
42
|
protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
|
|
31
43
|
/**
|
|
32
|
-
* @
|
|
44
|
+
* @internal
|
|
33
45
|
*/
|
|
34
46
|
protected setAppliesTo(appliesTo: LazyLoadedEntityClass): void;
|
|
35
47
|
/**
|
|
@@ -53,6 +65,7 @@ export declare class Mixin extends ECClass {
|
|
|
53
65
|
* Type assertion to check if the SchemaItem is of type Mixin.
|
|
54
66
|
* @param item The SchemaItem to check.
|
|
55
67
|
* @returns The item cast to Mixin if it is a Mixin, undefined otherwise.
|
|
68
|
+
* @internal
|
|
56
69
|
*/
|
|
57
70
|
static assertIsMixin(item?: SchemaItem): asserts item is Mixin;
|
|
58
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mixin.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAmB,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAA0D,WAAW,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,qBAAa,KAAM,SAAQ,OAAO;IAChC,SAAyB,cAAc,iBAAwB;IAC/D,WAA2B,cAAc,mBAAmC;IAC5E,
|
|
1
|
+
{"version":3,"file":"Mixin.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAmB,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAA0D,WAAW,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,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ACH,8BAAsB,YAAa,SAAQ,KAAK;aACrB,YAAY,CAAC,WAAW,EAAE,qBAAqB,GAAG,IAAI;aACtD,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;aACpJ,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -8,20 +8,22 @@
|
|
|
8
8
|
import { DelayedPromiseWithProps } from "../DelayedPromise";
|
|
9
9
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
10
10
|
import { ECClassModifier, SchemaItemType } from "../ECObjects";
|
|
11
|
-
import {
|
|
11
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
12
12
|
import { ECClass } from "./Class";
|
|
13
13
|
import { createNavigationProperty, createNavigationPropertySync, EntityClass } from "./EntityClass";
|
|
14
14
|
/**
|
|
15
15
|
* A Typescript class representation of a Mixin.
|
|
16
|
-
* @
|
|
16
|
+
* @public @preview
|
|
17
17
|
*/
|
|
18
18
|
export class Mixin extends ECClass {
|
|
19
19
|
schemaItemType = Mixin.schemaItemType;
|
|
20
|
+
/** @internal */
|
|
20
21
|
static get schemaItemType() { return SchemaItemType.Mixin; }
|
|
21
22
|
_appliesTo;
|
|
22
23
|
get appliesTo() {
|
|
23
24
|
return this._appliesTo;
|
|
24
25
|
}
|
|
26
|
+
/** @internal */
|
|
25
27
|
constructor(schema, name) {
|
|
26
28
|
super(schema, name, ECClassModifier.Abstract);
|
|
27
29
|
}
|
|
@@ -30,15 +32,25 @@ export class Mixin extends ECClass {
|
|
|
30
32
|
* @param name
|
|
31
33
|
* @param relationship
|
|
32
34
|
* @param direction
|
|
35
|
+
* @internal
|
|
33
36
|
*/
|
|
34
37
|
async createNavigationProperty(name, relationship, direction) {
|
|
35
38
|
return this.addProperty(await createNavigationProperty(this, name, relationship, direction));
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param name
|
|
43
|
+
* @param relationship
|
|
44
|
+
* @param direction
|
|
45
|
+
* @returns
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
37
49
|
createNavigationPropertySync(name, relationship, direction) {
|
|
38
50
|
return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
|
-
* @
|
|
53
|
+
* @internal
|
|
42
54
|
*/
|
|
43
55
|
setAppliesTo(appliesTo) {
|
|
44
56
|
this._appliesTo = appliesTo;
|
|
@@ -82,11 +94,11 @@ export class Mixin extends ECClass {
|
|
|
82
94
|
super.fromJSONSync(mixinProps);
|
|
83
95
|
const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);
|
|
84
96
|
if (!entityClassSchemaItemKey)
|
|
85
|
-
throw new
|
|
97
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
|
|
86
98
|
this._appliesTo = new DelayedPromiseWithProps(entityClassSchemaItemKey, async () => {
|
|
87
99
|
const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey, EntityClass);
|
|
88
100
|
if (undefined === appliesTo)
|
|
89
|
-
throw new
|
|
101
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);
|
|
90
102
|
return appliesTo;
|
|
91
103
|
});
|
|
92
104
|
}
|
|
@@ -95,10 +107,10 @@ export class Mixin extends ECClass {
|
|
|
95
107
|
}
|
|
96
108
|
async applicableTo(entityClass) {
|
|
97
109
|
if (!this.appliesTo)
|
|
98
|
-
throw new
|
|
110
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);
|
|
99
111
|
const appliesTo = await this.appliesTo;
|
|
100
112
|
if (appliesTo === undefined)
|
|
101
|
-
throw new
|
|
113
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);
|
|
102
114
|
return appliesTo.is(entityClass);
|
|
103
115
|
}
|
|
104
116
|
/**
|
|
@@ -115,10 +127,11 @@ export class Mixin extends ECClass {
|
|
|
115
127
|
* Type assertion to check if the SchemaItem is of type Mixin.
|
|
116
128
|
* @param item The SchemaItem to check.
|
|
117
129
|
* @returns The item cast to Mixin if it is a Mixin, undefined otherwise.
|
|
130
|
+
* @internal
|
|
118
131
|
*/
|
|
119
132
|
static assertIsMixin(item) {
|
|
120
133
|
if (!this.isMixin(item))
|
|
121
|
-
throw new
|
|
134
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Mixin}' (Mixin)`);
|
|
122
135
|
}
|
|
123
136
|
}
|
|
124
137
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../../src/Metadata/Mixin.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,eAAe,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAMpG;;;GAGG;AACH,MAAM,OAAO,KAAM,SAAQ,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AAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,KAAK,WAAW,CAAC,CAAC;IAClH,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,YAAa,SAAQ,KAAK;CAK/C","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { MixinProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\nimport { NavigationProperty } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of a Mixin.\n * @beta\n */\nexport class Mixin extends ECClass {\n public override readonly schemaItemType = Mixin.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.Mixin; }\n protected _appliesTo?: LazyLoadedEntityClass;\n\n public get appliesTo(): LazyLoadedEntityClass | undefined {\n return this._appliesTo;\n }\n\n constructor(schema: Schema, name: string) {\n super(schema, name, ECClassModifier.Abstract);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * @alpha Used for schema editing.\n */\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\n this._appliesTo = appliesTo;\n }\n /**\n * Save this Mixin's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (undefined !== this.appliesTo) {\n schemaJson.appliesTo = this.appliesTo.fullName;\n }\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\n // already exist for this item before creating a new one to apply IsMixin\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\n if (undefined !== coreCustomSchema) {\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\n isMixinElement.setAttribute(\"xmlns\", xmlns);\n }\n\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\n const appliesTo = await this.appliesTo;\n if (undefined !== appliesTo) {\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\n appliesToElement.textContent = appliesToName;\n isMixinElement.appendChild(appliesToElement);\n }\n\n customAttributes.appendChild(isMixinElement);\n itemElement.appendChild(customAttributes);\n\n return itemElement;\n }\n\n public override fromJSONSync(mixinProps: MixinProps) {\n super.fromJSONSync(mixinProps);\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\n if (!entityClassSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\n async () => {\n const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey, EntityClass);\n if (undefined === appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n return appliesTo;\n });\n }\n\n public override async fromJSON(mixinProps: MixinProps) {\n this.fromJSONSync(mixinProps);\n }\n\n public async applicableTo(entityClass: EntityClass) {\n if (!this.appliesTo)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\n\n const appliesTo = await this.appliesTo;\n if (appliesTo === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\n\n return appliesTo.is(entityClass);\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Mixin.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Mixin, false otherwise.\n */\n public static isMixin(item?: SchemaItem): item is Mixin {\n if (item && item.schemaItemType === SchemaItemType.Mixin)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Mixin.\n * @param item The SchemaItem to check.\n * @returns The item cast to Mixin if it is a Mixin, undefined otherwise.\n */\n public static assertIsMixin(item?: SchemaItem): asserts item is Mixin {\n if (!this.isMixin(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Mixin}' (Mixin)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableMixin extends Mixin {\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Mixin.js","sourceRoot":"","sources":["../../../src/Metadata/Mixin.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAMpG;;;GAGG;AACH,MAAM,OAAO,KAAM,SAAQ,OAAO;IACP,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;IAC/D,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,UAAU,CAAyB;IAE3C,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,gBAAgB;IAChB,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,wBAAwB,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QACpI,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC/F,CAAC;IAED;;;;;;;;OAQG;IACO,4BAA4B,CAAC,IAAY,EAAE,YAAwC,EAAE,SAAqC;QAClI,OAAO,IAAI,CAAC,W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C,IAAI,CAAC,SAAS;YACjB,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,uCAAuC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAE/G,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;QACvC,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,kCAAkC,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC;QAEpH,OAAO,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,IAAiB;QACrC,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,KAAK;YACtD,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,KAAK,WAAW,CAAC,CAAC;IAChH,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,YAAa,SAAQ,KAAK;CAK/C","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { MixinProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { ECClassModifier, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { LazyLoadedEntityClass } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { createNavigationProperty, createNavigationPropertySync, EntityClass } from \"./EntityClass\";\nimport { NavigationProperty } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { Schema } from \"./Schema\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of a Mixin.\n * @public @preview\n */\nexport class Mixin extends ECClass {\n public override readonly schemaItemType = Mixin.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.Mixin; }\n private _appliesTo?: LazyLoadedEntityClass;\n\n public get appliesTo(): LazyLoadedEntityClass | undefined {\n return this._appliesTo;\n }\n\n /** @internal */\n constructor(schema: Schema, name: string) {\n super(schema, name, ECClassModifier.Abstract);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @returns\n *\n * @internal\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * @internal\n */\n protected setAppliesTo(appliesTo: LazyLoadedEntityClass) {\n this._appliesTo = appliesTo;\n }\n\n /**\n * Save this Mixin's properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): MixinProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (undefined !== this.appliesTo) {\n schemaJson.appliesTo = this.appliesTo.fullName;\n }\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n // When CustomAttributes are added, there must be a check to see if the ECCustomAttributes\n // already exist for this item before creating a new one to apply IsMixin\n const customAttributes = schemaXml.createElement(\"ECCustomAttributes\");\n const isMixinElement = schemaXml.createElement(\"IsMixin\");\n const coreCustomSchema = this.schema.getReferenceSync(\"CoreCustomAttributes\");\n if (undefined !== coreCustomSchema) {\n const xmlns = `CoreCustomAttributes.${coreCustomSchema.schemaKey.version.toString()}`;\n isMixinElement.setAttribute(\"xmlns\", xmlns);\n }\n\n const appliesToElement = schemaXml.createElement(\"AppliesToEntityClass\");\n const appliesTo = await this.appliesTo;\n if (undefined !== appliesTo) {\n const appliesToName = XmlSerializationUtils.createXmlTypedName(this.schema, appliesTo.schema, appliesTo.name);\n appliesToElement.textContent = appliesToName;\n isMixinElement.appendChild(appliesToElement);\n }\n\n customAttributes.appendChild(isMixinElement);\n itemElement.appendChild(customAttributes);\n\n return itemElement;\n }\n\n public override fromJSONSync(mixinProps: MixinProps) {\n super.fromJSONSync(mixinProps);\n const entityClassSchemaItemKey = this.schema.getSchemaItemKey(mixinProps.appliesTo);\n if (!entityClassSchemaItemKey)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n this._appliesTo = new DelayedPromiseWithProps<SchemaItemKey, EntityClass>(entityClassSchemaItemKey,\n async () => {\n const appliesTo = await this.schema.lookupItem(entityClassSchemaItemKey, EntityClass);\n if (undefined === appliesTo)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the appliesTo ${mixinProps.appliesTo}.`);\n return appliesTo;\n });\n }\n\n public override async fromJSON(mixinProps: MixinProps) {\n this.fromJSONSync(mixinProps);\n }\n\n public async applicableTo(entityClass: EntityClass) {\n if (!this.appliesTo)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `appliesTo is undefined in the class ${this.fullName}.`);\n\n const appliesTo = await this.appliesTo;\n if (appliesTo === undefined)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `Unable to locate the appliesTo ${this.appliesTo.fullName}.`);\n\n return appliesTo.is(entityClass);\n }\n\n /**\n * Type guard to check if the SchemaItem is of type Mixin.\n * @param item The SchemaItem to check.\n * @returns True if the item is a Mixin, false otherwise.\n */\n public static isMixin(item?: SchemaItem): item is Mixin {\n if (item && item.schemaItemType === SchemaItemType.Mixin)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type Mixin.\n * @param item The SchemaItem to check.\n * @returns The item cast to Mixin if it is a Mixin, undefined otherwise.\n * @internal\n */\n public static assertIsMixin(item?: SchemaItem): asserts item is Mixin {\n if (!this.isMixin(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Mixin}' (Mixin)`);\n }\n}\n/**\n * @internal\n * An abstract class used for schema editing.\n */\nexport abstract class MutableMixin extends Mixin {\n public abstract override setAppliesTo(entityClass: LazyLoadedEntityClass): void;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -3,21 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { DecimalPrecision, FormatProps, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from "@itwin/core-quantity";
|
|
5
5
|
import { Format } from "./Format";
|
|
6
|
-
import { InvertedUnit } from "./InvertedUnit";
|
|
7
6
|
import { Schema } from "./Schema";
|
|
8
7
|
import { SchemaItemOverrideFormatProps } from "../Deserialization/JsonProps";
|
|
9
|
-
import {
|
|
8
|
+
import { LazyLoadedInvertedUnit, LazyLoadedUnit } from "../Interfaces";
|
|
10
9
|
/**
|
|
11
|
-
* @
|
|
10
|
+
* @public @preview
|
|
12
11
|
*/
|
|
13
12
|
export interface OverrideFormatProps {
|
|
14
|
-
name: string;
|
|
15
|
-
precision?: number;
|
|
16
|
-
unitAndLabels?: Array<[string, string | undefined]>;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly precision?: number;
|
|
15
|
+
readonly unitAndLabels?: Array<[string, string | undefined]>;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
18
|
* Overrides of a Format, from a Schema, and is SchemaItem that is used specifically on KindOfQuantity.
|
|
20
|
-
* @
|
|
19
|
+
* @public @preview
|
|
21
20
|
*/
|
|
22
21
|
export declare class OverrideFormat {
|
|
23
22
|
private _precision?;
|
|
@@ -29,9 +28,10 @@ export declare class OverrideFormat {
|
|
|
29
28
|
* This should be set to the [FormatString]($docs/bis/ec/kindofquantity/#format-string) which represents the format override.
|
|
30
29
|
*/
|
|
31
30
|
readonly name: string;
|
|
32
|
-
|
|
31
|
+
/** @internal */
|
|
32
|
+
constructor(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>);
|
|
33
33
|
get precision(): DecimalPrecision | FractionalPrecision;
|
|
34
|
-
get units(): [
|
|
34
|
+
get units(): ReadonlyArray<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;
|
|
35
35
|
get fullName(): string;
|
|
36
36
|
get roundFactor(): number;
|
|
37
37
|
get type(): FormatType;
|
|
@@ -48,7 +48,7 @@ export declare class OverrideFormat {
|
|
|
48
48
|
get includeZero(): boolean | undefined;
|
|
49
49
|
hasFormatTrait(formatTrait: FormatTraits): boolean;
|
|
50
50
|
/** Returns the format string of this override in the Xml full name format.
|
|
51
|
-
* @
|
|
51
|
+
* @internal
|
|
52
52
|
*/
|
|
53
53
|
fullNameXml(koqSchema: Schema): string;
|
|
54
54
|
/**
|
|
@@ -56,7 +56,7 @@ export declare class OverrideFormat {
|
|
|
56
56
|
* @param parent The parent Format.
|
|
57
57
|
* @param unitAndLabels The overridden unit and labels collection.
|
|
58
58
|
*/
|
|
59
|
-
static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[
|
|
59
|
+
static createOverrideFormatFullName(parent: Format, precision?: DecimalPrecision | FractionalPrecision, unitAndLabels?: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]>): string;
|
|
60
60
|
/** Parses the format string into the parts that make up an Override Format
|
|
61
61
|
* @param formatString
|
|
62
62
|
*/
|
|
@@ -64,7 +64,7 @@ export declare class OverrideFormat {
|
|
|
64
64
|
/**
|
|
65
65
|
* @internal
|
|
66
66
|
*/
|
|
67
|
-
static isOverrideFormat(
|
|
67
|
+
static isOverrideFormat(format: unknown): format is OverrideFormat;
|
|
68
68
|
/**
|
|
69
69
|
* Returns a JSON object that contains the specification for the OverrideFormat where the precision and units properties have been overriden.
|
|
70
70
|
* If the precision and/or units properties have been overriden, the returned object will contain a "name" and a "parent" property.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverrideFormat.d.ts","sourceRoot":"","sources":["../../../src/Metadata/OverrideFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAmB,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrK,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OverrideFormat.d.ts","sourceRoot":"","sources":["../../../src/Metadata/OverrideFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAmB,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrK,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,6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