@itwin/ecschema-metadata 5.0.0-dev.11 → 5.0.0-dev.110
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 +61 -1
- package/lib/cjs/Constants.d.ts +8 -0
- package/lib/cjs/Constants.d.ts.map +1 -1
- package/lib/cjs/Constants.js +30 -21
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +85 -36
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +79 -29
- 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 +8 -6
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js +1 -0
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts +3 -3
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +35 -26
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +153 -150
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +47 -33
- 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.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +60 -52
- 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 +8 -17
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.d.ts +2 -2
- package/lib/cjs/ECName.js +5 -4
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +41 -9
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +78 -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 +61 -60
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +35 -32
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +179 -32
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +290 -88
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +26 -10
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +38 -10
- 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 +21 -7
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +28 -8
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +40 -11
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +72 -34
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +30 -10
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +41 -13
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +65 -17
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +107 -22
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +19 -10
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +32 -15
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +38 -18
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +90 -40
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +31 -4
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +42 -8
- 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 +36 -19
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +24 -3
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +32 -3
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +47 -25
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +128 -49
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +20 -4
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +31 -4
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +63 -27
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +100 -43
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +167 -41
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +211 -111
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +19 -19
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +23 -21
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +24 -21
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +40 -24
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +17 -4
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +24 -4
- 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 +8 -8
- package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js +7 -7
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +13 -7
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +22 -12
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +5 -5
- package/lib/cjs/SchemaLoader.d.ts.map +1 -1
- package/lib/cjs/SchemaLoader.js +5 -4
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/cjs/SchemaPartVisitorDelegate.js +2 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js +69 -65
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js +11 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js +6 -4
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +1 -0
- 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 +5 -6
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.d.ts +8 -0
- package/lib/esm/Constants.d.ts.map +1 -1
- package/lib/esm/Constants.js +29 -20
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Context.d.ts +85 -36
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +78 -28
- 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 +8 -6
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js +1 -0
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts +3 -3
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +36 -27
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +154 -151
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +47 -33
- 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.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +61 -53
- 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 +9 -18
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.d.ts +2 -2
- package/lib/esm/ECName.js +6 -5
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +41 -9
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +77 -24
- 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 +59 -58
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +35 -32
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +179 -32
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +292 -90
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +26 -10
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +39 -11
- 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 +21 -7
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +29 -9
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +40 -11
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +73 -35
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +30 -10
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +42 -14
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +65 -17
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +108 -23
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +19 -10
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +33 -16
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +38 -18
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +91 -41
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +31 -4
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +44 -10
- 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 +37 -20
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +24 -3
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +33 -4
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +47 -25
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +130 -51
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +20 -4
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +31 -4
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +63 -27
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +102 -45
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +167 -41
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +212 -112
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +19 -19
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +25 -23
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +24 -21
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +41 -25
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +17 -4
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +24 -4
- 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 +8 -8
- package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/esm/SchemaJsonLocater.js +7 -7
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +13 -7
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +23 -13
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +5 -5
- package/lib/esm/SchemaLoader.d.ts.map +1 -1
- package/lib/esm/SchemaLoader.js +6 -5
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/esm/SchemaPartVisitorDelegate.js +2 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js +69 -65
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js +9 -7
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js +2 -0
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js +11 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js +6 -4
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +1 -0
- 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 +6 -7
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +16 -14
|
@@ -8,23 +8,30 @@
|
|
|
8
8
|
import { assert } from "@itwin/core-bentley";
|
|
9
9
|
import { DelayedPromiseWithProps } from "../DelayedPromise";
|
|
10
10
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
11
|
-
import { classModifierToString, ECClassModifier, parseClassModifier, parsePrimitiveType, PrimitiveType, SchemaItemType } from "../ECObjects";
|
|
12
|
-
import {
|
|
11
|
+
import { AbstractSchemaItemType, classModifierToString, ECClassModifier, parseClassModifier, parsePrimitiveType, PrimitiveType, SchemaItemType } from "../ECObjects";
|
|
12
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
13
13
|
import { SchemaItemKey, SchemaKey } from "../SchemaKey";
|
|
14
14
|
import { serializeCustomAttributes } from "./CustomAttribute";
|
|
15
|
+
import { Enumeration } from "./Enumeration";
|
|
15
16
|
import { EnumerationArrayProperty, EnumerationProperty, PrimitiveArrayProperty, PrimitiveProperty, StructArrayProperty, StructProperty, } from "./Property";
|
|
16
17
|
import { SchemaItem } from "./SchemaItem";
|
|
17
18
|
import { SchemaReadHelper } from "../Deserialization/Helper";
|
|
18
19
|
/**
|
|
19
20
|
* A common abstract class for all of the ECClass types.
|
|
20
|
-
* @
|
|
21
|
+
* @public @preview
|
|
21
22
|
*/
|
|
22
23
|
export class ECClass extends SchemaItem {
|
|
24
|
+
/** @internal */
|
|
25
|
+
static get schemaItemType() { return AbstractSchemaItemType.Class; } // need this so getItem("name", ECClass) in schema works
|
|
26
|
+
_modifier;
|
|
27
|
+
_baseClass;
|
|
28
|
+
_derivedClasses;
|
|
29
|
+
_properties;
|
|
30
|
+
_customAttributes;
|
|
31
|
+
_mergedPropertyCache;
|
|
23
32
|
get modifier() { return this._modifier; }
|
|
24
|
-
get baseClass() { return this._baseClass; }
|
|
25
|
-
set baseClass(baseClass) { this._baseClass = baseClass; }
|
|
26
|
-
get properties() { return this._properties?.values(); }
|
|
27
33
|
get customAttributes() { return this._customAttributes; }
|
|
34
|
+
/** @internal */
|
|
28
35
|
constructor(schema, name, modifier) {
|
|
29
36
|
super(schema, name);
|
|
30
37
|
if (modifier)
|
|
@@ -32,75 +39,113 @@ export class ECClass extends SchemaItem {
|
|
|
32
39
|
else
|
|
33
40
|
this._modifier = ECClassModifier.None;
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Gets the base class if it exists, otherwise returns undefined.
|
|
44
|
+
*/
|
|
45
|
+
get baseClass() {
|
|
46
|
+
return this._baseClass;
|
|
47
|
+
}
|
|
48
|
+
getBaseClassSync() {
|
|
49
|
+
if (!this.baseClass) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return this.schema.lookupItemSync(this.baseClass, ECClass);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Sets the base class of the ECClass. Pass undefined to 'remove' the base class.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
async setBaseClass(baseClass) {
|
|
60
|
+
const oldBaseClass = this._baseClass;
|
|
61
|
+
this._baseClass = baseClass;
|
|
62
|
+
if (baseClass)
|
|
63
|
+
this.addDerivedClass(await baseClass, this);
|
|
64
|
+
else if (oldBaseClass)
|
|
65
|
+
this.removeDerivedClass(await oldBaseClass, this);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets the derived classes belonging to this class.
|
|
69
|
+
* @returns An array of ECClasses or undefined if no derived classes exist.
|
|
70
|
+
*/
|
|
71
|
+
async getDerivedClasses() {
|
|
72
|
+
if (!this._derivedClasses || this._derivedClasses.size === 0)
|
|
73
|
+
return undefined;
|
|
74
|
+
return Array.from(await Promise.all(this._derivedClasses.values()));
|
|
75
|
+
}
|
|
35
76
|
/**
|
|
36
77
|
* Convenience method for adding an already loaded ECProperty used by create*Property methods.
|
|
37
78
|
* @param prop The property to add.
|
|
38
79
|
* @return The property that was added.
|
|
80
|
+
*
|
|
81
|
+
* @internal
|
|
39
82
|
*/
|
|
40
83
|
addProperty(prop) {
|
|
41
84
|
if (!this._properties)
|
|
42
85
|
this._properties = new Map();
|
|
43
86
|
this._properties.set(prop.name.toUpperCase(), prop);
|
|
87
|
+
this.cleanCache();
|
|
44
88
|
return prop;
|
|
45
89
|
}
|
|
46
90
|
/**
|
|
47
91
|
* Deletes a property from within this class.
|
|
48
92
|
* @param name The property name to delete, lookup is case-insensitive
|
|
49
|
-
* @
|
|
93
|
+
* @internal
|
|
50
94
|
*/
|
|
51
95
|
async deleteProperty(name) {
|
|
52
96
|
if (this._properties) {
|
|
53
97
|
const property = await this.getProperty(name);
|
|
54
|
-
if (property)
|
|
98
|
+
if (property) {
|
|
55
99
|
this._properties.delete(name.toUpperCase());
|
|
100
|
+
this.cleanCache();
|
|
101
|
+
}
|
|
56
102
|
}
|
|
57
103
|
}
|
|
58
104
|
/**
|
|
59
105
|
* Deletes a property from within this class.
|
|
60
106
|
* @param name The property name to delete, lookup is case-insensitive
|
|
61
|
-
* @
|
|
107
|
+
* @internal
|
|
62
108
|
*/
|
|
63
109
|
deletePropertySync(name) {
|
|
64
110
|
if (this._properties) {
|
|
65
111
|
const property = this.getPropertySync(name);
|
|
66
|
-
if (property)
|
|
112
|
+
if (property) {
|
|
67
113
|
this._properties.delete(name.toUpperCase());
|
|
114
|
+
this.cleanCache();
|
|
115
|
+
}
|
|
68
116
|
}
|
|
69
117
|
}
|
|
70
|
-
getBaseClassSync() {
|
|
71
|
-
if (!this.baseClass) {
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
return this.schema.lookupItemSync(this.baseClass);
|
|
75
|
-
}
|
|
76
118
|
/**
|
|
77
|
-
* Searches, case-insensitive, for
|
|
78
|
-
*
|
|
119
|
+
* Searches, case-insensitive, for an ECProperty with given the name on this class and, by default, on
|
|
120
|
+
* all base classes. Set excludeInherited to 'true' to only search the local class.
|
|
121
|
+
* @param name The name of the property to retrieve.
|
|
122
|
+
* @param excludeInherited If true, excludes inherited properties from the results. Defaults to false.
|
|
79
123
|
*/
|
|
80
|
-
async getProperty(name,
|
|
124
|
+
async getProperty(name, excludeInherited = false) {
|
|
81
125
|
if (this._properties) {
|
|
82
126
|
const upperKey = name.toUpperCase();
|
|
83
127
|
const property = this._properties.get(upperKey);
|
|
84
128
|
if (property)
|
|
85
129
|
return property;
|
|
86
130
|
}
|
|
87
|
-
if (
|
|
131
|
+
if (excludeInherited) {
|
|
88
132
|
return undefined;
|
|
89
133
|
}
|
|
90
134
|
return this.getInheritedProperty(name);
|
|
91
135
|
}
|
|
92
136
|
/**
|
|
93
137
|
* Searches, case-insensitive, for a local ECProperty with the name provided.
|
|
94
|
-
* @param name
|
|
138
|
+
* @param name The name of the property to retrieve.
|
|
139
|
+
* @param excludeInherited If true, excludes inherited properties from the results. Defaults to false.
|
|
95
140
|
*/
|
|
96
|
-
getPropertySync(name,
|
|
141
|
+
getPropertySync(name, excludeInherited = false) {
|
|
97
142
|
if (this._properties) {
|
|
98
143
|
const upperKey = name.toUpperCase();
|
|
99
144
|
const property = this._properties.get(upperKey);
|
|
100
145
|
if (property)
|
|
101
146
|
return property;
|
|
102
147
|
}
|
|
103
|
-
if (
|
|
148
|
+
if (excludeInherited) {
|
|
104
149
|
return undefined;
|
|
105
150
|
}
|
|
106
151
|
return this.getInheritedPropertySync(name);
|
|
@@ -112,7 +157,7 @@ export class ECClass extends SchemaItem {
|
|
|
112
157
|
async getInheritedProperty(name) {
|
|
113
158
|
if (this.baseClass) {
|
|
114
159
|
const baseClassObj = await this.baseClass;
|
|
115
|
-
return baseClassObj.getProperty(name
|
|
160
|
+
return baseClassObj.getProperty(name);
|
|
116
161
|
}
|
|
117
162
|
return undefined;
|
|
118
163
|
}
|
|
@@ -123,36 +168,36 @@ export class ECClass extends SchemaItem {
|
|
|
123
168
|
getInheritedPropertySync(name) {
|
|
124
169
|
const baseClassObj = this.getBaseClassSync();
|
|
125
170
|
if (baseClassObj)
|
|
126
|
-
return baseClassObj.getPropertySync(name
|
|
171
|
+
return baseClassObj.getPropertySync(name);
|
|
127
172
|
return undefined;
|
|
128
173
|
}
|
|
129
174
|
async createPrimitiveProperty(name, primitiveType) {
|
|
130
|
-
if (await this.getProperty(name))
|
|
131
|
-
throw new
|
|
175
|
+
if (await this.getProperty(name, true))
|
|
176
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
132
177
|
const propType = await this.loadPrimitiveType(primitiveType, this.schema);
|
|
133
178
|
if (typeof (propType) === "number")
|
|
134
179
|
return this.addProperty(new PrimitiveProperty(this, name, propType));
|
|
135
180
|
return this.addProperty(new EnumerationProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));
|
|
136
181
|
}
|
|
137
182
|
createPrimitivePropertySync(name, primitiveType) {
|
|
138
|
-
if (this.getPropertySync(name))
|
|
139
|
-
throw new
|
|
183
|
+
if (this.getPropertySync(name, true))
|
|
184
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
140
185
|
const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);
|
|
141
186
|
if (typeof (propType) === "number")
|
|
142
187
|
return this.addProperty(new PrimitiveProperty(this, name, propType));
|
|
143
188
|
return this.addProperty(new EnumerationProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));
|
|
144
189
|
}
|
|
145
190
|
async createPrimitiveArrayProperty(name, primitiveType) {
|
|
146
|
-
if (await this.getProperty(name))
|
|
147
|
-
throw new
|
|
191
|
+
if (await this.getProperty(name, true))
|
|
192
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
148
193
|
const propType = await this.loadPrimitiveType(primitiveType, this.schema);
|
|
149
194
|
if (typeof (propType) === "number")
|
|
150
195
|
return this.addProperty(new PrimitiveArrayProperty(this, name, propType));
|
|
151
196
|
return this.addProperty(new EnumerationArrayProperty(this, name, new DelayedPromiseWithProps(propType.key, async () => propType)));
|
|
152
197
|
}
|
|
153
198
|
createPrimitiveArrayPropertySync(name, primitiveType) {
|
|
154
|
-
if (this.getPropertySync(name))
|
|
155
|
-
throw new
|
|
199
|
+
if (this.getPropertySync(name, true))
|
|
200
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
156
201
|
const propType = this.loadPrimitiveTypeSync(primitiveType, this.schema);
|
|
157
202
|
if (typeof (propType) === "number")
|
|
158
203
|
return this.addProperty(new PrimitiveArrayProperty(this, name, propType));
|
|
@@ -162,91 +207,131 @@ export class ECClass extends SchemaItem {
|
|
|
162
207
|
*
|
|
163
208
|
* @param name The name of property to create.
|
|
164
209
|
* @param structType The struct type of property to create.
|
|
210
|
+
*
|
|
211
|
+
* @internal
|
|
165
212
|
*/
|
|
166
213
|
async createStructProperty(name, structType) {
|
|
167
|
-
if (await this.getProperty(name))
|
|
168
|
-
throw new
|
|
214
|
+
if (await this.getProperty(name, true))
|
|
215
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
169
216
|
return this.addProperty(new StructProperty(this, name, await this.loadStructType(structType, this.schema)));
|
|
170
217
|
}
|
|
171
218
|
/**
|
|
172
219
|
*
|
|
173
220
|
* @param name The name of property to create.
|
|
174
221
|
* @param structType The struct type of property to create.
|
|
222
|
+
*
|
|
223
|
+
* @internal
|
|
175
224
|
*/
|
|
176
225
|
createStructPropertySync(name, structType) {
|
|
177
|
-
if (this.getPropertySync(name))
|
|
178
|
-
throw new
|
|
226
|
+
if (this.getPropertySync(name, true))
|
|
227
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
179
228
|
return this.addProperty(new StructProperty(this, name, this.loadStructTypeSync(structType, this.schema)));
|
|
180
229
|
}
|
|
181
230
|
/**
|
|
182
231
|
*
|
|
183
232
|
* @param name
|
|
184
233
|
* @param type
|
|
234
|
+
*
|
|
235
|
+
* @internal
|
|
185
236
|
*/
|
|
186
237
|
async createStructArrayProperty(name, structType) {
|
|
187
|
-
if (await this.getProperty(name))
|
|
188
|
-
throw new
|
|
238
|
+
if (await this.getProperty(name, true))
|
|
239
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
189
240
|
return this.addProperty(new StructArrayProperty(this, name, await this.loadStructType(structType, this.schema)));
|
|
190
241
|
}
|
|
191
242
|
/**
|
|
192
243
|
*
|
|
193
244
|
* @param name
|
|
194
245
|
* @param type
|
|
246
|
+
*
|
|
247
|
+
* @internal
|
|
195
248
|
*/
|
|
196
249
|
createStructArrayPropertySync(name, structType) {
|
|
197
|
-
if (this.getPropertySync(name))
|
|
198
|
-
throw new
|
|
250
|
+
if (this.getPropertySync(name, true))
|
|
251
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${this.name}.`);
|
|
199
252
|
return this.addProperty(new StructArrayProperty(this, name, this.loadStructTypeSync(structType, this.schema)));
|
|
200
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
*
|
|
256
|
+
* @param structType
|
|
257
|
+
* @param schema
|
|
258
|
+
* @returns
|
|
259
|
+
*
|
|
260
|
+
* @internal
|
|
261
|
+
*/
|
|
201
262
|
async loadStructType(structType, schema) {
|
|
202
263
|
let correctType;
|
|
203
264
|
if (typeof (structType) === "string") {
|
|
204
|
-
correctType = await schema.lookupItem(structType);
|
|
265
|
+
correctType = await schema.lookupItem(structType, StructClass);
|
|
205
266
|
}
|
|
206
267
|
else
|
|
207
268
|
correctType = structType;
|
|
208
269
|
if (!correctType)
|
|
209
|
-
throw new
|
|
270
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
|
|
210
271
|
return correctType;
|
|
211
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
*
|
|
275
|
+
* @param structType
|
|
276
|
+
* @param schema
|
|
277
|
+
* @returns
|
|
278
|
+
*
|
|
279
|
+
* @internal
|
|
280
|
+
*/
|
|
212
281
|
loadStructTypeSync(structType, schema) {
|
|
213
282
|
let correctType;
|
|
214
283
|
if (typeof (structType) === "string") {
|
|
215
|
-
correctType = schema.lookupItemSync(structType);
|
|
284
|
+
correctType = schema.lookupItemSync(structType, StructClass);
|
|
216
285
|
}
|
|
217
286
|
else
|
|
218
287
|
correctType = structType;
|
|
219
288
|
if (!correctType)
|
|
220
|
-
throw new
|
|
289
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
|
|
221
290
|
return correctType;
|
|
222
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
*
|
|
294
|
+
* @param primitiveType
|
|
295
|
+
* @param schema
|
|
296
|
+
* @returns
|
|
297
|
+
*
|
|
298
|
+
* @internal
|
|
299
|
+
*/
|
|
223
300
|
async loadPrimitiveType(primitiveType, schema) {
|
|
224
301
|
if (primitiveType === undefined)
|
|
225
302
|
return PrimitiveType.Integer;
|
|
226
303
|
if (typeof (primitiveType) === "string") {
|
|
227
304
|
let resolvedType = parsePrimitiveType(primitiveType);
|
|
228
305
|
if (!resolvedType) {
|
|
229
|
-
resolvedType = await schema.lookupItem(primitiveType);
|
|
306
|
+
resolvedType = await schema.lookupItem(primitiveType, Enumeration);
|
|
230
307
|
}
|
|
231
308
|
if (resolvedType === undefined)
|
|
232
|
-
throw new
|
|
309
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
|
|
233
310
|
// If resolvedType is a SchemaItem, make sure it is an Enumeration- if not, throw an error
|
|
234
311
|
if (typeof (resolvedType) !== "number" && resolvedType.schemaItemType !== SchemaItemType.Enumeration)
|
|
235
|
-
throw new
|
|
312
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
|
|
236
313
|
return resolvedType;
|
|
237
314
|
}
|
|
238
315
|
return primitiveType;
|
|
239
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
* @param primitiveType
|
|
320
|
+
* @param schema
|
|
321
|
+
* @returns
|
|
322
|
+
*
|
|
323
|
+
* @internal
|
|
324
|
+
*/
|
|
240
325
|
loadPrimitiveTypeSync(primitiveType, schema) {
|
|
241
326
|
if (primitiveType === undefined)
|
|
242
327
|
return PrimitiveType.Integer;
|
|
243
328
|
if (typeof (primitiveType) === "string") {
|
|
244
329
|
let resolvedType = parsePrimitiveType(primitiveType);
|
|
245
330
|
if (!resolvedType) {
|
|
246
|
-
resolvedType = schema.lookupItemSync(primitiveType);
|
|
331
|
+
resolvedType = schema.lookupItemSync(primitiveType, Enumeration);
|
|
247
332
|
}
|
|
248
333
|
if (resolvedType === undefined)
|
|
249
|
-
throw new
|
|
334
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided primitive type, ${primitiveType}, is not a valid PrimitiveType or Enumeration.`);
|
|
250
335
|
return resolvedType;
|
|
251
336
|
}
|
|
252
337
|
return primitiveType;
|
|
@@ -265,7 +350,7 @@ export class ECClass extends SchemaItem {
|
|
|
265
350
|
if (this.baseClass !== undefined)
|
|
266
351
|
schemaJson.baseClass = this.baseClass.fullName;
|
|
267
352
|
if (this._properties !== undefined && this._properties.size > 0)
|
|
268
|
-
schemaJson.properties = [...this.
|
|
353
|
+
schemaJson.properties = [...this._properties.values()].map((prop) => prop.toJSON());
|
|
269
354
|
const customAttributes = serializeCustomAttributes(this.customAttributes);
|
|
270
355
|
if (customAttributes !== undefined)
|
|
271
356
|
schemaJson.customAttributes = customAttributes;
|
|
@@ -283,8 +368,8 @@ export class ECClass extends SchemaItem {
|
|
|
283
368
|
baseClassElement.textContent = baseClassName;
|
|
284
369
|
itemElement.appendChild(baseClassElement);
|
|
285
370
|
}
|
|
286
|
-
if (undefined !== this.
|
|
287
|
-
for (const prop of this.
|
|
371
|
+
if (undefined !== this._properties) {
|
|
372
|
+
for (const prop of this._properties.values()) {
|
|
288
373
|
const propXml = await prop.toXml(schemaXml);
|
|
289
374
|
itemElement.appendChild(propXml);
|
|
290
375
|
}
|
|
@@ -307,7 +392,7 @@ export class ECClass extends SchemaItem {
|
|
|
307
392
|
if (SchemaReadHelper.isECSpecVersionNewer({ readVersion: classProps.originalECSpecMajorVersion, writeVersion: classProps.originalECSpecMinorVersion }))
|
|
308
393
|
this._modifier = ECClassModifier.None;
|
|
309
394
|
else
|
|
310
|
-
throw new
|
|
395
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidModifier, `The string '${classProps.modifier}' is not a valid ECClassModifier.`);
|
|
311
396
|
}
|
|
312
397
|
else {
|
|
313
398
|
this._modifier = modifier;
|
|
@@ -316,18 +401,37 @@ export class ECClass extends SchemaItem {
|
|
|
316
401
|
if (undefined !== classProps.baseClass) {
|
|
317
402
|
const ecClassSchemaItemKey = this.schema.getSchemaItemKey(classProps.baseClass);
|
|
318
403
|
if (!ecClassSchemaItemKey)
|
|
319
|
-
throw new
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
404
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
|
|
405
|
+
const baseClass = this.schema.lookupItemSync(ecClassSchemaItemKey);
|
|
406
|
+
let lazyBase;
|
|
407
|
+
if (!baseClass) {
|
|
408
|
+
lazyBase = new DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
|
|
409
|
+
const baseItem = await this.schema.lookupItem(ecClassSchemaItemKey);
|
|
410
|
+
if (undefined === baseItem || !ECClass.isECClass(baseItem))
|
|
411
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate the baseClass ${classProps.baseClass}.`);
|
|
412
|
+
return baseItem;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
lazyBase = new DelayedPromiseWithProps(ecClassSchemaItemKey, async () => {
|
|
417
|
+
return baseClass;
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
this._baseClass = lazyBase;
|
|
421
|
+
if (!baseClass)
|
|
422
|
+
return;
|
|
423
|
+
this.addDerivedClass(baseClass, this);
|
|
326
424
|
}
|
|
327
425
|
}
|
|
328
426
|
async fromJSON(classProps) {
|
|
329
427
|
this.fromJSONSync(classProps);
|
|
330
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
*
|
|
431
|
+
* @param customAttribute
|
|
432
|
+
*
|
|
433
|
+
* @internal
|
|
434
|
+
*/
|
|
331
435
|
addCustomAttribute(customAttribute) {
|
|
332
436
|
if (!this._customAttributes)
|
|
333
437
|
this._customAttributes = new Map();
|
|
@@ -341,8 +445,8 @@ export class ECClass extends SchemaItem {
|
|
|
341
445
|
const baseClasses = [this];
|
|
342
446
|
const addBaseClasses = async (ecClass) => {
|
|
343
447
|
if (SchemaItemType.EntityClass === ecClass.schemaItemType) {
|
|
344
|
-
for (let i =
|
|
345
|
-
baseClasses.push(await
|
|
448
|
+
for (let i = ecClass.mixins.length - 1; i >= 0; i--) {
|
|
449
|
+
baseClasses.push(await ecClass.mixins[i]);
|
|
346
450
|
}
|
|
347
451
|
}
|
|
348
452
|
if (ecClass.baseClass)
|
|
@@ -358,7 +462,7 @@ export class ECClass extends SchemaItem {
|
|
|
358
462
|
*getAllBaseClassesSync() {
|
|
359
463
|
const baseClasses = [this];
|
|
360
464
|
const addBaseClasses = (ecClass) => {
|
|
361
|
-
if (
|
|
465
|
+
if (ecClass.schemaItemType === SchemaItemType.EntityClass) { // cannot use EntityClass typeguard because of circular reference
|
|
362
466
|
for (const m of Array.from(ecClass.getMixinsSync()).reverse()) {
|
|
363
467
|
baseClasses.push(m);
|
|
364
468
|
}
|
|
@@ -374,6 +478,15 @@ export class ECClass extends SchemaItem {
|
|
|
374
478
|
yield baseClass;
|
|
375
479
|
}
|
|
376
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
*
|
|
483
|
+
* @param target
|
|
484
|
+
* @param existingValues
|
|
485
|
+
* @param propertiesToMerge
|
|
486
|
+
* @param overwriteExisting
|
|
487
|
+
*
|
|
488
|
+
* @internal
|
|
489
|
+
*/
|
|
377
490
|
static mergeProperties(target, existingValues, propertiesToMerge, overwriteExisting) {
|
|
378
491
|
for (const property of propertiesToMerge) {
|
|
379
492
|
const upperCaseName = property.name.toUpperCase();
|
|
@@ -389,52 +502,87 @@ export class ECClass extends SchemaItem {
|
|
|
389
502
|
}
|
|
390
503
|
}
|
|
391
504
|
}
|
|
392
|
-
|
|
505
|
+
/**
|
|
506
|
+
*
|
|
507
|
+
* @param result
|
|
508
|
+
* @param existingValues
|
|
509
|
+
* @returns
|
|
510
|
+
*
|
|
511
|
+
* @internal
|
|
512
|
+
*/
|
|
513
|
+
async buildPropertyCache(result, existingValues) {
|
|
393
514
|
if (!existingValues) {
|
|
394
515
|
existingValues = new Map();
|
|
395
516
|
}
|
|
396
517
|
if (this.baseClass) {
|
|
397
|
-
|
|
518
|
+
const baseClass = await this.baseClass;
|
|
519
|
+
if (baseClass) {
|
|
520
|
+
ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);
|
|
521
|
+
}
|
|
398
522
|
}
|
|
399
|
-
if (!this.
|
|
523
|
+
if (!this._properties)
|
|
400
524
|
return;
|
|
401
|
-
ECClass.mergeProperties(result, existingValues, [...this.
|
|
525
|
+
ECClass.mergeProperties(result, existingValues, [...this._properties.values()], true);
|
|
402
526
|
}
|
|
403
|
-
|
|
527
|
+
/**
|
|
528
|
+
*
|
|
529
|
+
* @param result
|
|
530
|
+
* @param existingValues
|
|
531
|
+
* @returns
|
|
532
|
+
*
|
|
533
|
+
* @internal
|
|
534
|
+
*/
|
|
535
|
+
buildPropertyCacheSync(result, existingValues) {
|
|
404
536
|
if (!existingValues) {
|
|
405
537
|
existingValues = new Map();
|
|
406
538
|
}
|
|
407
539
|
const baseClass = this.getBaseClassSync();
|
|
408
540
|
if (baseClass) {
|
|
409
|
-
ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(
|
|
541
|
+
ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);
|
|
410
542
|
}
|
|
411
|
-
if (!this.
|
|
543
|
+
if (!this._properties)
|
|
412
544
|
return;
|
|
413
|
-
ECClass.mergeProperties(result, existingValues, [...this.
|
|
545
|
+
ECClass.mergeProperties(result, existingValues, [...this._properties.values()], true);
|
|
414
546
|
}
|
|
415
547
|
/**
|
|
416
|
-
*
|
|
548
|
+
* Clears all caches on this object. This is called implicitly for this class,
|
|
549
|
+
* but needs to be called if derived classes have changed.
|
|
550
|
+
* @internal
|
|
551
|
+
*/
|
|
552
|
+
cleanCache() {
|
|
553
|
+
this._mergedPropertyCache = undefined;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Returns the properties on this class and its base classes.
|
|
417
557
|
* Since this is an expensive operation, results will be cached after first call.
|
|
418
|
-
* @param
|
|
558
|
+
* @param excludeInherited If true, only properties defined directly on this class will be returned. Defaults to false.
|
|
559
|
+
* @returns An array of properties, empty array if none exist.
|
|
419
560
|
*/
|
|
420
|
-
getPropertiesSync(
|
|
421
|
-
if (
|
|
561
|
+
getPropertiesSync(excludeInherited) {
|
|
562
|
+
if (excludeInherited) {
|
|
563
|
+
return this._properties && this._properties.size > 0 ? this._properties.values() : [];
|
|
564
|
+
}
|
|
565
|
+
if (!this._mergedPropertyCache) {
|
|
422
566
|
this._mergedPropertyCache = [];
|
|
423
|
-
this.buildPropertyCacheSync(this._mergedPropertyCache, undefined
|
|
567
|
+
this.buildPropertyCacheSync(this._mergedPropertyCache, undefined);
|
|
424
568
|
}
|
|
425
569
|
return this._mergedPropertyCache;
|
|
426
570
|
}
|
|
427
571
|
/**
|
|
428
|
-
*
|
|
572
|
+
* Quick way to check whether this class has any local properties without having to use the iterable
|
|
573
|
+
*/
|
|
574
|
+
get hasLocalProperties() {
|
|
575
|
+
return this._properties !== undefined && this._properties.size > 0;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Returns the properties on this class and its base classes.
|
|
429
579
|
* Since this is an expensive operation, results will be cached after first call.
|
|
430
|
-
* @param
|
|
580
|
+
* @param excludeInherited If true, only properties defined directly on this class will be returned.
|
|
581
|
+
* @returns An array of properties, empty array if none exist.
|
|
431
582
|
*/
|
|
432
|
-
async getProperties(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
await this.buildPropertyCache(this._mergedPropertyCache, undefined, resetCache);
|
|
436
|
-
}
|
|
437
|
-
return this._mergedPropertyCache;
|
|
583
|
+
async getProperties(excludeInherited) {
|
|
584
|
+
// At the moment we do not lazy load properties, so this is the same as getPropertiesSync
|
|
585
|
+
return this.getPropertiesSync(excludeInherited);
|
|
438
586
|
}
|
|
439
587
|
/**
|
|
440
588
|
* Retrieve all custom attributes in the current class and its bases
|
|
@@ -526,22 +674,76 @@ export class ECClass extends SchemaItem {
|
|
|
526
674
|
object.schemaItemType === SchemaItemType.StructClass || object.schemaItemType === SchemaItemType.CustomAttributeClass;
|
|
527
675
|
}
|
|
528
676
|
/**
|
|
529
|
-
* @alpha
|
|
530
677
|
* A setter method for the ECClass modifier, used specifically for schema editing.
|
|
531
678
|
* @param modifier
|
|
679
|
+
* @internal
|
|
532
680
|
*/
|
|
533
681
|
setModifier(modifier) {
|
|
534
682
|
this._modifier = modifier;
|
|
535
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Adds an ECClass to the derived class collection. This method is only intended to update the local
|
|
686
|
+
* cache of derived classes. For adding a class to the hierarchy, use the baseClass setter method.
|
|
687
|
+
* @param prop The property to add.
|
|
688
|
+
* @return The property that was added.
|
|
689
|
+
*/
|
|
690
|
+
addDerivedClass(baseClass, derivedClass) {
|
|
691
|
+
if (!baseClass._derivedClasses)
|
|
692
|
+
baseClass._derivedClasses = new Map();
|
|
693
|
+
if (baseClass._derivedClasses.has(derivedClass.fullName))
|
|
694
|
+
return;
|
|
695
|
+
if (derivedClass.isSync(baseClass)) {
|
|
696
|
+
const promise = new DelayedPromiseWithProps(derivedClass.key, async () => derivedClass);
|
|
697
|
+
baseClass._derivedClasses.set(derivedClass.fullName, promise);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Removes an ECClass from the derived class collection. This method is only intended to update the local
|
|
702
|
+
* cache of derived classes. For updating the class hierarchy, use the baseClass setter method.
|
|
703
|
+
* @param prop The property to add.
|
|
704
|
+
* @return The property that was added.
|
|
705
|
+
*/
|
|
706
|
+
removeDerivedClass(baseClass, derivedClass) {
|
|
707
|
+
if (!baseClass._derivedClasses)
|
|
708
|
+
return;
|
|
709
|
+
if (!baseClass._derivedClasses.has(derivedClass.fullName))
|
|
710
|
+
return;
|
|
711
|
+
baseClass._derivedClasses.delete(derivedClass.fullName);
|
|
712
|
+
}
|
|
536
713
|
}
|
|
537
714
|
/**
|
|
538
715
|
* A Typescript class representation of an ECStructClass.
|
|
539
|
-
* @
|
|
716
|
+
* @public @preview
|
|
540
717
|
*/
|
|
541
718
|
export class StructClass extends ECClass {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
719
|
+
/**
|
|
720
|
+
* Get the type of item represented by this instance
|
|
721
|
+
*/
|
|
722
|
+
schemaItemType = StructClass.schemaItemType;
|
|
723
|
+
/**
|
|
724
|
+
* Get the type of item represented by this class
|
|
725
|
+
* @internal
|
|
726
|
+
*/
|
|
727
|
+
static get schemaItemType() { return SchemaItemType.StructClass; }
|
|
728
|
+
/**
|
|
729
|
+
* Type guard to check if the SchemaItem is of type StructClass.
|
|
730
|
+
* @param item The SchemaItem to check.
|
|
731
|
+
* @returns True if the item is a StructClass, false otherwise.
|
|
732
|
+
*/
|
|
733
|
+
static isStructClass(item) {
|
|
734
|
+
if (item && item.schemaItemType === SchemaItemType.StructClass)
|
|
735
|
+
return true;
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Type assertion to check if the SchemaItem is of type StructClass.
|
|
740
|
+
* @param item The SchemaItem to check.
|
|
741
|
+
* @returns The item cast to StructClass if it is a StructClass, undefined otherwise.
|
|
742
|
+
* @internal
|
|
743
|
+
*/
|
|
744
|
+
static assertIsStructClass(item) {
|
|
745
|
+
if (!this.isStructClass(item))
|
|
746
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.StructClass}' (StructClass)`);
|
|
545
747
|
}
|
|
546
748
|
}
|
|
547
749
|
/**
|