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