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