@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import {
|
|
5
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
6
6
|
import { ECName } from "../ECName";
|
|
7
7
|
import { AbstractParser } from "./AbstractParser";
|
|
8
8
|
import { SchemaReadHelper } from "./Helper";
|
|
@@ -12,10 +12,13 @@ function isObject(x) {
|
|
|
12
12
|
const SCHEMAURL_JSON = "https://dev\\.bentley\\.com/json_schemas/ec";
|
|
13
13
|
/** @internal */
|
|
14
14
|
export class JsonParser extends AbstractParser {
|
|
15
|
+
_rawSchema;
|
|
16
|
+
_schemaName;
|
|
17
|
+
_currentItemFullName;
|
|
15
18
|
constructor(rawSchema) {
|
|
16
19
|
super();
|
|
17
20
|
if (!isObject(rawSchema))
|
|
18
|
-
throw new
|
|
21
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Invalid JSON object.`);
|
|
19
22
|
this._rawSchema = rawSchema;
|
|
20
23
|
this._schemaName = rawSchema.name;
|
|
21
24
|
this._ecSpecVersion = JsonParser.parseJSUri(rawSchema.$schema);
|
|
@@ -38,28 +41,28 @@ export class JsonParser extends AbstractParser {
|
|
|
38
41
|
*/
|
|
39
42
|
parseSchema() {
|
|
40
43
|
if (undefined === this._rawSchema.name)
|
|
41
|
-
throw new
|
|
44
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `An ECSchema is missing the required 'name' attribute.`);
|
|
42
45
|
if (typeof (this._rawSchema.name) !== "string")
|
|
43
|
-
throw new
|
|
46
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `An ECSchema has an invalid 'name' attribute. It should be of type 'string'.`);
|
|
44
47
|
if (undefined === this._rawSchema.$schema)
|
|
45
|
-
throw new
|
|
48
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required '$schema' attribute.`);
|
|
46
49
|
if (typeof (this._rawSchema.$schema) !== "string")
|
|
47
|
-
throw new
|
|
50
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid '$schema' attribute. It should be of type 'string'.`);
|
|
48
51
|
if (undefined === this._rawSchema.version)
|
|
49
|
-
throw new
|
|
52
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required 'version' attribute.`);
|
|
50
53
|
if (typeof (this._rawSchema.version) !== "string")
|
|
51
|
-
throw new
|
|
54
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'version' attribute. It should be of type 'string'.`);
|
|
52
55
|
if (undefined !== this._rawSchema.alias) {
|
|
53
56
|
if (typeof (this._rawSchema.alias) !== "string")
|
|
54
|
-
throw new
|
|
57
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'alias' attribute. It should be of type 'string'.`);
|
|
55
58
|
}
|
|
56
59
|
if (undefined !== this._rawSchema.label) {
|
|
57
60
|
if (typeof (this._rawSchema.label) !== "string")
|
|
58
|
-
throw new
|
|
61
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
59
62
|
}
|
|
60
63
|
if (undefined !== this._rawSchema.description) {
|
|
61
64
|
if (typeof (this._rawSchema.description) !== "string")
|
|
62
|
-
throw new
|
|
65
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'description' attribute. It should be of type 'string'.`);
|
|
63
66
|
}
|
|
64
67
|
const ecVersions = JsonParser.parseJSUri(this._rawSchema.$schema);
|
|
65
68
|
return {
|
|
@@ -71,7 +74,7 @@ export class JsonParser extends AbstractParser {
|
|
|
71
74
|
*getReferences() {
|
|
72
75
|
if (undefined !== this._rawSchema.references) {
|
|
73
76
|
if (!Array.isArray(this._rawSchema.references))
|
|
74
|
-
throw new
|
|
77
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._rawSchema.name} has an invalid 'references' attribute. It should be of type 'object[]'.`);
|
|
75
78
|
for (const ref of this._rawSchema.references) {
|
|
76
79
|
yield this.checkSchemaReference(ref);
|
|
77
80
|
}
|
|
@@ -79,33 +82,33 @@ export class JsonParser extends AbstractParser {
|
|
|
79
82
|
}
|
|
80
83
|
checkSchemaReference(jsonObj) {
|
|
81
84
|
if (!isObject(jsonObj))
|
|
82
|
-
throw new
|
|
85
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. It should be of type 'object[]'.`);
|
|
83
86
|
if (undefined === jsonObj.name)
|
|
84
|
-
throw new
|
|
87
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'name' attribute.`);
|
|
85
88
|
if (typeof (jsonObj.name) !== "string")
|
|
86
|
-
throw new
|
|
89
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references has an invalid 'name' attribute. It should be of type 'string'.`);
|
|
87
90
|
if (undefined === jsonObj.version)
|
|
88
|
-
throw new
|
|
91
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'version' attribute.`);
|
|
89
92
|
if (typeof (jsonObj.version) !== "string")
|
|
90
|
-
throw new
|
|
93
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references has an invalid 'version' attribute. It should be of type 'string'.`);
|
|
91
94
|
return jsonObj;
|
|
92
95
|
}
|
|
93
96
|
*getItems() {
|
|
94
97
|
const items = this._rawSchema.items;
|
|
95
98
|
if (undefined !== items) {
|
|
96
99
|
if (!isObject(items) || Array.isArray(items))
|
|
97
|
-
throw new
|
|
100
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
|
|
98
101
|
// eslint-disable-next-line guard-for-in
|
|
99
102
|
for (const itemName in items) {
|
|
100
103
|
const item = items[itemName];
|
|
101
104
|
if (!isObject(item))
|
|
102
|
-
throw new
|
|
105
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
|
|
103
106
|
if (!ECName.validate(itemName))
|
|
104
|
-
throw new
|
|
107
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
|
|
105
108
|
if (undefined === item.schemaItemType)
|
|
106
|
-
throw new
|
|
109
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
|
|
107
110
|
if (typeof (item.schemaItemType) !== "string")
|
|
108
|
-
throw new
|
|
111
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
|
|
109
112
|
this._currentItemFullName = `${this._schemaName}.${itemName}`;
|
|
110
113
|
yield [itemName, item.schemaItemType, item];
|
|
111
114
|
}
|
|
@@ -115,17 +118,17 @@ export class JsonParser extends AbstractParser {
|
|
|
115
118
|
const items = this._rawSchema.items;
|
|
116
119
|
if (undefined !== items) {
|
|
117
120
|
if (!isObject(items) || Array.isArray(items))
|
|
118
|
-
throw new
|
|
121
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
|
|
119
122
|
const item = items[itemName];
|
|
120
123
|
if (undefined !== item) {
|
|
121
124
|
if (!isObject(item))
|
|
122
|
-
throw new
|
|
125
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
|
|
123
126
|
if (!ECName.validate(itemName))
|
|
124
|
-
throw new
|
|
127
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
|
|
125
128
|
if (undefined === item.schemaItemType)
|
|
126
|
-
throw new
|
|
129
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
|
|
127
130
|
if (typeof (item.schemaItemType) !== "string")
|
|
128
|
-
throw new
|
|
131
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
|
|
129
132
|
this._currentItemFullName = `${this._schemaName}.${itemName}`;
|
|
130
133
|
return [itemName, item.schemaItemType, item];
|
|
131
134
|
}
|
|
@@ -139,33 +142,33 @@ export class JsonParser extends AbstractParser {
|
|
|
139
142
|
checkSchemaItemProps(jsonObj) {
|
|
140
143
|
if (undefined !== jsonObj.description) {
|
|
141
144
|
if (typeof (jsonObj.description) !== "string")
|
|
142
|
-
throw new
|
|
145
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'description' attribute. It should be of type 'string'.`);
|
|
143
146
|
}
|
|
144
147
|
if (undefined !== jsonObj.label) {
|
|
145
148
|
if (typeof (jsonObj.label) !== "string")
|
|
146
|
-
throw new
|
|
149
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
*getProperties(jsonObj, itemName) {
|
|
150
153
|
const properties = jsonObj.properties;
|
|
151
154
|
if (undefined !== properties) {
|
|
152
155
|
if (!Array.isArray(properties))
|
|
153
|
-
throw new
|
|
156
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECClass ${itemName} has an invalid 'properties' attribute. It should be of type 'object[]'.`);
|
|
154
157
|
for (const property of properties) {
|
|
155
158
|
if (!isObject(property))
|
|
156
|
-
throw new
|
|
159
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `An ECProperty in ${itemName} is an invalid JSON object.`);
|
|
157
160
|
if (undefined === property.name)
|
|
158
|
-
throw new
|
|
161
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `An ECProperty in ${itemName} is missing the required 'name' attribute.`);
|
|
159
162
|
if (typeof (property.name) !== "string")
|
|
160
|
-
throw new
|
|
163
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `An ECProperty in ${itemName} has an invalid 'name' attribute. It should be of type 'string'.`);
|
|
161
164
|
if (undefined === property.type)
|
|
162
|
-
throw new
|
|
165
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} does not have the required 'type' attribute.`);
|
|
163
166
|
if (typeof (property.type) !== "string")
|
|
164
|
-
throw new
|
|
167
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. It should be of type 'string'.`);
|
|
165
168
|
if (!this.isValidPropertyType(property.type)) {
|
|
166
169
|
if (SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))
|
|
167
170
|
return;
|
|
168
|
-
throw new
|
|
171
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. '${property.type}' is not a valid type.`);
|
|
169
172
|
}
|
|
170
173
|
yield [property.name, property.type, property];
|
|
171
174
|
}
|
|
@@ -179,15 +182,15 @@ export class JsonParser extends AbstractParser {
|
|
|
179
182
|
this.checkSchemaItemProps(jsonObj);
|
|
180
183
|
if (undefined !== jsonObj.modifier) {
|
|
181
184
|
if (typeof (jsonObj.modifier) !== "string")
|
|
182
|
-
throw new
|
|
185
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'modifier' attribute. It should be of type 'string'.`);
|
|
183
186
|
}
|
|
184
187
|
if (undefined !== jsonObj.baseClass) {
|
|
185
188
|
if (typeof (jsonObj.baseClass) !== "string")
|
|
186
|
-
throw new
|
|
189
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'baseClass' attribute. It should be of type 'string'.`);
|
|
187
190
|
}
|
|
188
191
|
if (undefined !== jsonObj.customAttributes) {
|
|
189
192
|
if (!Array.isArray(jsonObj.customAttributes)) {
|
|
190
|
-
throw new
|
|
193
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
196
|
}
|
|
@@ -200,10 +203,10 @@ export class JsonParser extends AbstractParser {
|
|
|
200
203
|
this.checkClassProps(jsonObj);
|
|
201
204
|
if (undefined !== jsonObj.mixins) {
|
|
202
205
|
if (!Array.isArray(jsonObj.mixins))
|
|
203
|
-
throw new
|
|
206
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
|
|
204
207
|
for (const mixinName of jsonObj.mixins) {
|
|
205
208
|
if (typeof (mixinName) !== "string")
|
|
206
|
-
throw new
|
|
209
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
212
|
return {
|
|
@@ -220,9 +223,9 @@ export class JsonParser extends AbstractParser {
|
|
|
220
223
|
parseMixin(jsonObj) {
|
|
221
224
|
this.checkClassProps(jsonObj);
|
|
222
225
|
if (undefined === jsonObj.appliesTo)
|
|
223
|
-
throw new
|
|
226
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
|
|
224
227
|
if (typeof (jsonObj.appliesTo) !== "string")
|
|
225
|
-
throw new
|
|
228
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
|
|
226
229
|
return {
|
|
227
230
|
...jsonObj,
|
|
228
231
|
originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,
|
|
@@ -237,9 +240,9 @@ export class JsonParser extends AbstractParser {
|
|
|
237
240
|
parseCustomAttributeClass(jsonObj) {
|
|
238
241
|
this.checkClassProps(jsonObj);
|
|
239
242
|
if (undefined === jsonObj.appliesTo)
|
|
240
|
-
throw new
|
|
243
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
|
|
241
244
|
if (typeof (jsonObj.appliesTo) !== "string")
|
|
242
|
-
throw new
|
|
245
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
|
|
243
246
|
return {
|
|
244
247
|
...jsonObj,
|
|
245
248
|
originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,
|
|
@@ -266,22 +269,22 @@ export class JsonParser extends AbstractParser {
|
|
|
266
269
|
parseRelationshipClass(jsonObj) {
|
|
267
270
|
this.checkClassProps(jsonObj);
|
|
268
271
|
if (undefined === jsonObj.strength)
|
|
269
|
-
throw new
|
|
272
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strength' attribute.`);
|
|
270
273
|
if (typeof (jsonObj.strength) !== "string")
|
|
271
|
-
throw new
|
|
274
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strength' attribute. It should be of type 'string'.`);
|
|
272
275
|
if (undefined === jsonObj.strengthDirection)
|
|
273
|
-
throw new
|
|
276
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strengthDirection' attribute.`);
|
|
274
277
|
if (typeof (jsonObj.strengthDirection) !== "string")
|
|
275
|
-
throw new
|
|
278
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strengthDirection' attribute. It should be of type 'string'.`);
|
|
276
279
|
if (undefined === jsonObj.source)
|
|
277
|
-
throw new
|
|
280
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required source constraint.`);
|
|
278
281
|
if (!isObject(jsonObj.source))
|
|
279
|
-
throw new
|
|
282
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid source constraint. It should be of type 'object'.`);
|
|
280
283
|
this.checkRelationshipConstraintProps(jsonObj.source, true);
|
|
281
284
|
if (undefined === jsonObj.target)
|
|
282
|
-
throw new
|
|
285
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required target constraint.`);
|
|
283
286
|
if (!isObject(jsonObj.target))
|
|
284
|
-
throw new
|
|
287
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid target constraint. It should be of type 'object'.`);
|
|
285
288
|
this.checkRelationshipConstraintProps(jsonObj.target, false);
|
|
286
289
|
return {
|
|
287
290
|
...jsonObj,
|
|
@@ -298,29 +301,29 @@ export class JsonParser extends AbstractParser {
|
|
|
298
301
|
checkRelationshipConstraintProps(jsonObj, isSource) {
|
|
299
302
|
const constraintName = `${(isSource) ? "Source" : "Target"} Constraint of ${this._currentItemFullName}`; // most specific name to call RelationshipConstraint
|
|
300
303
|
if (undefined === jsonObj.multiplicity)
|
|
301
|
-
throw new
|
|
304
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'multiplicity' attribute.`);
|
|
302
305
|
if (typeof (jsonObj.multiplicity) !== "string")
|
|
303
|
-
throw new
|
|
306
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'multiplicity' attribute. It should be of type 'string'.`);
|
|
304
307
|
if (undefined === jsonObj.roleLabel)
|
|
305
|
-
throw new
|
|
308
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'roleLabel' attribute.`);
|
|
306
309
|
if (typeof (jsonObj.roleLabel) !== "string")
|
|
307
|
-
throw new
|
|
310
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'roleLabel' attribute. It should be of type 'string'.`);
|
|
308
311
|
if (undefined === jsonObj.polymorphic)
|
|
309
|
-
throw new
|
|
312
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'polymorphic' attribute.`);
|
|
310
313
|
if (typeof (jsonObj.polymorphic) !== "boolean")
|
|
311
|
-
throw new
|
|
314
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'polymorphic' attribute. It should be of type 'boolean'.`);
|
|
312
315
|
if (undefined !== jsonObj.abstractConstraint && typeof (jsonObj.abstractConstraint) !== "string")
|
|
313
|
-
throw new
|
|
316
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'abstractConstraint' attribute. It should be of type 'string'.`);
|
|
314
317
|
if (undefined === jsonObj.constraintClasses)
|
|
315
|
-
throw new
|
|
318
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'constraintClasses' attribute.`);
|
|
316
319
|
if (!Array.isArray(jsonObj.constraintClasses))
|
|
317
|
-
throw new
|
|
320
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
|
|
318
321
|
for (const constraintClassName of jsonObj.constraintClasses) {
|
|
319
322
|
if (typeof (constraintClassName) !== "string")
|
|
320
|
-
throw new
|
|
323
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
|
|
321
324
|
}
|
|
322
325
|
if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
|
|
323
|
-
throw new
|
|
326
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
|
|
324
327
|
}
|
|
325
328
|
/**
|
|
326
329
|
* Type checks Enumeration and returns EnumerationProps interface
|
|
@@ -330,9 +333,9 @@ export class JsonParser extends AbstractParser {
|
|
|
330
333
|
parseEnumeration(jsonObj) {
|
|
331
334
|
this.checkSchemaItemProps(jsonObj);
|
|
332
335
|
if (undefined === jsonObj.type)
|
|
333
|
-
throw new
|
|
336
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'type' attribute.`);
|
|
334
337
|
if (typeof (jsonObj.type) !== "string")
|
|
335
|
-
throw new
|
|
338
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
|
|
336
339
|
const isValidEnumerationType = (type) => {
|
|
337
340
|
type = type.toLowerCase();
|
|
338
341
|
return (type === "int") ||
|
|
@@ -343,37 +346,37 @@ export class JsonParser extends AbstractParser {
|
|
|
343
346
|
if (SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))
|
|
344
347
|
jsonObj.type = "string";
|
|
345
348
|
else
|
|
346
|
-
throw new
|
|
349
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be either "int" or "string".`);
|
|
347
350
|
}
|
|
348
351
|
if (undefined !== jsonObj.isStrict) { // TODO: make required
|
|
349
352
|
if (typeof (jsonObj.isStrict) !== "boolean")
|
|
350
|
-
throw new
|
|
353
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'isStrict' attribute. It should be of type 'boolean'.`);
|
|
351
354
|
}
|
|
352
355
|
if (undefined === jsonObj.enumerators)
|
|
353
|
-
throw new
|
|
356
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'enumerators' attribute.`);
|
|
354
357
|
if (!Array.isArray(jsonObj.enumerators))
|
|
355
|
-
throw new
|
|
358
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
|
|
356
359
|
for (const enumerator of jsonObj.enumerators) {
|
|
357
360
|
if (!isObject(enumerator))
|
|
358
|
-
throw new
|
|
361
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
|
|
359
362
|
if (undefined === enumerator.value)
|
|
360
|
-
throw new
|
|
363
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'value'.`);
|
|
361
364
|
// TODO: Should this really be handled here?
|
|
362
365
|
const expectedType = jsonObj.type;
|
|
363
366
|
const receivedType = (typeof (enumerator.value) === "number") ? "int" : typeof (enumerator.value);
|
|
364
367
|
if (!expectedType.includes(receivedType)) // is receivedType a substring of expectedType? - easiest way to check "int" === "int" | "integer" && "string" === "string"
|
|
365
|
-
throw new
|
|
368
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an incompatible type. It must be "${expectedType}", not "${receivedType}".`);
|
|
366
369
|
if (undefined === enumerator.name)
|
|
367
|
-
throw new
|
|
370
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'name'.`);
|
|
368
371
|
if (typeof (enumerator.name) !== "string")
|
|
369
|
-
throw new
|
|
372
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'name' attribute. It should be of type 'string'.`);
|
|
370
373
|
if (undefined !== enumerator.label) {
|
|
371
374
|
if (typeof (enumerator.label) !== "string")
|
|
372
|
-
throw new
|
|
375
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'label' attribute. It should be of type 'string'.`);
|
|
373
376
|
}
|
|
374
377
|
if (undefined !== enumerator.description) {
|
|
375
378
|
if (typeof (enumerator.description) !== "string")
|
|
376
|
-
throw new
|
|
379
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'description' attribute. It should be of type 'string'.`);
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
382
|
return jsonObj;
|
|
@@ -386,17 +389,17 @@ export class JsonParser extends AbstractParser {
|
|
|
386
389
|
parseKindOfQuantity(jsonObj) {
|
|
387
390
|
this.checkSchemaItemProps(jsonObj);
|
|
388
391
|
if (undefined === jsonObj.relativeError)
|
|
389
|
-
throw new
|
|
392
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'relativeError' attribute.`);
|
|
390
393
|
if (typeof (jsonObj.relativeError) !== "number")
|
|
391
|
-
throw new
|
|
394
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'relativeError' attribute. It should be of type 'number'.`);
|
|
392
395
|
if (undefined !== jsonObj.presentationUnits) {
|
|
393
396
|
if (!Array.isArray(jsonObj.presentationUnits) && typeof (jsonObj.presentationUnits) !== "string")
|
|
394
|
-
throw new
|
|
397
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'presentationUnits' attribute. It should be of type 'string' or 'string[]'.`);
|
|
395
398
|
}
|
|
396
399
|
if (undefined === jsonObj.persistenceUnit)
|
|
397
|
-
throw new
|
|
400
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'persistenceUnit' attribute.`);
|
|
398
401
|
if (typeof (jsonObj.persistenceUnit) !== "string")
|
|
399
|
-
throw new
|
|
402
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'persistenceUnit' attribute. It should be of type 'string'.`);
|
|
400
403
|
return jsonObj;
|
|
401
404
|
}
|
|
402
405
|
/**
|
|
@@ -408,7 +411,7 @@ export class JsonParser extends AbstractParser {
|
|
|
408
411
|
this.checkSchemaItemProps(jsonObj);
|
|
409
412
|
if (undefined !== jsonObj.priority) { // TODO: make required
|
|
410
413
|
if (typeof (jsonObj.priority) !== "number")
|
|
411
|
-
throw new
|
|
414
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The PropertyCategory ${this._currentItemFullName} has an invalid 'priority' attribute. It should be of type 'number'.`);
|
|
412
415
|
}
|
|
413
416
|
return jsonObj;
|
|
414
417
|
}
|
|
@@ -420,28 +423,28 @@ export class JsonParser extends AbstractParser {
|
|
|
420
423
|
parseUnit(jsonObj) {
|
|
421
424
|
this.checkSchemaItemProps(jsonObj);
|
|
422
425
|
if (undefined === jsonObj.phenomenon)
|
|
423
|
-
throw new
|
|
426
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
|
|
424
427
|
if (typeof (jsonObj.phenomenon) !== "string")
|
|
425
|
-
throw new
|
|
428
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
|
|
426
429
|
if (undefined === jsonObj.unitSystem)
|
|
427
|
-
throw new
|
|
430
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
|
|
428
431
|
if (typeof (jsonObj.unitSystem) !== "string")
|
|
429
|
-
throw new
|
|
432
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
|
|
430
433
|
if (undefined === jsonObj.definition)
|
|
431
|
-
throw new
|
|
434
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'definition' attribute.`);
|
|
432
435
|
if (typeof (jsonObj.definition) !== "string")
|
|
433
|
-
throw new
|
|
436
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
|
|
434
437
|
if (undefined !== jsonObj.numerator) {
|
|
435
438
|
if (typeof (jsonObj.numerator) !== "number")
|
|
436
|
-
throw new
|
|
439
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
|
|
437
440
|
}
|
|
438
441
|
if (undefined !== jsonObj.denominator) {
|
|
439
442
|
if (typeof (jsonObj.denominator) !== "number")
|
|
440
|
-
throw new
|
|
443
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
|
|
441
444
|
}
|
|
442
445
|
if (undefined !== jsonObj.offset) {
|
|
443
446
|
if (typeof (jsonObj.offset) !== "number")
|
|
444
|
-
throw new
|
|
447
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'offset' attribute. It should be of type 'number'.`);
|
|
445
448
|
}
|
|
446
449
|
return jsonObj;
|
|
447
450
|
}
|
|
@@ -453,13 +456,13 @@ export class JsonParser extends AbstractParser {
|
|
|
453
456
|
parseInvertedUnit(jsonObj) {
|
|
454
457
|
this.checkSchemaItemProps(jsonObj);
|
|
455
458
|
if (undefined === jsonObj.invertsUnit)
|
|
456
|
-
throw new
|
|
459
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'invertsUnit' attribute.`);
|
|
457
460
|
if (typeof (jsonObj.invertsUnit) !== "string")
|
|
458
|
-
throw new
|
|
461
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'invertsUnit' attribute. It should be of type 'string'.`);
|
|
459
462
|
if (undefined === jsonObj.unitSystem)
|
|
460
|
-
throw new
|
|
463
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
|
|
461
464
|
if (typeof (jsonObj.unitSystem) !== "string")
|
|
462
|
-
throw new
|
|
465
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
|
|
463
466
|
return jsonObj;
|
|
464
467
|
}
|
|
465
468
|
/**
|
|
@@ -470,20 +473,20 @@ export class JsonParser extends AbstractParser {
|
|
|
470
473
|
parseConstant(jsonObj) {
|
|
471
474
|
this.checkSchemaItemProps(jsonObj);
|
|
472
475
|
if (undefined === jsonObj.phenomenon)
|
|
473
|
-
throw new
|
|
476
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
|
|
474
477
|
if (typeof (jsonObj.phenomenon) !== "string")
|
|
475
|
-
throw new
|
|
478
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
|
|
476
479
|
if (undefined === jsonObj.definition)
|
|
477
|
-
throw new
|
|
480
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'definition' attribute.`);
|
|
478
481
|
if (typeof (jsonObj.definition) !== "string")
|
|
479
|
-
throw new
|
|
482
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
|
|
480
483
|
if (undefined !== jsonObj.numerator) {
|
|
481
484
|
if (typeof (jsonObj.numerator) !== "number")
|
|
482
|
-
throw new
|
|
485
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
|
|
483
486
|
}
|
|
484
487
|
if (undefined !== jsonObj.denominator) {
|
|
485
488
|
if (typeof (jsonObj.denominator) !== "number")
|
|
486
|
-
throw new
|
|
489
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
|
|
487
490
|
}
|
|
488
491
|
return jsonObj;
|
|
489
492
|
}
|
|
@@ -495,9 +498,9 @@ export class JsonParser extends AbstractParser {
|
|
|
495
498
|
parsePhenomenon(jsonObj) {
|
|
496
499
|
this.checkSchemaItemProps(jsonObj);
|
|
497
500
|
if (undefined === jsonObj.definition)
|
|
498
|
-
throw new
|
|
501
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} does not have the required 'definition' attribute.`);
|
|
499
502
|
if (typeof (jsonObj.definition) !== "string")
|
|
500
|
-
throw new
|
|
503
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
|
|
501
504
|
return jsonObj;
|
|
502
505
|
}
|
|
503
506
|
/**
|
|
@@ -508,54 +511,54 @@ export class JsonParser extends AbstractParser {
|
|
|
508
511
|
parseFormat(jsonObj) {
|
|
509
512
|
this.checkSchemaItemProps(jsonObj);
|
|
510
513
|
if (undefined === jsonObj.type)
|
|
511
|
-
throw new
|
|
514
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} does not have the required 'type' attribute.`);
|
|
512
515
|
if (typeof (jsonObj.type) !== "string")
|
|
513
|
-
throw new
|
|
516
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
|
|
514
517
|
if (undefined !== jsonObj.precision && typeof (jsonObj.precision) !== "number")
|
|
515
|
-
throw new
|
|
518
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'precision' attribute. It should be of type 'number'.`);
|
|
516
519
|
if (undefined !== jsonObj.roundFactor && typeof (jsonObj.roundFactor) !== "number")
|
|
517
|
-
throw new
|
|
520
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);
|
|
518
521
|
if (undefined !== jsonObj.minWidth && typeof (jsonObj.minWidth) !== "number")
|
|
519
|
-
throw new
|
|
522
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'minWidth' attribute. It should be of type 'number'.`);
|
|
520
523
|
if (undefined !== jsonObj.showSignOption && typeof (jsonObj.showSignOption) !== "string")
|
|
521
|
-
throw new
|
|
524
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);
|
|
522
525
|
if (undefined !== jsonObj.formatTraits) {
|
|
523
526
|
if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== "string") // must be either an array of strings or a string
|
|
524
|
-
throw new
|
|
527
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);
|
|
525
528
|
}
|
|
526
529
|
if (undefined !== jsonObj.decimalSeparator && typeof (jsonObj.decimalSeparator) !== "string")
|
|
527
|
-
throw new
|
|
530
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);
|
|
528
531
|
if (undefined !== jsonObj.thousandSeparator && typeof (jsonObj.thousandSeparator) !== "string")
|
|
529
|
-
throw new
|
|
532
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);
|
|
530
533
|
if (undefined !== jsonObj.uomSeparator && typeof (jsonObj.uomSeparator) !== "string")
|
|
531
|
-
throw new
|
|
534
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);
|
|
532
535
|
if (undefined !== jsonObj.scientificType && typeof (jsonObj.scientificType) !== "string")
|
|
533
|
-
throw new
|
|
536
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'scientificType' attribute. It should be of type 'string'.`);
|
|
534
537
|
if (undefined !== jsonObj.stationOffsetSize && typeof (jsonObj.stationOffsetSize) !== "number")
|
|
535
|
-
throw new
|
|
538
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);
|
|
536
539
|
if (undefined !== jsonObj.stationSeparator && typeof (jsonObj.stationSeparator) !== "string")
|
|
537
|
-
throw new
|
|
540
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);
|
|
538
541
|
if (undefined !== jsonObj.composite) { // optional
|
|
539
542
|
if (!isObject(jsonObj.composite))
|
|
540
|
-
throw new
|
|
543
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'composite' object.`);
|
|
541
544
|
if (undefined !== jsonObj.composite.includeZero && typeof (jsonObj.composite.includeZero) !== "boolean")
|
|
542
|
-
throw new
|
|
545
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);
|
|
543
546
|
if (undefined !== jsonObj.composite.spacer && typeof (jsonObj.composite.spacer) !== "string")
|
|
544
|
-
throw new
|
|
547
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'spacer' attribute. It should be of type 'string'.`);
|
|
545
548
|
// if composite is defined
|
|
546
549
|
if (undefined === jsonObj.composite.units)
|
|
547
|
-
throw new
|
|
550
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);
|
|
548
551
|
if (!Array.isArray(jsonObj.composite.units))
|
|
549
|
-
throw new
|
|
552
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
|
|
550
553
|
for (let i = 0; i < jsonObj.composite.units.length; i++) {
|
|
551
554
|
if (!isObject(jsonObj.composite.units[i]))
|
|
552
|
-
throw new
|
|
555
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
|
|
553
556
|
if (undefined === jsonObj.composite.units[i].name) // required
|
|
554
|
-
throw new
|
|
557
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} is missing the required 'name' attribute.`);
|
|
555
558
|
if (typeof (jsonObj.composite.units[i].name) !== "string")
|
|
556
|
-
throw new
|
|
559
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} has an invalid 'name' attribute. It should be of type 'string'.`);
|
|
557
560
|
if (undefined !== jsonObj.composite.units[i].label && typeof (jsonObj.composite.units[i].label) !== "string")
|
|
558
|
-
throw new
|
|
561
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. The object at position ${i} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
559
562
|
}
|
|
560
563
|
}
|
|
561
564
|
return jsonObj;
|
|
@@ -576,36 +579,36 @@ export class JsonParser extends AbstractParser {
|
|
|
576
579
|
checkPropertyProps(jsonObj) {
|
|
577
580
|
const propName = jsonObj.name;
|
|
578
581
|
if (undefined !== jsonObj.label && typeof (jsonObj.label) !== "string")
|
|
579
|
-
throw new
|
|
582
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
580
583
|
if (undefined !== jsonObj.description && typeof (jsonObj.description) !== "string")
|
|
581
|
-
throw new
|
|
584
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'description' attribute. It should be of type 'string'.`);
|
|
582
585
|
if (undefined !== jsonObj.priority && typeof (jsonObj.priority) !== "number")
|
|
583
|
-
throw new
|
|
586
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'priority' attribute. It should be of type 'number'.`);
|
|
584
587
|
if (undefined !== jsonObj.isReadOnly && typeof (jsonObj.isReadOnly) !== "boolean")
|
|
585
|
-
throw new
|
|
588
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'isReadOnly' attribute. It should be of type 'boolean'.`);
|
|
586
589
|
if (undefined !== jsonObj.category && typeof (jsonObj.category) !== "string")
|
|
587
|
-
throw new
|
|
590
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'category' attribute. It should be of type 'string'.`);
|
|
588
591
|
if (undefined !== jsonObj.kindOfQuantity && typeof (jsonObj.kindOfQuantity) !== "string")
|
|
589
|
-
throw new
|
|
592
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'kindOfQuantity' attribute. It should be of type 'string'.`);
|
|
590
593
|
if (undefined !== jsonObj.inherited && typeof (jsonObj.inherited) !== "boolean")
|
|
591
|
-
throw new
|
|
594
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'inherited' attribute. It should be of type 'boolean'.`);
|
|
592
595
|
if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
|
|
593
|
-
throw new
|
|
596
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
|
|
594
597
|
return jsonObj;
|
|
595
598
|
}
|
|
596
599
|
checkPropertyTypename(jsonObj) {
|
|
597
600
|
const propName = jsonObj.name;
|
|
598
601
|
if (undefined === jsonObj.typeName)
|
|
599
|
-
throw new
|
|
602
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} is missing the required 'typeName' attribute.`);
|
|
600
603
|
if (typeof (jsonObj.typeName) !== "string")
|
|
601
|
-
throw new
|
|
604
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'typeName' attribute. It should be of type 'string'.`);
|
|
602
605
|
}
|
|
603
606
|
checkPropertyMinAndMaxOccurs(jsonObj) {
|
|
604
607
|
const propName = jsonObj.name;
|
|
605
608
|
if (undefined !== jsonObj.minOccurs && typeof (jsonObj.minOccurs) !== "number")
|
|
606
|
-
throw new
|
|
609
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minOccurs' attribute. It should be of type 'number'.`);
|
|
607
610
|
if (undefined !== jsonObj.maxOccurs && typeof (jsonObj.maxOccurs) !== "number")
|
|
608
|
-
throw new
|
|
611
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxOccurs' attribute. It should be of type 'number'.`);
|
|
609
612
|
}
|
|
610
613
|
/**
|
|
611
614
|
* Type checks PrimitiveOrEnumProperty and returns PrimitiveOrEnumPropertyBaseProps interface
|
|
@@ -617,15 +620,15 @@ export class JsonParser extends AbstractParser {
|
|
|
617
620
|
this.checkPropertyTypename(jsonObj);
|
|
618
621
|
const propName = jsonObj.name;
|
|
619
622
|
if (undefined !== jsonObj.minLength && typeof (jsonObj.minLength) !== "number")
|
|
620
|
-
throw new
|
|
623
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minLength' attribute. It should be of type 'number'.`);
|
|
621
624
|
if (undefined !== jsonObj.maxLength && typeof (jsonObj.maxLength) !== "number")
|
|
622
|
-
throw new
|
|
625
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxLength' attribute. It should be of type 'number'.`);
|
|
623
626
|
if (undefined !== jsonObj.minValue && typeof (jsonObj.minValue) !== "number")
|
|
624
|
-
throw new
|
|
627
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minValue' attribute. It should be of type 'number'.`);
|
|
625
628
|
if (undefined !== jsonObj.maxValue && typeof (jsonObj.maxValue) !== "number")
|
|
626
|
-
throw new
|
|
629
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxValue' attribute. It should be of type 'number'.`);
|
|
627
630
|
if (undefined !== jsonObj.extendedTypeName && typeof (jsonObj.extendedTypeName) !== "string")
|
|
628
|
-
throw new
|
|
631
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'extendedTypeName' attribute. It should be of type 'string'.`);
|
|
629
632
|
return jsonObj;
|
|
630
633
|
}
|
|
631
634
|
/**
|
|
@@ -677,13 +680,13 @@ export class JsonParser extends AbstractParser {
|
|
|
677
680
|
this.checkPropertyProps(jsonObj);
|
|
678
681
|
const fullname = `${this._currentItemFullName}.${jsonObj.name}`;
|
|
679
682
|
if (undefined === jsonObj.relationshipName)
|
|
680
|
-
throw new
|
|
683
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'relationshipName' property.`);
|
|
681
684
|
if (typeof (jsonObj.relationshipName) !== "string")
|
|
682
|
-
throw new
|
|
685
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'relationshipName' property. It should be of type 'string'.`);
|
|
683
686
|
if (undefined === jsonObj.direction)
|
|
684
|
-
throw new
|
|
687
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'direction' property.`);
|
|
685
688
|
if (typeof (jsonObj.direction) !== "string")
|
|
686
|
-
throw new
|
|
689
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'direction' property. It should be of type 'string'.`);
|
|
687
690
|
return jsonObj;
|
|
688
691
|
}
|
|
689
692
|
getSchemaCustomAttributeProviders() {
|
|
@@ -703,14 +706,14 @@ export class JsonParser extends AbstractParser {
|
|
|
703
706
|
*getCustomAttributeProviders(jsonObj, type, name) {
|
|
704
707
|
if (undefined !== jsonObj.customAttributes) {
|
|
705
708
|
if (!Array.isArray(jsonObj.customAttributes))
|
|
706
|
-
throw new
|
|
709
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
|
|
707
710
|
for (const instance of jsonObj.customAttributes) {
|
|
708
711
|
if (!isObject(instance) || Array.isArray(instance))
|
|
709
|
-
throw new
|
|
712
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
|
|
710
713
|
if (undefined === instance.className)
|
|
711
|
-
throw new
|
|
714
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes is missing the required 'className' attribute.`);
|
|
712
715
|
if (typeof (instance.className) !== "string")
|
|
713
|
-
throw new
|
|
716
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes has an invalid 'className' attribute. It should be of type 'string'.`);
|
|
714
717
|
const provider = (_caClass) => {
|
|
715
718
|
return instance;
|
|
716
719
|
};
|