@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
|
@@ -9,7 +9,8 @@ import { SchemaReadHelper } from "../Deserialization/Helper";
|
|
|
9
9
|
import { JsonParser } from "../Deserialization/JsonParser";
|
|
10
10
|
import { XmlParser } from "../Deserialization/XmlParser";
|
|
11
11
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
12
|
-
import {
|
|
12
|
+
import { isSupportedSchemaItemType } from "../ECObjects";
|
|
13
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
13
14
|
import { ECVersion, SchemaItemKey, SchemaKey } from "../SchemaKey";
|
|
14
15
|
import { ECName } from "../ECName";
|
|
15
16
|
import { ECClass, StructClass } from "./Class";
|
|
@@ -28,12 +29,22 @@ import { RelationshipClass } from "./RelationshipClass";
|
|
|
28
29
|
import { SchemaItem } from "./SchemaItem";
|
|
29
30
|
import { Unit } from "./Unit";
|
|
30
31
|
import { UnitSystem } from "./UnitSystem";
|
|
31
|
-
|
|
32
|
-
const SCHEMAURL3_2_XML = "http://www.bentley.com/schemas/Bentley.ECXML.3.2";
|
|
32
|
+
import { ECSchemaNamespaceUris } from "../Constants";
|
|
33
33
|
/**
|
|
34
|
-
* @
|
|
34
|
+
* @public @preview
|
|
35
35
|
*/
|
|
36
36
|
export class Schema {
|
|
37
|
+
static _currentECSpecVersion = "3.2";
|
|
38
|
+
_context;
|
|
39
|
+
_schemaKey;
|
|
40
|
+
_alias;
|
|
41
|
+
_label;
|
|
42
|
+
_description;
|
|
43
|
+
references;
|
|
44
|
+
_items;
|
|
45
|
+
_customAttributes;
|
|
46
|
+
_originalECSpecMajorVersion;
|
|
47
|
+
_originalECSpecMinorVersion;
|
|
37
48
|
/** @internal */
|
|
38
49
|
constructor(context, nameOrKey, alias, readVer, writeVer, minorVer) {
|
|
39
50
|
this._schemaKey = (typeof (nameOrKey) === "string") ? new SchemaKey(nameOrKey, new ECVersion(readVer, writeVer, minorVer)) : nameOrKey;
|
|
@@ -44,43 +55,47 @@ export class Schema {
|
|
|
44
55
|
this._alias = alias;
|
|
45
56
|
}
|
|
46
57
|
else if (nameOrKey !== undefined) {
|
|
47
|
-
throw new
|
|
58
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
|
|
48
59
|
}
|
|
49
60
|
this._originalECSpecMajorVersion = Schema.currentECSpecMajorVersion;
|
|
50
61
|
this._originalECSpecMinorVersion = Schema.currentECSpecMinorVersion;
|
|
51
62
|
}
|
|
52
63
|
get schemaKey() {
|
|
53
64
|
if (undefined === this._schemaKey)
|
|
54
|
-
throw new
|
|
65
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
55
66
|
return this._schemaKey;
|
|
56
67
|
}
|
|
57
68
|
get name() {
|
|
58
69
|
if (this._schemaKey === undefined)
|
|
59
|
-
throw new
|
|
70
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
60
71
|
return this.schemaKey.name;
|
|
61
72
|
}
|
|
62
73
|
get readVersion() {
|
|
63
74
|
if (this._schemaKey === undefined)
|
|
64
|
-
throw new
|
|
75
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
65
76
|
return this.schemaKey.readVersion;
|
|
66
77
|
}
|
|
67
78
|
get writeVersion() {
|
|
68
79
|
if (this._schemaKey === undefined)
|
|
69
|
-
throw new
|
|
80
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
70
81
|
return this.schemaKey.writeVersion;
|
|
71
82
|
}
|
|
72
83
|
get minorVersion() {
|
|
73
84
|
if (this._schemaKey === undefined)
|
|
74
|
-
throw new
|
|
85
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
75
86
|
return this.schemaKey.minorVersion;
|
|
76
87
|
}
|
|
77
88
|
get originalECSpecMajorVersion() { return this._originalECSpecMajorVersion; }
|
|
78
89
|
get originalECSpecMinorVersion() { return this._originalECSpecMinorVersion; }
|
|
79
90
|
static get currentECSpecMajorVersion() { return parseInt(Schema._currentECSpecVersion.split(".")[0], 10); }
|
|
80
91
|
static get currentECSpecMinorVersion() { return parseInt(Schema._currentECSpecVersion.split(".")[1], 10); }
|
|
92
|
+
get _isECSpecVersionUnsupported() {
|
|
93
|
+
return (this.originalECSpecMajorVersion !== 3 || this.originalECSpecMinorVersion === undefined
|
|
94
|
+
|| (this.originalECSpecMinorVersion < 2 || this.originalECSpecMinorVersion > Schema.currentECSpecMinorVersion));
|
|
95
|
+
}
|
|
81
96
|
get alias() {
|
|
82
97
|
if (this._alias === undefined || this._alias === null) {
|
|
83
|
-
throw new
|
|
98
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
|
|
84
99
|
}
|
|
85
100
|
else {
|
|
86
101
|
return this._alias;
|
|
@@ -105,18 +120,19 @@ export class Schema {
|
|
|
105
120
|
if (this.name !== schemaName) {
|
|
106
121
|
const newSchemaRef = this.getReferenceSync(schemaName);
|
|
107
122
|
if (undefined === newSchemaRef)
|
|
108
|
-
throw new
|
|
123
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to find the referenced SchemaItem ${itemName}.`);
|
|
109
124
|
schemaKey = newSchemaRef.schemaKey;
|
|
110
125
|
}
|
|
111
126
|
return new SchemaItemKey(itemName, schemaKey);
|
|
112
127
|
}
|
|
128
|
+
/** @internal */
|
|
113
129
|
addItem(item) {
|
|
114
130
|
if (undefined !== this.getItemSync(item.name))
|
|
115
|
-
throw new
|
|
131
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateItem, `The SchemaItem ${item.name} cannot be added to the schema ${this.name} because it already exists`);
|
|
116
132
|
this._items.set(item.name.toUpperCase(), item);
|
|
117
133
|
}
|
|
118
134
|
/**
|
|
119
|
-
* @
|
|
135
|
+
* @internal
|
|
120
136
|
*/
|
|
121
137
|
createClass(type, name, modifier) {
|
|
122
138
|
const item = new type(this, name, modifier);
|
|
@@ -126,7 +142,7 @@ export class Schema {
|
|
|
126
142
|
/**
|
|
127
143
|
* Deletes a class from within this schema.
|
|
128
144
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
129
|
-
* @
|
|
145
|
+
* @internal
|
|
130
146
|
*/
|
|
131
147
|
async deleteClass(name) {
|
|
132
148
|
const schemaItem = await this.getItem(name);
|
|
@@ -137,7 +153,7 @@ export class Schema {
|
|
|
137
153
|
/**
|
|
138
154
|
* Deletes a class from within this schema.
|
|
139
155
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
140
|
-
* @
|
|
156
|
+
* @internal
|
|
141
157
|
*/
|
|
142
158
|
deleteClassSync(name) {
|
|
143
159
|
const schemaItem = this.getItemSync(name);
|
|
@@ -147,7 +163,7 @@ export class Schema {
|
|
|
147
163
|
/**
|
|
148
164
|
* Deletes a SchemaItem from within this schema.
|
|
149
165
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
150
|
-
* @
|
|
166
|
+
* @internal
|
|
151
167
|
*/
|
|
152
168
|
async deleteSchemaItem(name) {
|
|
153
169
|
const schemaItem = await this.getItem(name);
|
|
@@ -158,21 +174,20 @@ export class Schema {
|
|
|
158
174
|
/**
|
|
159
175
|
* Deletes a SchemaItem from within this schema.
|
|
160
176
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
161
|
-
* @
|
|
177
|
+
* @internal
|
|
162
178
|
*/
|
|
163
179
|
deleteSchemaItemSync(name) {
|
|
164
180
|
const schemaItem = this.getItemSync(name);
|
|
165
181
|
if (SchemaItem.isSchemaItem(schemaItem))
|
|
166
182
|
this._items.delete(name.toUpperCase());
|
|
167
183
|
}
|
|
168
|
-
/**
|
|
169
|
-
* @alpha
|
|
170
|
-
*/
|
|
184
|
+
/** @internal */
|
|
171
185
|
createItem(type, name) {
|
|
172
186
|
const item = new type(this, name);
|
|
173
187
|
this.addItem(item);
|
|
174
188
|
return item;
|
|
175
189
|
}
|
|
190
|
+
/** @internal */
|
|
176
191
|
addCustomAttribute(customAttribute) {
|
|
177
192
|
if (!this._customAttributes)
|
|
178
193
|
this._customAttributes = new Map();
|
|
@@ -182,27 +197,33 @@ export class Schema {
|
|
|
182
197
|
* Creates a EntityClass with the provided name in this schema.
|
|
183
198
|
* @param name
|
|
184
199
|
* @param modifier
|
|
200
|
+
* @internal
|
|
185
201
|
*/
|
|
186
202
|
async createEntityClass(name, modifier) {
|
|
187
203
|
return this.createClass(EntityClass, name, modifier);
|
|
188
204
|
}
|
|
205
|
+
/** @internal */
|
|
189
206
|
createEntityClassSync(name, modifier) {
|
|
190
207
|
return this.createClass(EntityClass, name, modifier);
|
|
191
208
|
}
|
|
192
209
|
/**
|
|
193
210
|
* Creates a Mixin with the provided name in this schema.
|
|
194
211
|
* @param name
|
|
212
|
+
* @internal
|
|
195
213
|
*/
|
|
196
214
|
async createMixinClass(name) { return this.createClass(Mixin, name); }
|
|
215
|
+
/** @internal */
|
|
197
216
|
createMixinClassSync(name) { return this.createClass(Mixin, name); }
|
|
198
217
|
/**
|
|
199
218
|
* Creates a StructClass with the provided name in this schema.
|
|
200
219
|
* @param name
|
|
201
220
|
* @param modifier
|
|
221
|
+
* @internal
|
|
202
222
|
*/
|
|
203
223
|
async createStructClass(name, modifier) {
|
|
204
224
|
return this.createClass(StructClass, name, modifier);
|
|
205
225
|
}
|
|
226
|
+
/** @internal */
|
|
206
227
|
createStructClassSync(name, modifier) {
|
|
207
228
|
return this.createClass(StructClass, name, modifier);
|
|
208
229
|
}
|
|
@@ -210,10 +231,12 @@ export class Schema {
|
|
|
210
231
|
* Creates a CustomAttributeClass with the provided name in this schema.
|
|
211
232
|
* @param name
|
|
212
233
|
* @param modifier
|
|
234
|
+
* @internal
|
|
213
235
|
*/
|
|
214
236
|
async createCustomAttributeClass(name, modifier) {
|
|
215
237
|
return this.createClass(CustomAttributeClass, name, modifier);
|
|
216
238
|
}
|
|
239
|
+
/** @internal */
|
|
217
240
|
createCustomAttributeClassSync(name, modifier) {
|
|
218
241
|
return this.createClass(CustomAttributeClass, name, modifier);
|
|
219
242
|
}
|
|
@@ -221,20 +244,26 @@ export class Schema {
|
|
|
221
244
|
* Creates a RelationshipClass with the provided name in this schema.
|
|
222
245
|
* @param name
|
|
223
246
|
* @param modifier
|
|
247
|
+
* @internal
|
|
224
248
|
*/
|
|
225
249
|
async createRelationshipClass(name, modifier) {
|
|
226
250
|
return this.createRelationshipClassSync(name, modifier);
|
|
227
251
|
}
|
|
252
|
+
/** @internal */
|
|
228
253
|
createRelationshipClassSync(name, modifier) {
|
|
229
254
|
return this.createClass(RelationshipClass, name, modifier);
|
|
230
255
|
}
|
|
231
256
|
/**
|
|
232
257
|
* Creates an Enumeration with the provided name in this schema.
|
|
233
258
|
* @param name
|
|
259
|
+
* @param primitiveType
|
|
260
|
+
*
|
|
261
|
+
* @internal
|
|
234
262
|
*/
|
|
235
263
|
async createEnumeration(name, primitiveType) {
|
|
236
264
|
return this.createEnumerationSync(name, primitiveType);
|
|
237
265
|
}
|
|
266
|
+
/** @internal */
|
|
238
267
|
createEnumerationSync(name, primitiveType) {
|
|
239
268
|
const item = new Enumeration(this, name, primitiveType);
|
|
240
269
|
this.addItem(item);
|
|
@@ -243,97 +272,113 @@ export class Schema {
|
|
|
243
272
|
/**
|
|
244
273
|
* Creates an KindOfQuantity with the provided name in this schema.
|
|
245
274
|
* @param name
|
|
275
|
+
* @internal
|
|
246
276
|
*/
|
|
247
277
|
async createKindOfQuantity(name) {
|
|
248
278
|
return this.createKindOfQuantitySync(name);
|
|
249
279
|
}
|
|
280
|
+
/** @internal */
|
|
250
281
|
createKindOfQuantitySync(name) {
|
|
251
282
|
return this.createItem(KindOfQuantity, name);
|
|
252
283
|
}
|
|
253
284
|
/**
|
|
254
285
|
* Creates a Constant with the provided name in this schema.
|
|
255
286
|
* @param name
|
|
287
|
+
* @internal
|
|
256
288
|
*/
|
|
257
289
|
async createConstant(name) {
|
|
258
290
|
return this.createItem(Constant, name);
|
|
259
291
|
}
|
|
292
|
+
/** @internal */
|
|
260
293
|
createConstantSync(name) {
|
|
261
294
|
return this.createItem(Constant, name);
|
|
262
295
|
}
|
|
263
296
|
/**
|
|
264
297
|
* Creates a Inverted Unit with the provided name in this schema.
|
|
265
298
|
* @param name
|
|
299
|
+
* @internal
|
|
266
300
|
*/
|
|
267
301
|
async createInvertedUnit(name) {
|
|
268
302
|
return this.createItem(InvertedUnit, name);
|
|
269
303
|
}
|
|
304
|
+
/** @internal */
|
|
270
305
|
createInvertedUnitSync(name) {
|
|
271
306
|
return this.createItem(InvertedUnit, name);
|
|
272
307
|
}
|
|
273
308
|
/**
|
|
274
309
|
* Creates an Format with the provided name in this schema.
|
|
275
310
|
* @param name
|
|
311
|
+
* @internal
|
|
276
312
|
*/
|
|
277
313
|
async createFormat(name) {
|
|
278
314
|
return this.createItem(Format, name);
|
|
279
315
|
}
|
|
316
|
+
/** @internal */
|
|
280
317
|
createFormatSync(name) {
|
|
281
318
|
return this.createItem(Format, name);
|
|
282
319
|
}
|
|
283
320
|
/**
|
|
284
321
|
* Creates a UnitSystem with the provided name in this schema.
|
|
285
322
|
* @param name
|
|
323
|
+
* @internal
|
|
286
324
|
*/
|
|
287
325
|
async createUnitSystem(name) {
|
|
288
326
|
return this.createItem(UnitSystem, name);
|
|
289
327
|
}
|
|
328
|
+
/** @internal */
|
|
290
329
|
createUnitSystemSync(name) {
|
|
291
330
|
return this.createItem(UnitSystem, name);
|
|
292
331
|
}
|
|
293
332
|
/**
|
|
294
333
|
* Creates a Phenomenon with the provided name in this schema.
|
|
295
334
|
* @param name
|
|
335
|
+
* @internal
|
|
296
336
|
*/
|
|
297
337
|
async createPhenomenon(name) {
|
|
298
338
|
return this.createItem(Phenomenon, name);
|
|
299
339
|
}
|
|
340
|
+
/** @internal */
|
|
300
341
|
createPhenomenonSync(name) {
|
|
301
342
|
return this.createItem(Phenomenon, name);
|
|
302
343
|
}
|
|
303
344
|
/**
|
|
304
345
|
* Creates a Unit with the provided name in this schema.
|
|
305
346
|
* @param name
|
|
347
|
+
* @internal
|
|
306
348
|
*/
|
|
307
349
|
async createUnit(name) {
|
|
308
350
|
return this.createItem(Unit, name);
|
|
309
351
|
}
|
|
352
|
+
/** @internal */
|
|
310
353
|
createUnitSync(name) {
|
|
311
354
|
return this.createItem(Unit, name);
|
|
312
355
|
}
|
|
313
356
|
/**
|
|
314
357
|
* Creates an PropertyCategory with the provided name in this schema.
|
|
315
358
|
* @param name
|
|
359
|
+
* @internal
|
|
316
360
|
*/
|
|
317
361
|
async createPropertyCategory(name) {
|
|
318
362
|
return this.createItem(PropertyCategory, name);
|
|
319
363
|
}
|
|
364
|
+
/** @internal */
|
|
320
365
|
createPropertyCategorySync(name) {
|
|
321
366
|
return this.createItem(PropertyCategory, name);
|
|
322
367
|
}
|
|
323
368
|
/**
|
|
324
369
|
*
|
|
325
370
|
* @param refSchema
|
|
371
|
+
* @internal
|
|
326
372
|
*/
|
|
327
373
|
async addReference(refSchema) {
|
|
328
374
|
// TODO validation of reference schema. For now just adding
|
|
329
375
|
this.addReferenceSync(refSchema);
|
|
330
376
|
}
|
|
377
|
+
/** @internal */
|
|
331
378
|
addReferenceSync(refSchema) {
|
|
332
379
|
this.references.push(refSchema);
|
|
333
380
|
}
|
|
334
|
-
/**
|
|
335
|
-
* @alpha Used for schema editing.
|
|
336
|
-
*/
|
|
381
|
+
/** @internal */
|
|
337
382
|
setContext(context) {
|
|
338
383
|
this._context = context;
|
|
339
384
|
}
|
|
@@ -342,34 +387,113 @@ export class Schema {
|
|
|
342
387
|
* @param readVersion The read version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
343
388
|
* @param writeVersion The write version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
344
389
|
* @param minorVersion The minor version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
390
|
+
* @internal
|
|
345
391
|
*/
|
|
346
392
|
setVersion(readVersion, writeVersion, minorVersion) {
|
|
347
393
|
if (!this._schemaKey)
|
|
348
|
-
throw new
|
|
394
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaKey, `The schema '${this.name}' has an invalid SchemaKey.`);
|
|
349
395
|
const newVersion = new ECVersion(readVersion ?? this._schemaKey.readVersion, writeVersion ?? this._schemaKey.writeVersion, minorVersion ?? this._schemaKey.minorVersion);
|
|
350
396
|
this._schemaKey = new SchemaKey(this._schemaKey.name, newVersion);
|
|
351
397
|
}
|
|
352
398
|
/**
|
|
353
|
-
*
|
|
354
|
-
* @param
|
|
399
|
+
* Shortcut for calling getItem with EntityClass.
|
|
400
|
+
* @param name The local (unqualified) name of the item to return.
|
|
401
|
+
* @returns The requested EntityClass or undefined if not found.
|
|
355
402
|
*/
|
|
356
|
-
async getItem(name)
|
|
357
|
-
// this method exists so we can rewire it later when we load partial schemas, for now it is identical to the sync version
|
|
358
|
-
return this.getItemSync(name);
|
|
359
|
-
}
|
|
403
|
+
async getEntityClass(name) { return this.getItem(name, EntityClass); }
|
|
360
404
|
/**
|
|
361
|
-
*
|
|
362
|
-
* @param
|
|
405
|
+
* Shortcut for calling getItem with Mixin.
|
|
406
|
+
* @param name The local (unqualified) name of the item to return.
|
|
407
|
+
* @returns The requested Mixin or undefined if not found.
|
|
363
408
|
*/
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
409
|
+
async getMixin(name) { return this.getItem(name, Mixin); }
|
|
410
|
+
/**
|
|
411
|
+
* Shortcut for calling getItem with StructClass.
|
|
412
|
+
* @param name The local (unqualified) name of the item to return.
|
|
413
|
+
* @returns The requested StructClass or undefined if not found.
|
|
414
|
+
*/
|
|
415
|
+
async getStructClass(name) { return this.getItem(name, StructClass); }
|
|
416
|
+
/**
|
|
417
|
+
* Shortcut for calling getItem with CustomAttributeClass.
|
|
418
|
+
* @param name The local (unqualified) name of the item to return.
|
|
419
|
+
* @returns The requested CustomAttributeClass or undefined if not found.
|
|
420
|
+
*/
|
|
421
|
+
async getCustomAttributeClass(name) { return this.getItem(name, CustomAttributeClass); }
|
|
422
|
+
/**
|
|
423
|
+
* Shortcut for calling getItem with RelationshipClass.
|
|
424
|
+
* @param name The local (unqualified) name of the item to return.
|
|
425
|
+
* @returns The requested RelationshipClass or undefined if not found.
|
|
426
|
+
*/
|
|
427
|
+
async getRelationshipClass(name) { return this.getItem(name, RelationshipClass); }
|
|
428
|
+
/**
|
|
429
|
+
* Shortcut for calling getItem with Enumeration.
|
|
430
|
+
* @param name The local (unqualified) name of the item to return.
|
|
431
|
+
* @returns The requested Enumeration or undefined if not found.
|
|
432
|
+
*/
|
|
433
|
+
async getEnumeration(name) { return this.getItem(name, Enumeration); }
|
|
434
|
+
/**
|
|
435
|
+
* Shortcut for calling getItem with KindOfQuantity.
|
|
436
|
+
* @param name The local (unqualified) name of the item to return.
|
|
437
|
+
* @returns The requested KindOfQuantity or undefined if not found.
|
|
438
|
+
*/
|
|
439
|
+
async getKindOfQuantity(name) { return this.getItem(name, KindOfQuantity); }
|
|
440
|
+
/**
|
|
441
|
+
* Shortcut for calling getItem with PropertyCategory.
|
|
442
|
+
* @param name The local (unqualified) name of the item to return.
|
|
443
|
+
* @returns The requested PropertyCategory or undefined if not found.
|
|
444
|
+
*/
|
|
445
|
+
async getPropertyCategory(name) { return this.getItem(name, PropertyCategory); }
|
|
446
|
+
/**
|
|
447
|
+
* Shortcut for calling getItem with Unit.
|
|
448
|
+
* @param name The local (unqualified) name of the item to return.
|
|
449
|
+
* @returns The requested Unit or undefined if not found.
|
|
450
|
+
*/
|
|
451
|
+
async getUnit(name) { return this.getItem(name, Unit); }
|
|
452
|
+
/**
|
|
453
|
+
* Shortcut for calling getItem with InvertedUnit.
|
|
454
|
+
* @param name The local (unqualified) name of the item to return.
|
|
455
|
+
* @returns The requested InvertedUnit or undefined if not found.
|
|
456
|
+
*/
|
|
457
|
+
async getInvertedUnit(name) { return this.getItem(name, InvertedUnit); }
|
|
458
|
+
/**
|
|
459
|
+
* Shortcut for calling getItem with Constant.
|
|
460
|
+
* @param name The local (unqualified) name of the item to return.
|
|
461
|
+
* @returns The requested Constant or undefined if not found.
|
|
462
|
+
*/
|
|
463
|
+
async getConstant(name) { return this.getItem(name, Constant); }
|
|
464
|
+
/**
|
|
465
|
+
* Shortcut for calling getItem with Phenomenon.
|
|
466
|
+
* @param name The local (unqualified) name of the item to return.
|
|
467
|
+
* @returns The requested Phenomenon or undefined if not found.
|
|
468
|
+
*/
|
|
469
|
+
async getPhenomenon(name) { return this.getItem(name, Phenomenon); }
|
|
368
470
|
/**
|
|
369
|
-
*
|
|
370
|
-
* @param
|
|
471
|
+
* Shortcut for calling getItem with UnitSystem.
|
|
472
|
+
* @param name The local (unqualified) name of the item to return.
|
|
473
|
+
* @returns The requested UnitSystem or undefined if not found.
|
|
371
474
|
*/
|
|
372
|
-
async
|
|
475
|
+
async getUnitSystem(name) { return this.getItem(name, UnitSystem); }
|
|
476
|
+
/**
|
|
477
|
+
* Shortcut for calling getItem with Format.
|
|
478
|
+
* @param name The local (unqualified) name of the item to return.
|
|
479
|
+
* @returns The requested Format or undefined if not found.
|
|
480
|
+
*/
|
|
481
|
+
async getFormat(name) { return this.getItem(name, Format); }
|
|
482
|
+
async getItem(name, itemConstructor) {
|
|
483
|
+
// this method exists so we can rewire it later when we load partial schemas, for now it is identical to the sync version
|
|
484
|
+
if (itemConstructor === undefined)
|
|
485
|
+
return this.getItemSync(name);
|
|
486
|
+
return this.getItemSync(name, itemConstructor);
|
|
487
|
+
}
|
|
488
|
+
getItemSync(name, itemConstructor) {
|
|
489
|
+
const value = this._items.get(name.toUpperCase());
|
|
490
|
+
if (value === undefined || itemConstructor === undefined)
|
|
491
|
+
return value;
|
|
492
|
+
if (isSupportedSchemaItemType(value.schemaItemType, itemConstructor.schemaItemType))
|
|
493
|
+
return value;
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
async lookupItem(key, itemConstructor) {
|
|
373
497
|
let schemaName, itemName;
|
|
374
498
|
if (typeof (key) === "string") {
|
|
375
499
|
[schemaName, itemName] = SchemaItem.parseFullName(key);
|
|
@@ -379,18 +503,18 @@ export class Schema {
|
|
|
379
503
|
schemaName = key.schemaName;
|
|
380
504
|
}
|
|
381
505
|
if (!schemaName || schemaName.toUpperCase() === this.name.toUpperCase()) {
|
|
382
|
-
return
|
|
506
|
+
return itemConstructor
|
|
507
|
+
? this.getItem(itemName, itemConstructor)
|
|
508
|
+
: this.getItem(itemName);
|
|
383
509
|
}
|
|
384
510
|
const refSchema = await this.getReference(schemaName);
|
|
385
511
|
if (!refSchema)
|
|
386
512
|
return undefined;
|
|
387
|
-
return
|
|
513
|
+
return itemConstructor
|
|
514
|
+
? refSchema.getItem(itemName, itemConstructor)
|
|
515
|
+
: refSchema.getItem(itemName);
|
|
388
516
|
}
|
|
389
|
-
|
|
390
|
-
* Attempts to find a schema item within this schema or a (directly) referenced schema
|
|
391
|
-
* @param key The full name or a SchemaItemKey identifying the desired item.
|
|
392
|
-
*/
|
|
393
|
-
lookupItemSync(key) {
|
|
517
|
+
lookupItemSync(key, itemConstructor) {
|
|
394
518
|
let schemaName, itemName;
|
|
395
519
|
if (typeof (key) === "string") {
|
|
396
520
|
[schemaName, itemName] = SchemaItem.parseFullName(key);
|
|
@@ -400,35 +524,48 @@ export class Schema {
|
|
|
400
524
|
schemaName = key.schemaName;
|
|
401
525
|
}
|
|
402
526
|
if (!schemaName || schemaName.toUpperCase() === this.name.toUpperCase()) {
|
|
403
|
-
return
|
|
527
|
+
return itemConstructor
|
|
528
|
+
? this.getItemSync(itemName, itemConstructor)
|
|
529
|
+
: this.getItemSync(itemName);
|
|
404
530
|
}
|
|
405
531
|
const refSchema = this.getReferenceSync(schemaName);
|
|
406
532
|
if (!refSchema)
|
|
407
533
|
return undefined;
|
|
408
|
-
return
|
|
534
|
+
return itemConstructor
|
|
535
|
+
? refSchema.getItemSync(itemName, itemConstructor)
|
|
536
|
+
: refSchema.getItemSync(itemName);
|
|
409
537
|
}
|
|
410
|
-
getItems() {
|
|
538
|
+
*getItems(itemConstructor) {
|
|
411
539
|
if (!this._items)
|
|
412
|
-
return
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
for (const [, value] of this._items) {
|
|
417
|
-
if (ECClass.isECClass(value))
|
|
418
|
-
yield value;
|
|
540
|
+
return;
|
|
541
|
+
for (const item of this._items.values()) {
|
|
542
|
+
if (itemConstructor === undefined || isSupportedSchemaItemType(item.schemaItemType, itemConstructor.schemaItemType))
|
|
543
|
+
yield item;
|
|
419
544
|
}
|
|
420
545
|
}
|
|
546
|
+
/**
|
|
547
|
+
* Gets a referenced schema by name
|
|
548
|
+
* @param refSchemaName schema name to find
|
|
549
|
+
*/
|
|
421
550
|
async getReference(refSchemaName) {
|
|
422
551
|
if (this.references.length === 0)
|
|
423
552
|
return undefined;
|
|
424
553
|
return this.references.find((ref) => ref.name.toLowerCase() === refSchemaName.toLowerCase());
|
|
425
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Gets a referenced schema by alias
|
|
557
|
+
* @param alias alias to find
|
|
558
|
+
*/
|
|
426
559
|
getReferenceNameByAlias(alias) {
|
|
427
560
|
if (this.references.length === 0)
|
|
428
561
|
return undefined;
|
|
429
562
|
const schema = this.references.find((ref) => ref.alias ? ref.alias.toLowerCase() === alias.toLowerCase() : false);
|
|
430
563
|
return schema ? schema.name : undefined;
|
|
431
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* Gets a referenced schema by name
|
|
567
|
+
* @param refSchemaName schema name to find
|
|
568
|
+
*/
|
|
432
569
|
getReferenceSync(refSchemaName) {
|
|
433
570
|
if (this.references.length === 0)
|
|
434
571
|
return undefined;
|
|
@@ -438,10 +575,10 @@ export class Schema {
|
|
|
438
575
|
* Save this Schema's properties to an object for serializing to JSON.
|
|
439
576
|
*/
|
|
440
577
|
toJSON() {
|
|
441
|
-
if (
|
|
442
|
-
throw new
|
|
578
|
+
if (this._isECSpecVersionUnsupported)
|
|
579
|
+
throw new ECSchemaError(ECSchemaStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
|
|
443
580
|
const schemaJson = {};
|
|
444
|
-
schemaJson.$schema = SCHEMAURL3_2_JSON; // $schema is required
|
|
581
|
+
schemaJson.$schema = ECSchemaNamespaceUris.SCHEMAURL3_2_JSON; // $schema is required
|
|
445
582
|
schemaJson.name = this.name; // name is required
|
|
446
583
|
schemaJson.version = this.schemaKey.version.toString(true);
|
|
447
584
|
schemaJson.alias = this.alias; // alias is required
|
|
@@ -467,10 +604,10 @@ export class Schema {
|
|
|
467
604
|
* @param schemaXml An empty DOM document to which the schema will be written
|
|
468
605
|
*/
|
|
469
606
|
async toXml(schemaXml) {
|
|
470
|
-
if (
|
|
471
|
-
throw new
|
|
607
|
+
if (this._isECSpecVersionUnsupported)
|
|
608
|
+
throw new ECSchemaError(ECSchemaStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
|
|
472
609
|
const schemaMetadata = schemaXml.createElement("ECSchema");
|
|
473
|
-
schemaMetadata.setAttribute("xmlns", SCHEMAURL3_2_XML);
|
|
610
|
+
schemaMetadata.setAttribute("xmlns", ECSchemaNamespaceUris.SCHEMAURL3_2_XML);
|
|
474
611
|
schemaMetadata.setAttribute("version", this.schemaKey.version.toString());
|
|
475
612
|
schemaMetadata.setAttribute("schemaName", this.name);
|
|
476
613
|
schemaMetadata.setAttribute("alias", this.alias ? this.alias : "");
|
|
@@ -503,33 +640,6 @@ export class Schema {
|
|
|
503
640
|
schemaXml.appendChild(schemaMetadata);
|
|
504
641
|
return schemaXml;
|
|
505
642
|
}
|
|
506
|
-
// Check if the ECSpecVersion read-version is greater than the current ECSpecVersion supported.
|
|
507
|
-
// If a specific ECSpecVersion is given, check against that version.
|
|
508
|
-
// If no argument is given, check against the original ECSpecVersion of the schema.
|
|
509
|
-
isECSpecMajorVersionSupported(ecSpecMajorVersionToCheck) {
|
|
510
|
-
// If argument is supplied, check the argument against the current ECSpecVersion supported
|
|
511
|
-
if (ecSpecMajorVersionToCheck !== undefined)
|
|
512
|
-
return (Schema.currentECSpecMajorVersion >= ecSpecMajorVersionToCheck);
|
|
513
|
-
// If argument is not supplied, check against the original ECSpecVersion of the schema
|
|
514
|
-
if (this.originalECSpecMajorVersion === undefined)
|
|
515
|
-
return false;
|
|
516
|
-
return (Schema.currentECSpecMajorVersion >= this.originalECSpecMajorVersion);
|
|
517
|
-
}
|
|
518
|
-
// Check if the full ECSpecVersion is greater than the current ECSpecVersion supported.
|
|
519
|
-
// If a specific ECSpecVersion is given, check against that version.
|
|
520
|
-
// If no argument is given, check against the original ECSpecVersion of the schema.
|
|
521
|
-
isECSpecVersionSupported(ecSpecMajorVersionToCheck, ecSpecMinorVersionToCheck) {
|
|
522
|
-
// If arguments are supplied, check the arguments against the current ECSpecVersion supported
|
|
523
|
-
if (ecSpecMajorVersionToCheck !== undefined && ecSpecMinorVersionToCheck !== undefined) {
|
|
524
|
-
if (!this.isECSpecMajorVersionSupported(ecSpecMajorVersionToCheck))
|
|
525
|
-
return false;
|
|
526
|
-
return (Schema.currentECSpecMinorVersion >= ecSpecMinorVersionToCheck);
|
|
527
|
-
}
|
|
528
|
-
// If arguments are not supplied, check against the original ECSpecVersion of the schema
|
|
529
|
-
if (!this.isECSpecMajorVersionSupported() || this.originalECSpecMinorVersion === undefined)
|
|
530
|
-
return false;
|
|
531
|
-
return (Schema.currentECSpecMinorVersion >= this.originalECSpecMinorVersion);
|
|
532
|
-
}
|
|
533
643
|
/**
|
|
534
644
|
* Loads the schema header (name, version alias, label and description) from the input SchemaProps
|
|
535
645
|
*/
|
|
@@ -541,12 +651,12 @@ export class Schema {
|
|
|
541
651
|
}
|
|
542
652
|
else {
|
|
543
653
|
if (schemaProps.name.toLowerCase() !== this.name.toLowerCase())
|
|
544
|
-
throw new
|
|
654
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not match the provided name, '${schemaProps.name}'.`);
|
|
545
655
|
if (this.schemaKey.version.compare(ECVersion.fromString(schemaProps.version)))
|
|
546
|
-
throw new
|
|
656
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Schema ${this.name} has the version '${this.schemaKey.version}' that does not match the provided version '${schemaProps.version}'.`);
|
|
547
657
|
}
|
|
548
658
|
if (schemaProps.$schema.match(`https://dev\\.bentley\\.com/json_schemas/ec/([0-9]+)/ecschema`) == null && schemaProps.$schema.match(`http://www\\.bentley\\.com/schemas/Bentley\\.ECXML\\.([0-9]+)`) == null)
|
|
549
|
-
throw new
|
|
659
|
+
throw new ECSchemaError(ECSchemaStatus.MissingSchemaUrl, `The Schema '${this.name}' has an unsupported namespace '${schemaProps.$schema}'.`);
|
|
550
660
|
// The schema props have not been parsed. Parse the ECXml version from the $schema attribute
|
|
551
661
|
let ecVersion;
|
|
552
662
|
if (schemaProps.ecSpecMajorVersion === undefined || schemaProps.ecSpecMinorVersion === undefined) {
|
|
@@ -555,15 +665,15 @@ export class Schema {
|
|
|
555
665
|
else {
|
|
556
666
|
ecVersion = { readVersion: schemaProps.ecSpecMajorVersion, writeVersion: schemaProps.ecSpecMinorVersion };
|
|
557
667
|
}
|
|
558
|
-
this._originalECSpecMajorVersion = ecVersion
|
|
559
|
-
this._originalECSpecMinorVersion = ecVersion
|
|
560
|
-
if (
|
|
561
|
-
throw new
|
|
668
|
+
this._originalECSpecMajorVersion = ecVersion.readVersion;
|
|
669
|
+
this._originalECSpecMinorVersion = ecVersion.writeVersion;
|
|
670
|
+
if (ecVersion.readVersion !== 3 || (ecVersion.readVersion === 3 && ecVersion.writeVersion < 2))
|
|
671
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The Schema '${this.name}' has an unsupported ECVersion ${ecVersion.readVersion}.${ecVersion.writeVersion} and cannot be loaded.`);
|
|
562
672
|
if (ECName.validate(schemaProps.alias)) {
|
|
563
673
|
this._alias = schemaProps.alias;
|
|
564
674
|
}
|
|
565
675
|
else {
|
|
566
|
-
throw new
|
|
676
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Schema ${schemaProps.name} does not have the required 'alias' attribute.`);
|
|
567
677
|
}
|
|
568
678
|
if (undefined !== schemaProps.label)
|
|
569
679
|
this._label = schemaProps.label;
|
|
@@ -610,32 +720,22 @@ export class Schema {
|
|
|
610
720
|
const schema = object;
|
|
611
721
|
return schema !== undefined && schema.schemaKey !== undefined && schema.context !== undefined;
|
|
612
722
|
}
|
|
613
|
-
/**
|
|
614
|
-
* @alpha
|
|
615
|
-
* Used for schema editing.
|
|
616
|
-
*/
|
|
723
|
+
/** @internal */
|
|
617
724
|
setDisplayLabel(displayLabel) {
|
|
618
725
|
this._label = displayLabel;
|
|
619
726
|
}
|
|
620
|
-
/**
|
|
621
|
-
* @alpha
|
|
622
|
-
* Used for schema editing.
|
|
623
|
-
*/
|
|
727
|
+
/** @internal */
|
|
624
728
|
setDescription(description) {
|
|
625
729
|
this._description = description;
|
|
626
730
|
}
|
|
627
|
-
/**
|
|
628
|
-
* @alpha
|
|
629
|
-
* Used for schema editing.
|
|
630
|
-
*/
|
|
731
|
+
/** @internal */
|
|
631
732
|
setAlias(alias) {
|
|
632
733
|
if (!ECName.validate(alias)) {
|
|
633
|
-
throw new
|
|
734
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName, "The specified schema alias is invalid.");
|
|
634
735
|
}
|
|
635
736
|
this._alias = alias;
|
|
636
737
|
}
|
|
637
738
|
}
|
|
638
|
-
Schema._currentECSpecVersion = "3.2";
|
|
639
739
|
/**
|
|
640
740
|
* Hackish approach that works like a "friend class" so we can access protected members without making them public.
|
|
641
741
|
* We cannot put this into Helper.ts and make it non-export, because we are importing Helper.ts from this file, and the circular import
|