@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { PrimitiveType, primitiveTypeToString } from "../ECObjects";
|
|
6
|
-
import {
|
|
6
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
7
7
|
/**
|
|
8
8
|
* Namespace holding utility functions for serializing EC types to the EC XML format.
|
|
9
9
|
* @internal
|
|
@@ -16,19 +16,16 @@ export var XmlSerializationUtils;
|
|
|
16
16
|
* @param customAttribute The CustomAttribute instance to serialize.
|
|
17
17
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
18
18
|
* @param schema The Schema object being serialized.
|
|
19
|
-
* @beta
|
|
20
19
|
*/
|
|
21
20
|
async function writeCustomAttribute(fullName, customAttribute, schemaDoc, schema) {
|
|
22
21
|
const caClass = await schema.lookupItem(fullName);
|
|
23
22
|
if (!caClass)
|
|
24
|
-
throw new
|
|
23
|
+
throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The class '${fullName}' could not be found in the current schema context.`);
|
|
25
24
|
const nameAndNamespace = await resolveCustomAttributeNamespace(fullName, schema);
|
|
26
25
|
const caElement = schemaDoc.createElement(nameAndNamespace[0]);
|
|
27
26
|
if (nameAndNamespace[1])
|
|
28
27
|
caElement.setAttribute("xmlns", nameAndNamespace[1]);
|
|
29
|
-
|
|
30
|
-
return caElement;
|
|
31
|
-
for (const property of caClass.properties)
|
|
28
|
+
for (const property of await caClass.getProperties())
|
|
32
29
|
await writeInstanceProperty(property, customAttribute, caElement, schemaDoc);
|
|
33
30
|
return caElement;
|
|
34
31
|
}
|
|
@@ -39,7 +36,6 @@ export var XmlSerializationUtils;
|
|
|
39
36
|
* @param instance The Property instance.
|
|
40
37
|
* @param instanceElement The XML Element that will contain the serialized property instance.
|
|
41
38
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
42
|
-
* @beta
|
|
43
39
|
*/
|
|
44
40
|
async function writeInstanceProperty(propertyClass, instance, instanceElement, schemaDoc) {
|
|
45
41
|
const propertyValue = instance[propertyClass.name];
|
|
@@ -64,7 +60,6 @@ export var XmlSerializationUtils;
|
|
|
64
60
|
* @param propertyValue An array holding the property values.
|
|
65
61
|
* @param arrayElement The XML Element that will contain the serialized property instance.
|
|
66
62
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
67
|
-
* @beta
|
|
68
63
|
*/
|
|
69
64
|
async function writeArrayProperty(propertyClass, propertyValue, arrayElement, schemaDoc) {
|
|
70
65
|
if (propertyClass.isPrimitive()) {
|
|
@@ -90,13 +85,10 @@ export var XmlSerializationUtils;
|
|
|
90
85
|
* @param propertyValue The struct object holding the property values.
|
|
91
86
|
* @param structElement The XML Element that will contain the serialized property instance.
|
|
92
87
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
93
|
-
* @beta
|
|
94
88
|
*/
|
|
95
89
|
async function writeStructProperty(propertyClass, propertyValue, structElement, schemaDoc) {
|
|
96
90
|
const structClass = propertyClass.structClass;
|
|
97
|
-
|
|
98
|
-
return;
|
|
99
|
-
for (const propertyMetadata of structClass.properties)
|
|
91
|
+
for (const propertyMetadata of structClass.getPropertiesSync(true))
|
|
100
92
|
await writeInstanceProperty(propertyMetadata, propertyValue, structElement, schemaDoc);
|
|
101
93
|
}
|
|
102
94
|
XmlSerializationUtils.writeStructProperty = writeStructProperty;
|
|
@@ -105,16 +97,15 @@ export var XmlSerializationUtils;
|
|
|
105
97
|
* @param propertyClass The Property metadata object.
|
|
106
98
|
* @param propertyValue The struct object holding the property values.
|
|
107
99
|
* @param propertyElement The XML Element that will contain the serialized property instance.
|
|
108
|
-
* @beta
|
|
109
100
|
*/
|
|
110
101
|
async function writePrimitiveProperty(propertyClass, propertyValue, propertyElement) {
|
|
111
102
|
let primitiveType;
|
|
112
103
|
if (propertyClass.isEnumeration()) {
|
|
113
104
|
const enumeration = await propertyClass.enumeration;
|
|
114
105
|
if (!enumeration)
|
|
115
|
-
throw new
|
|
106
|
+
throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The enumeration on property class '${propertyClass.fullName}' could not be found in the current schema context.`);
|
|
116
107
|
if (enumeration.type === undefined)
|
|
117
|
-
throw new
|
|
108
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The enumeration on property class '${propertyClass.fullName}' has an invalid primitive type.`);
|
|
118
109
|
primitiveType = enumeration.type;
|
|
119
110
|
}
|
|
120
111
|
else
|
|
@@ -145,7 +136,7 @@ export var XmlSerializationUtils;
|
|
|
145
136
|
propertyElement.textContent = propertyValue;
|
|
146
137
|
return;
|
|
147
138
|
default:
|
|
148
|
-
throw new
|
|
139
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, `The property '${propertyClass.fullName}' has an invalid primitive type.`);
|
|
149
140
|
}
|
|
150
141
|
}
|
|
151
142
|
XmlSerializationUtils.writePrimitiveProperty = writePrimitiveProperty;
|
|
@@ -155,7 +146,7 @@ export var XmlSerializationUtils;
|
|
|
155
146
|
// Alias is required in Spec. It could be undefined (technically), so
|
|
156
147
|
// throw until fixed.
|
|
157
148
|
if (typeSchema.alias === undefined)
|
|
158
|
-
throw new
|
|
149
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaAlias, `The schema '${typeSchema.name}' has an invalid alias.`);
|
|
159
150
|
return `${typeSchema.alias}:${typeName}`;
|
|
160
151
|
}
|
|
161
152
|
XmlSerializationUtils.createXmlTypedName = createXmlTypedName;
|
|
@@ -165,7 +156,7 @@ export var XmlSerializationUtils;
|
|
|
165
156
|
return [caName, undefined];
|
|
166
157
|
const attributeSchema = nameParts[0].toUpperCase() === schema.name.toUpperCase() ? schema : await schema.getReference(nameParts[0]);
|
|
167
158
|
if (!attributeSchema)
|
|
168
|
-
throw new
|
|
159
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to resolve the namespace for CustomAttribute '${caName}' because the referenced schema '${nameParts[0]}' could not be located.`);
|
|
169
160
|
return [nameParts[1], `${nameParts[0]}.${attributeSchema.schemaKey.version.toString()}`];
|
|
170
161
|
}
|
|
171
162
|
})(XmlSerializationUtils || (XmlSerializationUt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C","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { PrimitiveType, primitiveTypeToString } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { ArrayProperty, EnumerationProperty, PrimitiveOrEnumPropertyBase, PrimitiveProperty, Property, StructProperty } from \"../Metadata/Property\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\n\r\n/**\r\n * Namespace holding utility functions for serializing EC types to the EC XML format.\r\n * @internal\r\n */\r\nexport namespace XmlSerializationUtils {\r\n /**\r\n * Serializes a CustomAttribute instance to the EC XML format.\r\n * @param fullName The full name of the CustomAttribute (qualified by schema name).\r\n * @param customAttribute The CustomAttribute instance to serialize.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n * @param schema The Schema object being serialized.\r\n * @beta\r\n */\r\n export async function writeCustomAttribute(fullName: string, customAttribute: CustomAttribute, schemaDoc: Document, schema: Schema): Promise<Element> {\r\n const caClass = await schema.lookupItem(fullName) as CustomAttributeClass;\r\n if (!caClass)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `The class '${fullName}' could not be found in the current schema context.`);\r\n\r\n const nameAndNamespace = await resolveCustomAttributeNamespace(fullName, schema);\r\n const caElement = schemaDoc.createElement(nameAndNamespace[0]);\r\n\r\n if (nameAndNamespace[1])\r\n caElement.setAttribute(\"xmlns\", nameAndNamespace[1]);\r\n\r\n if (!caClass.properties)\r\n return caElement;\r\n\r\n for (const property of caClass.properties)\r\n await writeInstanceProperty(property, customAttribute, caElement, schemaDoc);\r\n\r\n return caElement;\r\n }\r\n\r\n /**\r\n * Serializes an EC Property instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param instance The Property instance.\r\n * @param instanceElement The XML Element that will contain the serialized property instance.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n * @beta\r\n */\r\n export async function writeInstanceProperty(propertyClass: Property, instance: any, instanceElement: Element, schemaDoc: Document): Promise<void> {\r\n const propertyValue = instance[propertyClass.name];\r\n if (propertyValue === undefined)\r\n return;\r\n\r\n const propertyElement = schemaDoc.createElement(propertyClass.name);\r\n instanceElement.appendChild(propertyElement);\r\n\r\n if (propertyClass.isArray()) {\r\n await writeArrayProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\r\n } else if (propertyClass.isPrimitive()) {\r\n await writePrimitiveProperty(propertyClass, propertyValue, propertyElement);\r\n } else if (propertyClass.isStruct()) {\r\n await writeStructProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\r\n }\r\n }\r\n\r\n /**\r\n * Serializes an EC ArrayProperty instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param propertyValue An array holding the property values.\r\n * @param arrayElement The XML Element that will contain the serialized property instance.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n * @beta\r\n */\r\n export async function writeArrayProperty(propertyClass: ArrayProperty, propertyValue: any[], arrayElement: Element, schemaDoc: Document): Promise<void> {\r\n if (propertyClass.isPrimitive()) {\r\n const typeString = primitiveTypeToString(propertyClass.primitiveType);\r\n for (const value of propertyValue) {\r\n const entryElement = schemaDoc.createElement(typeString);\r\n await writePrimitiveProperty(propertyClass, value, entryElement);\r\n arrayElement.appendChild(entryElement);\r\n }\r\n }\r\n\r\n if (propertyClass.isStruct()) {\r\n for (const value of propertyValue) {\r\n const structElement = schemaDoc.createElement(propertyClass.structClass.name);\r\n arrayElement.appendChild(structElement);\r\n await writeStructProperty(propertyClass, value, structElement, schemaDoc);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes an EC StructProperty instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param propertyValue The struct object holding the property values.\r\n * @param structElement The XML Element that will contain the serialized property instance.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n * @beta\r\n */\r\n export async function writeStructProperty(propertyClass: StructProperty, propertyValue: any, structElement: Element, schemaDoc: Document): Promise<void> {\r\n const structClass = propertyClass.structClass;\r\n if (!structClass.properties)\r\n return;\r\n\r\n for (const propertyMetadata of structClass.properties)\r\n await writeInstanceProperty(propertyMetadata, propertyValue, structElement, schemaDoc);\r\n }\r\n\r\n /**\r\n * Serializes an EC PrimitiveProperty instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param propertyValue The struct object holding the property values.\r\n * @param propertyElement The XML Element that will contain the serialized property instance.\r\n * @beta\r\n */\r\n export async function writePrimitiveProperty(propertyClass: PrimitiveOrEnumPropertyBase, propertyValue: any, propertyElement: Element): Promise<void> {\r\n let primitiveType: PrimitiveType;\r\n if (propertyClass.isEnumeration()) {\r\n const enumeration = await (propertyClass as EnumerationProperty).enumeration;\r\n if (!enumeration)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `The enumeration on property class '${propertyClass.fullName}' could not be found in the current schema context.`);\r\n\r\n if (enumeration.type === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The enumeration on property class '${propertyClass.fullName}' has an invalid primitive type.`);\r\n\r\n primitiveType = enumeration.type;\r\n } else\r\n primitiveType = (propertyClass as PrimitiveProperty).primitiveType;\r\n\r\n switch (primitiveType) {\r\n case PrimitiveType.String:\r\n propertyElement.textContent = propertyValue;\r\n return;\r\n case PrimitiveType.Boolean:\r\n propertyElement.textContent = (propertyValue as boolean) ? \"True\" : \"False\";\r\n return;\r\n case PrimitiveType.Integer:\r\n case PrimitiveType.Double:\r\n case PrimitiveType.Long:\r\n propertyElement.textContent = propertyValue.toString();\r\n return;\r\n case PrimitiveType.DateTime:\r\n propertyElement.textContent = new Date(propertyValue).getTime().toString();\r\n return;\r\n case PrimitiveType.Point2d:\r\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y}`;\r\n return;\r\n case PrimitiveType.Point3d:\r\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y},${propertyValue.z}`;\r\n return;\r\n case PrimitiveType.IGeometry:\r\n case PrimitiveType.Binary:\r\n propertyElement.textContent = propertyValue;\r\n return;\r\n default:\r\n throw new ECObjectsError(ECObjectsStatus.InvalidPrimitiveType, `The property '${propertyClass.fullName}' has an invalid primitive type.`);\r\n }\r\n }\r\n\r\n export function createXmlTypedName(currentSchema: Schema, typeSchema: Schema, typeName: string) {\r\n if (currentSchema.schemaKey.matches(typeSchema.schemaKey))\r\n return typeName;\r\n\r\n // Alias is required in Spec. It could be undefined (technically), so\r\n // throw until fixed.\r\n if (typeSchema.alias === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaAlias, `The schema '${typeSchema.name}' has an invalid alias.`);\r\n\r\n return `${typeSchema.alias}:${typeName}`;\r\n }\r\n\r\n async function resolveCustomAttributeNamespace(caName: string, schema: Schema): Promise<[string, string | undefined]> {\r\n const nameParts = caName.split(\".\");\r\n if (nameParts.length === 1)\r\n return [caName, undefined];\r\n\r\n const attributeSchema = nameParts[0].toUpperCase() === schema.name.toUpperCase() ? schema : await schema.getReference(nameParts[0]);\r\n if (!attributeSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to resolve the namespace for CustomAttribute '${caName}' because the referenced schema '${nameParts[0]}' could not be located.`);\r\n\r\n return [nameParts[1], `${nameParts[0]}.${attributeSchema.schemaKey.version.toString()}`];\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"XmlSerializationUtils.js","sourceRoot":"","sources":["../../../src/Deserialization/XmlSerializationUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM7D;;;GAGG;AACH,MA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,IAAI,QAAQ,EAAE,CAAC;IAC3C,CAAC;IAVe,wCAAkB,qBAUjC,CAAA;IAED,KAAK,UAAU,+BAA+B,CAAC,MAAc,EAAE,MAAc;QAC3E,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YACxB,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAE7B,MAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACpI,IAAI,CAAC,eAAe;YAClB,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,wDAAwD,MAAM,oCAAoC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC;QAExM,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC,EAjKgB,qBAAqB,KAArB,qBAAqB,QAiKrC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PrimitiveType, primitiveTypeToString } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\nimport { ArrayProperty, EnumerationProperty, PrimitiveOrEnumPropertyBase, PrimitiveProperty, Property, StructProperty } from \"../Metadata/Property\";\nimport { Schema } from \"../Metadata/Schema\";\n\n/**\n * Namespace holding utility functions for serializing EC types to the EC XML format.\n * @internal\n */\nexport namespace XmlSerializationUtils {\n /**\n * Serializes a CustomAttribute instance to the EC XML format.\n * @param fullName The full name of the CustomAttribute (qualified by schema name).\n * @param customAttribute The CustomAttribute instance to serialize.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n * @param schema The Schema object being serialized.\n */\n export async function writeCustomAttribute(fullName: string, customAttribute: CustomAttribute, schemaDoc: Document, schema: Schema): Promise<Element> {\n const caClass = await schema.lookupItem(fullName) as CustomAttributeClass;\n if (!caClass)\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The class '${fullName}' could not be found in the current schema context.`);\n\n const nameAndNamespace = await resolveCustomAttributeNamespace(fullName, schema);\n const caElement = schemaDoc.createElement(nameAndNamespace[0]);\n\n if (nameAndNamespace[1])\n caElement.setAttribute(\"xmlns\", nameAndNamespace[1]);\n\n for (const property of await caClass.getProperties())\n await writeInstanceProperty(property, customAttribute, caElement, schemaDoc);\n\n return caElement;\n }\n\n /**\n * Serializes an EC Property instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param instance The Property instance.\n * @param instanceElement The XML Element that will contain the serialized property instance.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n */\n export async function writeInstanceProperty(propertyClass: Property, instance: any, instanceElement: Element, schemaDoc: Document): Promise<void> {\n const propertyValue = instance[propertyClass.name];\n if (propertyValue === undefined)\n return;\n\n const propertyElement = schemaDoc.createElement(propertyClass.name);\n instanceElement.appendChild(propertyElement);\n\n if (propertyClass.isArray()) {\n await writeArrayProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\n } else if (propertyClass.isPrimitive()) {\n await writePrimitiveProperty(propertyClass, propertyValue, propertyElement);\n } else if (propertyClass.isStruct()) {\n await writeStructProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\n }\n }\n\n /**\n * Serializes an EC ArrayProperty instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param propertyValue An array holding the property values.\n * @param arrayElement The XML Element that will contain the serialized property instance.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n */\n export async function writeArrayProperty(propertyClass: ArrayProperty, propertyValue: any[], arrayElement: Element, schemaDoc: Document): Promise<void> {\n if (propertyClass.isPrimitive()) {\n const typeString = primitiveTypeToString(propertyClass.primitiveType);\n for (const value of propertyValue) {\n const entryElement = schemaDoc.createElement(typeString);\n await writePrimitiveProperty(propertyClass, value, entryElement);\n arrayElement.appendChild(entryElement);\n }\n }\n\n if (propertyClass.isStruct()) {\n for (const value of propertyValue) {\n const structElement = schemaDoc.createElement(propertyClass.structClass.name);\n arrayElement.appendChild(structElement);\n await writeStructProperty(propertyClass, value, structElement, schemaDoc);\n }\n }\n }\n\n /**\n * Serializes an EC StructProperty instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param propertyValue The struct object holding the property values.\n * @param structElement The XML Element that will contain the serialized property instance.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n */\n export async function writeStructProperty(propertyClass: StructProperty, propertyValue: any, structElement: Element, schemaDoc: Document): Promise<void> {\n const structClass = propertyClass.structClass;\n for (const propertyMetadata of structClass.getPropertiesSync(true))\n await writeInstanceProperty(propertyMetadata, propertyValue, structElement, schemaDoc);\n }\n\n /**\n * Serializes an EC PrimitiveProperty instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param propertyValue The struct object holding the property values.\n * @param propertyElement The XML Element that will contain the serialized property instance.\n */\n export async function writePrimitiveProperty(propertyClass: PrimitiveOrEnumPropertyBase, propertyValue: any, propertyElement: Element): Promise<void> {\n let primitiveType: PrimitiveType;\n if (propertyClass.isEnumeration()) {\n const enumeration = await (propertyClass as EnumerationProperty).enumeration;\n if (!enumeration)\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The enumeration on property class '${propertyClass.fullName}' could not be found in the current schema context.`);\n\n if (enumeration.type === undefined)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The enumeration on property class '${propertyClass.fullName}' has an invalid primitive type.`);\n\n primitiveType = enumeration.type;\n } else\n primitiveType = (propertyClass as PrimitiveProperty).primitiveType;\n\n switch (primitiveType) {\n case PrimitiveType.String:\n propertyElement.textContent = propertyValue;\n return;\n case PrimitiveType.Boolean:\n propertyElement.textContent = (propertyValue as boolean) ? \"True\" : \"False\";\n return;\n case PrimitiveType.Integer:\n case PrimitiveType.Double:\n case PrimitiveType.Long:\n propertyElement.textContent = propertyValue.toString();\n return;\n case PrimitiveType.DateTime:\n propertyElement.textContent = new Date(propertyValue).getTime().toString();\n return;\n case PrimitiveType.Point2d:\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y}`;\n return;\n case PrimitiveType.Point3d:\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y},${propertyValue.z}`;\n return;\n case PrimitiveType.IGeometry:\n case PrimitiveType.Binary:\n propertyElement.textContent = propertyValue;\n return;\n default:\n throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, `The property '${propertyClass.fullName}' has an invalid primitive type.`);\n }\n }\n\n export function createXmlTypedName(currentSchema: Schema, typeSchema: Schema, typeName: string) {\n if (currentSchema.schemaKey.matches(typeSchema.schemaKey))\n return typeName;\n\n // Alias is required in Spec. It could be undefined (technically), so\n // throw until fixed.\n if (typeSchema.alias === undefined)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaAlias, `The schema '${typeSchema.name}' has an invalid alias.`);\n\n return `${typeSchema.alias}:${typeName}`;\n }\n\n async function resolveCustomAttributeNamespace(caName: string, schema: Schema): Promise<[string, string | undefined]> {\n const nameParts = caName.split(\".\");\n if (nameParts.length === 1)\n return [caName, undefined];\n\n const attributeSchema = nameParts[0].toUpperCase() === schema.name.toUpperCase() ? schema : await schema.getReference(nameParts[0]);\n if (!attributeSchema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to resolve the namespace for CustomAttribute '${caName}' because the referenced schema '${nameParts[0]}' could not be located.`);\n\n return [nameParts[1], `${nameParts[0]}.${attributeSchema.schemaKey.version.toString()}`];\n }\n}\n"]}
|
package/lib/esm/ECName.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
export declare class ECName {
|
|
15
15
|
private _name;
|
|
16
16
|
/** Construct a new ECName from a valid EC name.
|
|
17
|
-
* throws
|
|
17
|
+
* throws ECSchemaError if `name` does not meet the criteria for a valid EC name.
|
|
18
18
|
*/
|
|
19
19
|
constructor(name: string);
|
|
20
20
|
/** Returns true if a string meets the criteria of a valid EC name. */
|
|
@@ -22,7 +22,7 @@ export declare class ECName {
|
|
|
22
22
|
/** The underlying name as a string. */
|
|
23
23
|
get name(): string;
|
|
24
24
|
/** Create an ECName from an arbitrary string, encoding any special characters as "__x####__" where "####" is the UTF-16 character code.
|
|
25
|
-
* @throws
|
|
25
|
+
* @throws ECSchemaError if `input` is an empty string.
|
|
26
26
|
*/
|
|
27
27
|
static encode(input: string): ECName;
|
|
28
28
|
/** Decode this ECName, replacing encoded special characters with the characters they encode. */
|
package/lib/esm/ECName.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
8
|
import { assert } from "@itwin/core-bentley";
|
|
9
|
-
import {
|
|
9
|
+
import { ECSchemaError, ECSchemaStatus } from "./Exception";
|
|
10
10
|
const validECNameRegex = /^([a-zA-Z_]+[a-zA-Z0-9_]*)$/i;
|
|
11
11
|
const ecNameReplacerRegex = /__x([0-9a-fA-F]{4})__/g;
|
|
12
12
|
const leadingDigits = ["0000", "000", "00", "0", ""];
|
|
@@ -29,12 +29,13 @@ function isValidAlphaNumericCharacter(c) {
|
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
31
|
export class ECName {
|
|
32
|
+
_name;
|
|
32
33
|
/** Construct a new ECName from a valid EC name.
|
|
33
|
-
* throws
|
|
34
|
+
* throws ECSchemaError if `name` does not meet the criteria for a valid EC name.
|
|
34
35
|
*/
|
|
35
36
|
constructor(name) {
|
|
36
37
|
if (!ECName.validate(name))
|
|
37
|
-
throw new
|
|
38
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName);
|
|
38
39
|
this._name = name;
|
|
39
40
|
}
|
|
40
41
|
/** Returns true if a string meets the criteria of a valid EC name. */
|
|
@@ -46,11 +47,11 @@ export class ECName {
|
|
|
46
47
|
return this._name;
|
|
47
48
|
}
|
|
48
49
|
/** Create an ECName from an arbitrary string, encoding any special characters as "__x####__" where "####" is the UTF-16 character code.
|
|
49
|
-
* @throws
|
|
50
|
+
* @throws ECSchemaError if `input` is an empty string.
|
|
50
51
|
*/
|
|
51
52
|
static encode(input) {
|
|
52
53
|
if (0 === input.length)
|
|
53
|
-
throw new
|
|
54
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName);
|
|
54
55
|
if (ECName.validate(input)) {
|
|
55
56
|
// It's already a valid EC name.
|
|
56
57
|
return new ECName(input);
|
package/lib/esm/ECName.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECName.js","sourceRoot":"","sources":["../../src/ECName.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ECName.js","sourceRoot":"","sources":["../../src/ECName.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACxD,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AACrD,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAErD,SAAS,OAAO,CAAC,SAAiB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IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,SAAS,sBAAsB,CAAC,KAAa;YAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;YAC/D,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACzC,MAAM,IAAI,MAAM,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC;QACtD,CAAC;QAED,qCAAqC;QACrC,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,gBAAgB;YAClB,sBAAsB,CAAC,CAAC,CAAC,CAAC;QAE5B,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC;gBACrC,sBAAsB,CAAC,CAAC,CAAC,CAAC;;gBAE1B,MAAM,IAAI,IAAI,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,gGAAgG;IACzF,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAChH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\n\nconst validECNameRegex = /^([a-zA-Z_]+[a-zA-Z0-9_]*)$/i;\nconst ecNameReplacerRegex = /__x([0-9a-fA-F]{4})__/g;\nconst leadingDigits = [\"0000\", \"000\", \"00\", \"0\", \"\"];\n\nfunction isDigit(character: string): boolean {\n assert(1 === character.length);\n return character >= \"0\" && character <= \"9\";\n}\n\nfunction isValidAlphaNumericCharacter(c: string): boolean {\n assert(1 === c.length);\n return (((c >= \"0\" && c <= \"9\") || (c >= \"A\" && c <= \"Z\") || (c >= \"a\" && c <= \"z\") || c === \"_\"));\n}\n\n/** The name of an item in a [[Schema]], encoded to meet restrictions on the characters usable in such names.\n * An ECName meets the following criteria:\n * - Contains at least one character.\n * - Does not begin with a digit.\n * - Consists entirely of characters in the ASCII ranges A-Z, a-z, and 0-9; and the underscore (\"_\") character.\n *\n * All characters not meeting the above criteria are encoded as \"__x####__\" where \"####\" is the UTF-16 character code.\n * Such names are often automatically generated from the item's display label, which is unrestricted in the characters it may contain.\n * @public\n */\nexport class ECName {\n private _name: string;\n\n /** Construct a new ECName from a valid EC name.\n * throws ECSchemaError if `name` does not meet the criteria for a valid EC name.\n */\n constructor(name: string) {\n if (!ECName.validate(name))\n throw new ECSchemaError(ECSchemaStatus.InvalidECName);\n\n this._name = name;\n }\n\n /** Returns true if a string meets the criteria of a valid EC name. */\n public static validate(name: string): boolean {\n return validECNameRegex.test(name);\n }\n\n /** The underlying name as a string. */\n public get name(): string {\n return this._name;\n }\n\n /** Create an ECName from an arbitrary string, encoding any special characters as \"__x####__\" where \"####\" is the UTF-16 character code.\n * @throws ECSchemaError if `input` is an empty string.\n */\n public static encode(input: string): ECName {\n if (0 === input.length)\n throw new ECSchemaError(ECSchemaStatus.InvalidECName);\n\n if (ECName.validate(input)) {\n // It's already a valid EC name.\n return new ECName(input);\n }\n\n let output = \"\";\n\n function appendEncodedCharacter(index: number): void {\n const hex = input.charCodeAt(index).toString(16).toUpperCase();\n assert(hex.length > 0 && hex.length < 5);\n output += `__x${leadingDigits[hex.length]}${hex}__`;\n }\n\n // First character cannot be a digit.\n const firstCharIsDigit = isDigit(input[0]);\n if (firstCharIsDigit)\n appendEncodedCharacter(0);\n\n for (let i = firstCharIsDigit ? 1 : 0; i < input.length; i++) {\n const char = input[i];\n if (!isValidAlphaNumericCharacter(char))\n appendEncodedCharacter(i);\n else\n output += char;\n }\n\n return new ECName(output);\n }\n\n /** Decode this ECName, replacing encoded special characters with the characters they encode. */\n public decode(): string {\n return this.name.replace(ecNameReplacerRegex, (_match, hex) => String.fromCharCode(Number.parseInt(hex, 16)));\n }\n}\n"]}
|
package/lib/esm/ECObjects.d.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* @module Metadata
|
|
3
3
|
*/
|
|
4
4
|
export { PropertyType } from "./PropertyTypes";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Identifies a class as abstract or sealed
|
|
7
|
+
*
|
|
8
|
+
* @public @preview
|
|
9
|
+
*/
|
|
6
10
|
export declare enum ECClassModifier {
|
|
7
11
|
None = 0,
|
|
8
12
|
Abstract = 1,
|
|
@@ -10,7 +14,10 @@ export declare enum ECClassModifier {
|
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
16
|
* An enumeration that has all the schema item type names as values
|
|
13
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* @enum {string}
|
|
19
|
+
* @public @preview
|
|
20
|
+
*/
|
|
14
21
|
export declare enum SchemaItemType {
|
|
15
22
|
EntityClass = "EntityClass",
|
|
16
23
|
Mixin = "Mixin",
|
|
@@ -27,9 +34,22 @@ export declare enum SchemaItemType {
|
|
|
27
34
|
UnitSystem = "UnitSystem",
|
|
28
35
|
Format = "Format"
|
|
29
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Additional Schema Item Types which define classes of item types
|
|
39
|
+
* @public @preview
|
|
40
|
+
*/
|
|
41
|
+
export declare enum AbstractSchemaItemType {
|
|
42
|
+
Class = "Class",
|
|
43
|
+
SchemaItem = "SchemaItem"
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Defines types of items that may be provided to identify supported items
|
|
47
|
+
* @public @preview
|
|
48
|
+
*/
|
|
49
|
+
export type SupportedSchemaItemType = SchemaItemType | AbstractSchemaItemType;
|
|
30
50
|
/**
|
|
31
51
|
* Primitive data types for ECProperties.
|
|
32
|
-
* @
|
|
52
|
+
* @public @preview
|
|
33
53
|
*/
|
|
34
54
|
export declare enum PrimitiveType {
|
|
35
55
|
Uninitialized = 0,
|
|
@@ -46,7 +66,7 @@ export declare enum PrimitiveType {
|
|
|
46
66
|
}
|
|
47
67
|
/**
|
|
48
68
|
* Defines the valid CustomAttribute container types.
|
|
49
|
-
* @
|
|
69
|
+
* @public @preview
|
|
50
70
|
*/
|
|
51
71
|
export declare enum CustomAttributeContainerType {
|
|
52
72
|
Schema = 1,
|
|
@@ -68,7 +88,7 @@ export declare enum CustomAttributeContainerType {
|
|
|
68
88
|
}
|
|
69
89
|
/**
|
|
70
90
|
* Defines what sort of match should be used when locating a schema.
|
|
71
|
-
* @
|
|
91
|
+
* @public @preview
|
|
72
92
|
*/
|
|
73
93
|
export declare enum SchemaMatchType {
|
|
74
94
|
Identical = 0,
|
|
@@ -79,21 +99,29 @@ export declare enum SchemaMatchType {
|
|
|
79
99
|
}
|
|
80
100
|
/**
|
|
81
101
|
* Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.
|
|
82
|
-
* @
|
|
102
|
+
* @public @preview
|
|
83
103
|
*/
|
|
84
104
|
export declare enum RelationshipEnd {
|
|
85
105
|
Source = 0,
|
|
86
106
|
Target = 1
|
|
87
107
|
}
|
|
88
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Defines the how the lifetime of the source and target are related.
|
|
110
|
+
*
|
|
111
|
+
* @public @preview */
|
|
89
112
|
export declare enum StrengthType {
|
|
90
113
|
Referencing = 0,
|
|
91
114
|
Holding = 1,
|
|
92
115
|
Embedding = 2
|
|
93
116
|
}
|
|
94
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Defines the which side of the relationship is the starting point of the relationship. This impacts how relationship strength is applied.
|
|
119
|
+
*
|
|
120
|
+
* @public @preview */
|
|
95
121
|
export declare enum StrengthDirection {
|
|
122
|
+
/** The source is the starting point of the relationship. */
|
|
96
123
|
Forward = 1,
|
|
124
|
+
/** The target is the starting point of the relationship. */
|
|
97
125
|
Backward = 2
|
|
98
126
|
}
|
|
99
127
|
/**
|
|
@@ -152,7 +180,7 @@ export declare function parseRelationshipEnd(end: string): RelationshipEnd | und
|
|
|
152
180
|
export declare function relationshipEndToString(end: RelationshipEnd): string;
|
|
153
181
|
/**
|
|
154
182
|
* Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.
|
|
155
|
-
* @throws
|
|
183
|
+
* @throws ECSchemaStatus.InvalidStrength if the provided string that is not valid
|
|
156
184
|
* @param strength
|
|
157
185
|
* @beta
|
|
158
186
|
*/
|
|
@@ -163,4 +191,8 @@ export declare function strengthToString(strength: StrengthType): string;
|
|
|
163
191
|
export declare function parseStrengthDirection(direction: string): StrengthDirection | undefined;
|
|
164
192
|
/** @beta */
|
|
165
193
|
export declare function strengthDirectionToString(direction: StrengthDirection): string;
|
|
194
|
+
/** Compares a SchemaItemType against supported type.
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
export declare function isSupportedSchemaItemType(value: SchemaItemType, supported: SupportedSchemaItemType): boolean;
|
|
166
198
|
//# sourceMappingURL=ECObjects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECObjects.d.ts","sourceRoot":"","sources":["../../src/ECObjects.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,YAAY,EAAE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ACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,4BAA4B,GAAG,MAAM,CAuDhF;AAED,YAAY;AACZ,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAM7E;AAED,YAAY;AACZ,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAOxE;AAED,YAAY;AACZ,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAQ/D;AAED,YAAY;AACZ,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAMvF;AAED,YAAY;AACZ,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAO9E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,uBAAuB,GAAG,OAAO,CAiB5G"}
|
package/lib/esm/ECObjects.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
8
|
import { ECStringConstants } from "./Constants";
|
|
9
|
-
import {
|
|
9
|
+
import { ECSchemaError, ECSchemaStatus } from "./Exception";
|
|
10
10
|
export { PropertyType } from "./PropertyTypes";
|
|
11
11
|
// NEEDSWORK: This shim is currently required to use async iterators. See https://github.com/Microsoft/TypeScript/issues/14151
|
|
12
12
|
if (!Symbol.asyncIterator) {
|
|
13
13
|
Symbol.asyncIterator = Symbol.for("Symbol.asyncIterator");
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Identifies a class as abstract or sealed
|
|
17
|
+
*
|
|
18
|
+
* @public @preview
|
|
19
|
+
*/
|
|
16
20
|
export var ECClassModifier;
|
|
17
21
|
(function (ECClassModifier) {
|
|
22
|
+
/* normal, instantiable class, can be subclassed */
|
|
18
23
|
ECClassModifier[ECClassModifier["None"] = 0] = "None";
|
|
24
|
+
/* abstract class, cannot be instantiated, can be subclassed */
|
|
19
25
|
ECClassModifier[ECClassModifier["Abstract"] = 1] = "Abstract";
|
|
26
|
+
/* sealed class, instantiable class, cannot be subclassed */
|
|
20
27
|
ECClassModifier[ECClassModifier["Sealed"] = 2] = "Sealed";
|
|
21
28
|
})(ECClassModifier || (ECClassModifier = {}));
|
|
22
29
|
/**
|
|
23
30
|
* An enumeration that has all the schema item type names as values
|
|
24
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* @enum {string}
|
|
33
|
+
* @public @preview
|
|
34
|
+
*/
|
|
25
35
|
export var SchemaItemType;
|
|
26
36
|
(function (SchemaItemType) {
|
|
27
37
|
SchemaItemType["EntityClass"] = "EntityClass";
|
|
@@ -39,9 +49,20 @@ export var SchemaItemType;
|
|
|
39
49
|
SchemaItemType["UnitSystem"] = "UnitSystem";
|
|
40
50
|
SchemaItemType["Format"] = "Format";
|
|
41
51
|
})(SchemaItemType || (SchemaItemType = {}));
|
|
52
|
+
/**
|
|
53
|
+
* Additional Schema Item Types which define classes of item types
|
|
54
|
+
* @public @preview
|
|
55
|
+
*/
|
|
56
|
+
export var AbstractSchemaItemType;
|
|
57
|
+
(function (AbstractSchemaItemType) {
|
|
58
|
+
/* Item is EntityClass, Mixin, StructClass, CustomAttributeClass, or RelationshipClass */
|
|
59
|
+
AbstractSchemaItemType["Class"] = "Class";
|
|
60
|
+
/* Any item type including the Class types */
|
|
61
|
+
AbstractSchemaItemType["SchemaItem"] = "SchemaItem";
|
|
62
|
+
})(AbstractSchemaItemType || (AbstractSchemaItemType = {}));
|
|
42
63
|
/**
|
|
43
64
|
* Primitive data types for ECProperties.
|
|
44
|
-
* @
|
|
65
|
+
* @public @preview
|
|
45
66
|
*/
|
|
46
67
|
export var PrimitiveType;
|
|
47
68
|
(function (PrimitiveType) {
|
|
@@ -59,7 +80,7 @@ export var PrimitiveType;
|
|
|
59
80
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
60
81
|
/**
|
|
61
82
|
* Defines the valid CustomAttribute container types.
|
|
62
|
-
* @
|
|
83
|
+
* @public @preview
|
|
63
84
|
*/
|
|
64
85
|
export var CustomAttributeContainerType;
|
|
65
86
|
(function (CustomAttributeContainerType) {
|
|
@@ -82,14 +103,14 @@ export var CustomAttributeContainerType;
|
|
|
82
103
|
})(CustomAttributeContainerType || (CustomAttributeContainerType = {}));
|
|
83
104
|
/**
|
|
84
105
|
* Defines what sort of match should be used when locating a schema.
|
|
85
|
-
* @
|
|
106
|
+
* @public @preview
|
|
86
107
|
*/
|
|
87
108
|
export var SchemaMatchType;
|
|
88
109
|
(function (SchemaMatchType) {
|
|
89
110
|
/*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
* Find exact VersionRead, VersionWrite, VersionMinor match as well as Data. NOTE data is not yet matched
|
|
112
|
+
* @deprecated in 4.10 Use Exact instead.
|
|
113
|
+
*/
|
|
93
114
|
SchemaMatchType[SchemaMatchType["Identical"] = 0] = "Identical";
|
|
94
115
|
/* Find exact VersionRead, VersionWrite, VersionMinor match. */
|
|
95
116
|
SchemaMatchType[SchemaMatchType["Exact"] = 1] = "Exact";
|
|
@@ -102,24 +123,32 @@ export var SchemaMatchType;
|
|
|
102
123
|
})(SchemaMatchType || (SchemaMatchType = {}));
|
|
103
124
|
/**
|
|
104
125
|
* Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.
|
|
105
|
-
* @
|
|
126
|
+
* @public @preview
|
|
106
127
|
*/
|
|
107
128
|
export var RelationshipEnd;
|
|
108
129
|
(function (RelationshipEnd) {
|
|
109
130
|
RelationshipEnd[RelationshipEnd["Source"] = 0] = "Source";
|
|
110
131
|
RelationshipEnd[RelationshipEnd["Target"] = 1] = "Target";
|
|
111
132
|
})(RelationshipEnd || (RelationshipEnd = {}));
|
|
112
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Defines the how the lifetime of the source and target are related.
|
|
135
|
+
*
|
|
136
|
+
* @public @preview */
|
|
113
137
|
export var StrengthType;
|
|
114
138
|
(function (StrengthType) {
|
|
115
139
|
StrengthType[StrengthType["Referencing"] = 0] = "Referencing";
|
|
116
140
|
StrengthType[StrengthType["Holding"] = 1] = "Holding";
|
|
117
141
|
StrengthType[StrengthType["Embedding"] = 2] = "Embedding";
|
|
118
142
|
})(StrengthType || (StrengthType = {}));
|
|
119
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Defines the which side of the relationship is the starting point of the relationship. This impacts how relationship strength is applied.
|
|
145
|
+
*
|
|
146
|
+
* @public @preview */
|
|
120
147
|
export var StrengthDirection;
|
|
121
148
|
(function (StrengthDirection) {
|
|
149
|
+
/** The source is the starting point of the relationship. */
|
|
122
150
|
StrengthDirection[StrengthDirection["Forward"] = 1] = "Forward";
|
|
151
|
+
/** The target is the starting point of the relationship. */
|
|
123
152
|
StrengthDirection[StrengthDirection["Backward"] = 2] = "Backward";
|
|
124
153
|
})(StrengthDirection || (StrengthDirection = {}));
|
|
125
154
|
// Helper methods for going to/from string for the above Enumerations.
|
|
@@ -146,7 +175,8 @@ export function classModifierToString(modifier) {
|
|
|
146
175
|
case ECClassModifier.Abstract: return "Abstract";
|
|
147
176
|
case ECClassModifier.None: return "None";
|
|
148
177
|
case ECClassModifier.Sealed: return "Sealed";
|
|
149
|
-
default:
|
|
178
|
+
default:
|
|
179
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidModifier, "An invalid ECClassModifier has been provided.");
|
|
150
180
|
}
|
|
151
181
|
}
|
|
152
182
|
/**
|
|
@@ -201,7 +231,8 @@ export function schemaItemTypeToXmlString(value) {
|
|
|
201
231
|
case SchemaItemType.Phenomenon: return "Phenomenon";
|
|
202
232
|
case SchemaItemType.UnitSystem: return "UnitSystem";
|
|
203
233
|
case SchemaItemType.Format: return "Format";
|
|
204
|
-
default:
|
|
234
|
+
default:
|
|
235
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, "An invalid SchemaItemType has been provided.");
|
|
205
236
|
}
|
|
206
237
|
}
|
|
207
238
|
/**
|
|
@@ -239,7 +270,8 @@ export function primitiveTypeToString(type) {
|
|
|
239
270
|
case PrimitiveType.Point2d: return "point2d";
|
|
240
271
|
case PrimitiveType.Point3d: return "point3d";
|
|
241
272
|
case PrimitiveType.String: return "string";
|
|
242
|
-
default:
|
|
273
|
+
default:
|
|
274
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, "An invalid PrimitiveType has been provided.");
|
|
243
275
|
}
|
|
244
276
|
}
|
|
245
277
|
/**
|
|
@@ -305,7 +337,7 @@ export function parseCustomAttributeContainerType(type) {
|
|
|
305
337
|
containerType = containerType | CustomAttributeContainerType.Any;
|
|
306
338
|
break;
|
|
307
339
|
default:
|
|
308
|
-
throw new
|
|
340
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${typeToken} is not a valid CustomAttributeContainerType value.`);
|
|
309
341
|
}
|
|
310
342
|
});
|
|
311
343
|
return containerType;
|
|
@@ -318,7 +350,7 @@ export function parseCustomAttributeContainerType(type) {
|
|
|
318
350
|
*/
|
|
319
351
|
export function containerTypeToString(type) {
|
|
320
352
|
const testContainerTypeValue = (compareType, otherType) => {
|
|
321
|
-
return
|
|
353
|
+
return compareType === (compareType & otherType);
|
|
322
354
|
};
|
|
323
355
|
if (testContainerTypeValue(CustomAttributeContainerType.Any, type))
|
|
324
356
|
return ECStringConstants.CONTAINERTYPE_ANY;
|
|
@@ -380,12 +412,13 @@ export function relationshipEndToString(end) {
|
|
|
380
412
|
switch (end) {
|
|
381
413
|
case RelationshipEnd.Source: return ECStringConstants.RELATIONSHIP_END_SOURCE;
|
|
382
414
|
case RelationshipEnd.Target: return ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
383
|
-
default:
|
|
415
|
+
default:
|
|
416
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidRelationshipEnd, `An invalid RelationshipEnd has been provided.`);
|
|
384
417
|
}
|
|
385
418
|
}
|
|
386
419
|
/**
|
|
387
420
|
* Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.
|
|
388
|
-
* @throws
|
|
421
|
+
* @throws ECSchemaStatus.InvalidStrength if the provided string that is not valid
|
|
389
422
|
* @param strength
|
|
390
423
|
* @beta
|
|
391
424
|
*/
|
|
@@ -403,7 +436,8 @@ export function strengthToString(strength) {
|
|
|
403
436
|
case StrengthType.Embedding: return "Embedding";
|
|
404
437
|
case StrengthType.Holding: return "Holding";
|
|
405
438
|
case StrengthType.Referencing: return "Referencing";
|
|
406
|
-
default:
|
|
439
|
+
default:
|
|
440
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidStrength, `An invalid Strength has been provided.`);
|
|
407
441
|
}
|
|
408
442
|
}
|
|
409
443
|
/** @beta */
|
|
@@ -419,7 +453,26 @@ export function strengthDirectionToString(direction) {
|
|
|
419
453
|
switch (direction) {
|
|
420
454
|
case StrengthDirection.Forward: return "Forward";
|
|
421
455
|
case StrengthDirection.Backward: return "Backward";
|
|
422
|
-
default:
|
|
456
|
+
default:
|
|
457
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `An invalid StrengthDirection has been provided.`);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/** Compares a SchemaItemType against supported type.
|
|
461
|
+
* @beta
|
|
462
|
+
*/
|
|
463
|
+
export function isSupportedSchemaItemType(value, supported) {
|
|
464
|
+
if (value === supported)
|
|
465
|
+
return true;
|
|
466
|
+
if (supported === AbstractSchemaItemType.Class && (value === SchemaItemType.EntityClass ||
|
|
467
|
+
value === SchemaItemType.Mixin ||
|
|
468
|
+
value === SchemaItemType.StructClass ||
|
|
469
|
+
value === SchemaItemType.CustomAttributeClass ||
|
|
470
|
+
value === SchemaItemType.RelationshipClass)) {
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
if (supported === AbstractSchemaItemType.SchemaItem) {
|
|
474
|
+
return true;
|
|
423
475
|
}
|
|
476
|
+
return false;
|
|
424
477
|
}
|
|
425
478
|
//# sourceMappingURL=ECObjects.js.map
|