@itwin/ecschema-metadata 5.0.0-dev.99 → 5.1.0-dev.1
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 +6 -1
- package/lib/cjs/Context.d.ts +3 -3
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +6 -6
- 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 +23 -11
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +47 -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 +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 +5 -3
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +7 -5
- 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 +146 -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 +3 -3
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +7 -7
- 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 +23 -11
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +48 -25
- 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 +5 -3
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +8 -6
- 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 +142 -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 +8 -6
|
@@ -21,7 +21,7 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
21
21
|
constructor(rawSchema) {
|
|
22
22
|
super();
|
|
23
23
|
if (!isObject(rawSchema))
|
|
24
|
-
throw new Exception_1.
|
|
24
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Invalid JSON object.`);
|
|
25
25
|
this._rawSchema = rawSchema;
|
|
26
26
|
this._schemaName = rawSchema.name;
|
|
27
27
|
this._ecSpecVersion = JsonParser.parseJSUri(rawSchema.$schema);
|
|
@@ -44,28 +44,28 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
44
44
|
*/
|
|
45
45
|
parseSchema() {
|
|
46
46
|
if (undefined === this._rawSchema.name)
|
|
47
|
-
throw new Exception_1.
|
|
47
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `An ECSchema is missing the required 'name' attribute.`);
|
|
48
48
|
if (typeof (this._rawSchema.name) !== "string")
|
|
49
|
-
throw new Exception_1.
|
|
49
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `An ECSchema has an invalid 'name' attribute. It should be of type 'string'.`);
|
|
50
50
|
if (undefined === this._rawSchema.$schema)
|
|
51
|
-
throw new Exception_1.
|
|
51
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required '$schema' attribute.`);
|
|
52
52
|
if (typeof (this._rawSchema.$schema) !== "string")
|
|
53
|
-
throw new Exception_1.
|
|
53
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid '$schema' attribute. It should be of type 'string'.`);
|
|
54
54
|
if (undefined === this._rawSchema.version)
|
|
55
|
-
throw new Exception_1.
|
|
55
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} is missing the required 'version' attribute.`);
|
|
56
56
|
if (typeof (this._rawSchema.version) !== "string")
|
|
57
|
-
throw new Exception_1.
|
|
57
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'version' attribute. It should be of type 'string'.`);
|
|
58
58
|
if (undefined !== this._rawSchema.alias) {
|
|
59
59
|
if (typeof (this._rawSchema.alias) !== "string")
|
|
60
|
-
throw new Exception_1.
|
|
60
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'alias' attribute. It should be of type 'string'.`);
|
|
61
61
|
}
|
|
62
62
|
if (undefined !== this._rawSchema.label) {
|
|
63
63
|
if (typeof (this._rawSchema.label) !== "string")
|
|
64
|
-
throw new Exception_1.
|
|
64
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
65
65
|
}
|
|
66
66
|
if (undefined !== this._rawSchema.description) {
|
|
67
67
|
if (typeof (this._rawSchema.description) !== "string")
|
|
68
|
-
throw new Exception_1.
|
|
68
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECSchema ${this._schemaName} has an invalid 'description' attribute. It should be of type 'string'.`);
|
|
69
69
|
}
|
|
70
70
|
const ecVersions = JsonParser.parseJSUri(this._rawSchema.$schema);
|
|
71
71
|
return {
|
|
@@ -77,7 +77,7 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
77
77
|
*getReferences() {
|
|
78
78
|
if (undefined !== this._rawSchema.references) {
|
|
79
79
|
if (!Array.isArray(this._rawSchema.references))
|
|
80
|
-
throw new Exception_1.
|
|
80
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema ${this._rawSchema.name} has an invalid 'references' attribute. It should be of type 'object[]'.`);
|
|
81
81
|
for (const ref of this._rawSchema.references) {
|
|
82
82
|
yield this.checkSchemaReference(ref);
|
|
83
83
|
}
|
|
@@ -85,33 +85,33 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
85
85
|
}
|
|
86
86
|
checkSchemaReference(jsonObj) {
|
|
87
87
|
if (!isObject(jsonObj))
|
|
88
|
-
throw new Exception_1.
|
|
88
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. It should be of type 'object[]'.`);
|
|
89
89
|
if (undefined === jsonObj.name)
|
|
90
|
-
throw new Exception_1.
|
|
90
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'name' attribute.`);
|
|
91
91
|
if (typeof (jsonObj.name) !== "string")
|
|
92
|
-
throw new Exception_1.
|
|
92
|
+
throw new Exception_1.ECSchemaError(Exception_1.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'.`);
|
|
93
93
|
if (undefined === jsonObj.version)
|
|
94
|
-
throw new Exception_1.
|
|
94
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'references' attribute. One of the references is missing the required 'version' attribute.`);
|
|
95
95
|
if (typeof (jsonObj.version) !== "string")
|
|
96
|
-
throw new Exception_1.
|
|
96
|
+
throw new Exception_1.ECSchemaError(Exception_1.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'.`);
|
|
97
97
|
return jsonObj;
|
|
98
98
|
}
|
|
99
99
|
*getItems() {
|
|
100
100
|
const items = this._rawSchema.items;
|
|
101
101
|
if (undefined !== items) {
|
|
102
102
|
if (!isObject(items) || Array.isArray(items))
|
|
103
|
-
throw new Exception_1.
|
|
103
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
|
|
104
104
|
// eslint-disable-next-line guard-for-in
|
|
105
105
|
for (const itemName in items) {
|
|
106
106
|
const item = items[itemName];
|
|
107
107
|
if (!isObject(item))
|
|
108
|
-
throw new Exception_1.
|
|
108
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
|
|
109
109
|
if (!ECName_1.ECName.validate(itemName))
|
|
110
|
-
throw new Exception_1.
|
|
110
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
|
|
111
111
|
if (undefined === item.schemaItemType)
|
|
112
|
-
throw new Exception_1.
|
|
112
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
|
|
113
113
|
if (typeof (item.schemaItemType) !== "string")
|
|
114
|
-
throw new Exception_1.
|
|
114
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
|
|
115
115
|
this._currentItemFullName = `${this._schemaName}.${itemName}`;
|
|
116
116
|
yield [itemName, item.schemaItemType, item];
|
|
117
117
|
}
|
|
@@ -121,17 +121,17 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
121
121
|
const items = this._rawSchema.items;
|
|
122
122
|
if (undefined !== items) {
|
|
123
123
|
if (!isObject(items) || Array.isArray(items))
|
|
124
|
-
throw new Exception_1.
|
|
124
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema ${this._schemaName} has an invalid 'items' attribute. It should be of type 'object'.`);
|
|
125
125
|
const item = items[itemName];
|
|
126
126
|
if (undefined !== item) {
|
|
127
127
|
if (!isObject(item))
|
|
128
|
-
throw new Exception_1.
|
|
128
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `A SchemaItem in ${this._schemaName} is an invalid JSON object.`);
|
|
129
129
|
if (!ECName_1.ECName.validate(itemName))
|
|
130
|
-
throw new Exception_1.
|
|
130
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECName, `A SchemaItem in ${this._schemaName} has an invalid 'name' attribute. '${itemName}' is not a valid ECName.`);
|
|
131
131
|
if (undefined === item.schemaItemType)
|
|
132
|
-
throw new Exception_1.
|
|
132
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} is missing the required 'schemaItemType' attribute.`);
|
|
133
133
|
if (typeof (item.schemaItemType) !== "string")
|
|
134
|
-
throw new Exception_1.
|
|
134
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._schemaName}.${itemName} has an invalid 'schemaItemType' attribute. It should be of type 'string'.`);
|
|
135
135
|
this._currentItemFullName = `${this._schemaName}.${itemName}`;
|
|
136
136
|
return [itemName, item.schemaItemType, item];
|
|
137
137
|
}
|
|
@@ -145,33 +145,33 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
145
145
|
checkSchemaItemProps(jsonObj) {
|
|
146
146
|
if (undefined !== jsonObj.description) {
|
|
147
147
|
if (typeof (jsonObj.description) !== "string")
|
|
148
|
-
throw new Exception_1.
|
|
148
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'description' attribute. It should be of type 'string'.`);
|
|
149
149
|
}
|
|
150
150
|
if (undefined !== jsonObj.label) {
|
|
151
151
|
if (typeof (jsonObj.label) !== "string")
|
|
152
|
-
throw new Exception_1.
|
|
152
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The SchemaItem ${this._currentItemFullName} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
*getProperties(jsonObj, itemName) {
|
|
156
156
|
const properties = jsonObj.properties;
|
|
157
157
|
if (undefined !== properties) {
|
|
158
158
|
if (!Array.isArray(properties))
|
|
159
|
-
throw new Exception_1.
|
|
159
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECClass ${itemName} has an invalid 'properties' attribute. It should be of type 'object[]'.`);
|
|
160
160
|
for (const property of properties) {
|
|
161
161
|
if (!isObject(property))
|
|
162
|
-
throw new Exception_1.
|
|
162
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `An ECProperty in ${itemName} is an invalid JSON object.`);
|
|
163
163
|
if (undefined === property.name)
|
|
164
|
-
throw new Exception_1.
|
|
164
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `An ECProperty in ${itemName} is missing the required 'name' attribute.`);
|
|
165
165
|
if (typeof (property.name) !== "string")
|
|
166
|
-
throw new Exception_1.
|
|
166
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `An ECProperty in ${itemName} has an invalid 'name' attribute. It should be of type 'string'.`);
|
|
167
167
|
if (undefined === property.type)
|
|
168
|
-
throw new Exception_1.
|
|
168
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} does not have the required 'type' attribute.`);
|
|
169
169
|
if (typeof (property.type) !== "string")
|
|
170
|
-
throw new Exception_1.
|
|
170
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. It should be of type 'string'.`);
|
|
171
171
|
if (!this.isValidPropertyType(property.type)) {
|
|
172
172
|
if (Helper_1.SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))
|
|
173
173
|
return;
|
|
174
|
-
throw new Exception_1.
|
|
174
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${itemName}.${property.name} has an invalid 'type' attribute. '${property.type}' is not a valid type.`);
|
|
175
175
|
}
|
|
176
176
|
yield [property.name, property.type, property];
|
|
177
177
|
}
|
|
@@ -185,15 +185,15 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
185
185
|
this.checkSchemaItemProps(jsonObj);
|
|
186
186
|
if (undefined !== jsonObj.modifier) {
|
|
187
187
|
if (typeof (jsonObj.modifier) !== "string")
|
|
188
|
-
throw new Exception_1.
|
|
188
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'modifier' attribute. It should be of type 'string'.`);
|
|
189
189
|
}
|
|
190
190
|
if (undefined !== jsonObj.baseClass) {
|
|
191
191
|
if (typeof (jsonObj.baseClass) !== "string")
|
|
192
|
-
throw new Exception_1.
|
|
192
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'baseClass' attribute. It should be of type 'string'.`);
|
|
193
193
|
}
|
|
194
194
|
if (undefined !== jsonObj.customAttributes) {
|
|
195
195
|
if (!Array.isArray(jsonObj.customAttributes)) {
|
|
196
|
-
throw new Exception_1.
|
|
196
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECClass ${this._currentItemFullName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -206,10 +206,10 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
206
206
|
this.checkClassProps(jsonObj);
|
|
207
207
|
if (undefined !== jsonObj.mixins) {
|
|
208
208
|
if (!Array.isArray(jsonObj.mixins))
|
|
209
|
-
throw new Exception_1.
|
|
209
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
|
|
210
210
|
for (const mixinName of jsonObj.mixins) {
|
|
211
211
|
if (typeof (mixinName) !== "string")
|
|
212
|
-
throw new Exception_1.
|
|
212
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this._currentItemFullName} has an invalid 'mixins' attribute. It should be of type 'string[]'.`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
return {
|
|
@@ -226,9 +226,9 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
226
226
|
parseMixin(jsonObj) {
|
|
227
227
|
this.checkClassProps(jsonObj);
|
|
228
228
|
if (undefined === jsonObj.appliesTo)
|
|
229
|
-
throw new Exception_1.
|
|
229
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
|
|
230
230
|
if (typeof (jsonObj.appliesTo) !== "string")
|
|
231
|
-
throw new Exception_1.
|
|
231
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Mixin ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
|
|
232
232
|
return {
|
|
233
233
|
...jsonObj,
|
|
234
234
|
originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,
|
|
@@ -243,9 +243,9 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
243
243
|
parseCustomAttributeClass(jsonObj) {
|
|
244
244
|
this.checkClassProps(jsonObj);
|
|
245
245
|
if (undefined === jsonObj.appliesTo)
|
|
246
|
-
throw new Exception_1.
|
|
246
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} is missing the required 'appliesTo' attribute.`);
|
|
247
247
|
if (typeof (jsonObj.appliesTo) !== "string")
|
|
248
|
-
throw new Exception_1.
|
|
248
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The CustomAttributeClass ${this._currentItemFullName} has an invalid 'appliesTo' attribute. It should be of type 'string'.`);
|
|
249
249
|
return {
|
|
250
250
|
...jsonObj,
|
|
251
251
|
originalECSpecMajorVersion: this._ecSpecVersion?.readVersion,
|
|
@@ -272,22 +272,22 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
272
272
|
parseRelationshipClass(jsonObj) {
|
|
273
273
|
this.checkClassProps(jsonObj);
|
|
274
274
|
if (undefined === jsonObj.strength)
|
|
275
|
-
throw new Exception_1.
|
|
275
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strength' attribute.`);
|
|
276
276
|
if (typeof (jsonObj.strength) !== "string")
|
|
277
|
-
throw new Exception_1.
|
|
277
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strength' attribute. It should be of type 'string'.`);
|
|
278
278
|
if (undefined === jsonObj.strengthDirection)
|
|
279
|
-
throw new Exception_1.
|
|
279
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required 'strengthDirection' attribute.`);
|
|
280
280
|
if (typeof (jsonObj.strengthDirection) !== "string")
|
|
281
|
-
throw new Exception_1.
|
|
281
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid 'strengthDirection' attribute. It should be of type 'string'.`);
|
|
282
282
|
if (undefined === jsonObj.source)
|
|
283
|
-
throw new Exception_1.
|
|
283
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required source constraint.`);
|
|
284
284
|
if (!isObject(jsonObj.source))
|
|
285
|
-
throw new Exception_1.
|
|
285
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid source constraint. It should be of type 'object'.`);
|
|
286
286
|
this.checkRelationshipConstraintProps(jsonObj.source, true);
|
|
287
287
|
if (undefined === jsonObj.target)
|
|
288
|
-
throw new Exception_1.
|
|
288
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} is missing the required target constraint.`);
|
|
289
289
|
if (!isObject(jsonObj.target))
|
|
290
|
-
throw new Exception_1.
|
|
290
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The RelationshipClass ${this._currentItemFullName} has an invalid target constraint. It should be of type 'object'.`);
|
|
291
291
|
this.checkRelationshipConstraintProps(jsonObj.target, false);
|
|
292
292
|
return {
|
|
293
293
|
...jsonObj,
|
|
@@ -304,29 +304,29 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
304
304
|
checkRelationshipConstraintProps(jsonObj, isSource) {
|
|
305
305
|
const constraintName = `${(isSource) ? "Source" : "Target"} Constraint of ${this._currentItemFullName}`; // most specific name to call RelationshipConstraint
|
|
306
306
|
if (undefined === jsonObj.multiplicity)
|
|
307
|
-
throw new Exception_1.
|
|
307
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'multiplicity' attribute.`);
|
|
308
308
|
if (typeof (jsonObj.multiplicity) !== "string")
|
|
309
|
-
throw new Exception_1.
|
|
309
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'multiplicity' attribute. It should be of type 'string'.`);
|
|
310
310
|
if (undefined === jsonObj.roleLabel)
|
|
311
|
-
throw new Exception_1.
|
|
311
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'roleLabel' attribute.`);
|
|
312
312
|
if (typeof (jsonObj.roleLabel) !== "string")
|
|
313
|
-
throw new Exception_1.
|
|
313
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'roleLabel' attribute. It should be of type 'string'.`);
|
|
314
314
|
if (undefined === jsonObj.polymorphic)
|
|
315
|
-
throw new Exception_1.
|
|
315
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'polymorphic' attribute.`);
|
|
316
316
|
if (typeof (jsonObj.polymorphic) !== "boolean")
|
|
317
|
-
throw new Exception_1.
|
|
317
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'polymorphic' attribute. It should be of type 'boolean'.`);
|
|
318
318
|
if (undefined !== jsonObj.abstractConstraint && typeof (jsonObj.abstractConstraint) !== "string")
|
|
319
|
-
throw new Exception_1.
|
|
319
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'abstractConstraint' attribute. It should be of type 'string'.`);
|
|
320
320
|
if (undefined === jsonObj.constraintClasses)
|
|
321
|
-
throw new Exception_1.
|
|
321
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} is missing the required 'constraintClasses' attribute.`);
|
|
322
322
|
if (!Array.isArray(jsonObj.constraintClasses))
|
|
323
|
-
throw new Exception_1.
|
|
323
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
|
|
324
324
|
for (const constraintClassName of jsonObj.constraintClasses) {
|
|
325
325
|
if (typeof (constraintClassName) !== "string")
|
|
326
|
-
throw new Exception_1.
|
|
326
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'constraintClasses' attribute. It should be of type 'string[]'.`);
|
|
327
327
|
}
|
|
328
328
|
if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
|
|
329
|
-
throw new Exception_1.
|
|
329
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${constraintName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
332
|
* Type checks Enumeration and returns EnumerationProps interface
|
|
@@ -336,9 +336,9 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
336
336
|
parseEnumeration(jsonObj) {
|
|
337
337
|
this.checkSchemaItemProps(jsonObj);
|
|
338
338
|
if (undefined === jsonObj.type)
|
|
339
|
-
throw new Exception_1.
|
|
339
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'type' attribute.`);
|
|
340
340
|
if (typeof (jsonObj.type) !== "string")
|
|
341
|
-
throw new Exception_1.
|
|
341
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
|
|
342
342
|
const isValidEnumerationType = (type) => {
|
|
343
343
|
type = type.toLowerCase();
|
|
344
344
|
return (type === "int") ||
|
|
@@ -349,37 +349,37 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
349
349
|
if (Helper_1.SchemaReadHelper.isECSpecVersionNewer(this._ecSpecVersion))
|
|
350
350
|
jsonObj.type = "string";
|
|
351
351
|
else
|
|
352
|
-
throw new Exception_1.
|
|
352
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'type' attribute. It should be either "int" or "string".`);
|
|
353
353
|
}
|
|
354
354
|
if (undefined !== jsonObj.isStrict) { // TODO: make required
|
|
355
355
|
if (typeof (jsonObj.isStrict) !== "boolean")
|
|
356
|
-
throw new Exception_1.
|
|
356
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'isStrict' attribute. It should be of type 'boolean'.`);
|
|
357
357
|
}
|
|
358
358
|
if (undefined === jsonObj.enumerators)
|
|
359
|
-
throw new Exception_1.
|
|
359
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} is missing the required 'enumerators' attribute.`);
|
|
360
360
|
if (!Array.isArray(jsonObj.enumerators))
|
|
361
|
-
throw new Exception_1.
|
|
361
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
|
|
362
362
|
for (const enumerator of jsonObj.enumerators) {
|
|
363
363
|
if (!isObject(enumerator))
|
|
364
|
-
throw new Exception_1.
|
|
364
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an invalid 'enumerators' attribute. It should be of type 'object[]'.`);
|
|
365
365
|
if (undefined === enumerator.value)
|
|
366
|
-
throw new Exception_1.
|
|
366
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'value'.`);
|
|
367
367
|
// TODO: Should this really be handled here?
|
|
368
368
|
const expectedType = jsonObj.type;
|
|
369
369
|
const receivedType = (typeof (enumerator.value) === "number") ? "int" : typeof (enumerator.value);
|
|
370
370
|
if (!expectedType.includes(receivedType)) // is receivedType a substring of expectedType? - easiest way to check "int" === "int" | "integer" && "string" === "string"
|
|
371
|
-
throw new Exception_1.
|
|
371
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an incompatible type. It must be "${expectedType}", not "${receivedType}".`);
|
|
372
372
|
if (undefined === enumerator.name)
|
|
373
|
-
throw new Exception_1.
|
|
373
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator that is missing the required attribute 'name'.`);
|
|
374
374
|
if (typeof (enumerator.name) !== "string")
|
|
375
|
-
throw new Exception_1.
|
|
375
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'name' attribute. It should be of type 'string'.`);
|
|
376
376
|
if (undefined !== enumerator.label) {
|
|
377
377
|
if (typeof (enumerator.label) !== "string")
|
|
378
|
-
throw new Exception_1.
|
|
378
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'label' attribute. It should be of type 'string'.`);
|
|
379
379
|
}
|
|
380
380
|
if (undefined !== enumerator.description) {
|
|
381
381
|
if (typeof (enumerator.description) !== "string")
|
|
382
|
-
throw new Exception_1.
|
|
382
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this._currentItemFullName} has an enumerator with an invalid 'description' attribute. It should be of type 'string'.`);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
return jsonObj;
|
|
@@ -392,17 +392,17 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
392
392
|
parseKindOfQuantity(jsonObj) {
|
|
393
393
|
this.checkSchemaItemProps(jsonObj);
|
|
394
394
|
if (undefined === jsonObj.relativeError)
|
|
395
|
-
throw new Exception_1.
|
|
395
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'relativeError' attribute.`);
|
|
396
396
|
if (typeof (jsonObj.relativeError) !== "number")
|
|
397
|
-
throw new Exception_1.
|
|
397
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'relativeError' attribute. It should be of type 'number'.`);
|
|
398
398
|
if (undefined !== jsonObj.presentationUnits) {
|
|
399
399
|
if (!Array.isArray(jsonObj.presentationUnits) && typeof (jsonObj.presentationUnits) !== "string")
|
|
400
|
-
throw new Exception_1.
|
|
400
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'presentationUnits' attribute. It should be of type 'string' or 'string[]'.`);
|
|
401
401
|
}
|
|
402
402
|
if (undefined === jsonObj.persistenceUnit)
|
|
403
|
-
throw new Exception_1.
|
|
403
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} is missing the required 'persistenceUnit' attribute.`);
|
|
404
404
|
if (typeof (jsonObj.persistenceUnit) !== "string")
|
|
405
|
-
throw new Exception_1.
|
|
405
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The KindOfQuantity ${this._currentItemFullName} has an invalid 'persistenceUnit' attribute. It should be of type 'string'.`);
|
|
406
406
|
return jsonObj;
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
@@ -414,7 +414,7 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
414
414
|
this.checkSchemaItemProps(jsonObj);
|
|
415
415
|
if (undefined !== jsonObj.priority) { // TODO: make required
|
|
416
416
|
if (typeof (jsonObj.priority) !== "number")
|
|
417
|
-
throw new Exception_1.
|
|
417
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The PropertyCategory ${this._currentItemFullName} has an invalid 'priority' attribute. It should be of type 'number'.`);
|
|
418
418
|
}
|
|
419
419
|
return jsonObj;
|
|
420
420
|
}
|
|
@@ -426,28 +426,28 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
426
426
|
parseUnit(jsonObj) {
|
|
427
427
|
this.checkSchemaItemProps(jsonObj);
|
|
428
428
|
if (undefined === jsonObj.phenomenon)
|
|
429
|
-
throw new Exception_1.
|
|
429
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
|
|
430
430
|
if (typeof (jsonObj.phenomenon) !== "string")
|
|
431
|
-
throw new Exception_1.
|
|
431
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
|
|
432
432
|
if (undefined === jsonObj.unitSystem)
|
|
433
|
-
throw new Exception_1.
|
|
433
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
|
|
434
434
|
if (typeof (jsonObj.unitSystem) !== "string")
|
|
435
|
-
throw new Exception_1.
|
|
435
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
|
|
436
436
|
if (undefined === jsonObj.definition)
|
|
437
|
-
throw new Exception_1.
|
|
437
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} does not have the required 'definition' attribute.`);
|
|
438
438
|
if (typeof (jsonObj.definition) !== "string")
|
|
439
|
-
throw new Exception_1.
|
|
439
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
|
|
440
440
|
if (undefined !== jsonObj.numerator) {
|
|
441
441
|
if (typeof (jsonObj.numerator) !== "number")
|
|
442
|
-
throw new Exception_1.
|
|
442
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
|
|
443
443
|
}
|
|
444
444
|
if (undefined !== jsonObj.denominator) {
|
|
445
445
|
if (typeof (jsonObj.denominator) !== "number")
|
|
446
|
-
throw new Exception_1.
|
|
446
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
|
|
447
447
|
}
|
|
448
448
|
if (undefined !== jsonObj.offset) {
|
|
449
449
|
if (typeof (jsonObj.offset) !== "number")
|
|
450
|
-
throw new Exception_1.
|
|
450
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Unit ${this._currentItemFullName} has an invalid 'offset' attribute. It should be of type 'number'.`);
|
|
451
451
|
}
|
|
452
452
|
return jsonObj;
|
|
453
453
|
}
|
|
@@ -459,13 +459,13 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
459
459
|
parseInvertedUnit(jsonObj) {
|
|
460
460
|
this.checkSchemaItemProps(jsonObj);
|
|
461
461
|
if (undefined === jsonObj.invertsUnit)
|
|
462
|
-
throw new Exception_1.
|
|
462
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'invertsUnit' attribute.`);
|
|
463
463
|
if (typeof (jsonObj.invertsUnit) !== "string")
|
|
464
|
-
throw new Exception_1.
|
|
464
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'invertsUnit' attribute. It should be of type 'string'.`);
|
|
465
465
|
if (undefined === jsonObj.unitSystem)
|
|
466
|
-
throw new Exception_1.
|
|
466
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} does not have the required 'unitSystem' attribute.`);
|
|
467
467
|
if (typeof (jsonObj.unitSystem) !== "string")
|
|
468
|
-
throw new Exception_1.
|
|
468
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The InvertedUnit ${this._currentItemFullName} has an invalid 'unitSystem' attribute. It should be of type 'string'.`);
|
|
469
469
|
return jsonObj;
|
|
470
470
|
}
|
|
471
471
|
/**
|
|
@@ -476,20 +476,20 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
476
476
|
parseConstant(jsonObj) {
|
|
477
477
|
this.checkSchemaItemProps(jsonObj);
|
|
478
478
|
if (undefined === jsonObj.phenomenon)
|
|
479
|
-
throw new Exception_1.
|
|
479
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'phenomenon' attribute.`);
|
|
480
480
|
if (typeof (jsonObj.phenomenon) !== "string")
|
|
481
|
-
throw new Exception_1.
|
|
481
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'phenomenon' attribute. It should be of type 'string'.`);
|
|
482
482
|
if (undefined === jsonObj.definition)
|
|
483
|
-
throw new Exception_1.
|
|
483
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} does not have the required 'definition' attribute.`);
|
|
484
484
|
if (typeof (jsonObj.definition) !== "string")
|
|
485
|
-
throw new Exception_1.
|
|
485
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
|
|
486
486
|
if (undefined !== jsonObj.numerator) {
|
|
487
487
|
if (typeof (jsonObj.numerator) !== "number")
|
|
488
|
-
throw new Exception_1.
|
|
488
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'numerator' attribute. It should be of type 'number'.`);
|
|
489
489
|
}
|
|
490
490
|
if (undefined !== jsonObj.denominator) {
|
|
491
491
|
if (typeof (jsonObj.denominator) !== "number")
|
|
492
|
-
throw new Exception_1.
|
|
492
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Constant ${this._currentItemFullName} has an invalid 'denominator' attribute. It should be of type 'number'.`);
|
|
493
493
|
}
|
|
494
494
|
return jsonObj;
|
|
495
495
|
}
|
|
@@ -501,9 +501,9 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
501
501
|
parsePhenomenon(jsonObj) {
|
|
502
502
|
this.checkSchemaItemProps(jsonObj);
|
|
503
503
|
if (undefined === jsonObj.definition)
|
|
504
|
-
throw new Exception_1.
|
|
504
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} does not have the required 'definition' attribute.`);
|
|
505
505
|
if (typeof (jsonObj.definition) !== "string")
|
|
506
|
-
throw new Exception_1.
|
|
506
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Phenomenon ${this._currentItemFullName} has an invalid 'definition' attribute. It should be of type 'string'.`);
|
|
507
507
|
return jsonObj;
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
@@ -514,54 +514,54 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
514
514
|
parseFormat(jsonObj) {
|
|
515
515
|
this.checkSchemaItemProps(jsonObj);
|
|
516
516
|
if (undefined === jsonObj.type)
|
|
517
|
-
throw new Exception_1.
|
|
517
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} does not have the required 'type' attribute.`);
|
|
518
518
|
if (typeof (jsonObj.type) !== "string")
|
|
519
|
-
throw new Exception_1.
|
|
519
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'type' attribute. It should be of type 'string'.`);
|
|
520
520
|
if (undefined !== jsonObj.precision && typeof (jsonObj.precision) !== "number")
|
|
521
|
-
throw new Exception_1.
|
|
521
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'precision' attribute. It should be of type 'number'.`);
|
|
522
522
|
if (undefined !== jsonObj.roundFactor && typeof (jsonObj.roundFactor) !== "number")
|
|
523
|
-
throw new Exception_1.
|
|
523
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);
|
|
524
524
|
if (undefined !== jsonObj.minWidth && typeof (jsonObj.minWidth) !== "number")
|
|
525
|
-
throw new Exception_1.
|
|
525
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'minWidth' attribute. It should be of type 'number'.`);
|
|
526
526
|
if (undefined !== jsonObj.showSignOption && typeof (jsonObj.showSignOption) !== "string")
|
|
527
|
-
throw new Exception_1.
|
|
527
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);
|
|
528
528
|
if (undefined !== jsonObj.formatTraits) {
|
|
529
529
|
if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== "string") // must be either an array of strings or a string
|
|
530
|
-
throw new Exception_1.
|
|
530
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);
|
|
531
531
|
}
|
|
532
532
|
if (undefined !== jsonObj.decimalSeparator && typeof (jsonObj.decimalSeparator) !== "string")
|
|
533
|
-
throw new Exception_1.
|
|
533
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);
|
|
534
534
|
if (undefined !== jsonObj.thousandSeparator && typeof (jsonObj.thousandSeparator) !== "string")
|
|
535
|
-
throw new Exception_1.
|
|
535
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);
|
|
536
536
|
if (undefined !== jsonObj.uomSeparator && typeof (jsonObj.uomSeparator) !== "string")
|
|
537
|
-
throw new Exception_1.
|
|
537
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);
|
|
538
538
|
if (undefined !== jsonObj.scientificType && typeof (jsonObj.scientificType) !== "string")
|
|
539
|
-
throw new Exception_1.
|
|
539
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'scientificType' attribute. It should be of type 'string'.`);
|
|
540
540
|
if (undefined !== jsonObj.stationOffsetSize && typeof (jsonObj.stationOffsetSize) !== "number")
|
|
541
|
-
throw new Exception_1.
|
|
541
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);
|
|
542
542
|
if (undefined !== jsonObj.stationSeparator && typeof (jsonObj.stationSeparator) !== "string")
|
|
543
|
-
throw new Exception_1.
|
|
543
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);
|
|
544
544
|
if (undefined !== jsonObj.composite) { // optional
|
|
545
545
|
if (!isObject(jsonObj.composite))
|
|
546
|
-
throw new Exception_1.
|
|
546
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'composite' object.`);
|
|
547
547
|
if (undefined !== jsonObj.composite.includeZero && typeof (jsonObj.composite.includeZero) !== "boolean")
|
|
548
|
-
throw new Exception_1.
|
|
548
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);
|
|
549
549
|
if (undefined !== jsonObj.composite.spacer && typeof (jsonObj.composite.spacer) !== "string")
|
|
550
|
-
throw new Exception_1.
|
|
550
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'spacer' attribute. It should be of type 'string'.`);
|
|
551
551
|
// if composite is defined
|
|
552
552
|
if (undefined === jsonObj.composite.units)
|
|
553
|
-
throw new Exception_1.
|
|
553
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);
|
|
554
554
|
if (!Array.isArray(jsonObj.composite.units))
|
|
555
|
-
throw new Exception_1.
|
|
555
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
|
|
556
556
|
for (let i = 0; i < jsonObj.composite.units.length; i++) {
|
|
557
557
|
if (!isObject(jsonObj.composite.units[i]))
|
|
558
|
-
throw new Exception_1.
|
|
558
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has a Composite with an invalid 'units' attribute. It should be of type 'object[]'.`);
|
|
559
559
|
if (undefined === jsonObj.composite.units[i].name) // required
|
|
560
|
-
throw new Exception_1.
|
|
560
|
+
throw new Exception_1.ECSchemaError(Exception_1.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.`);
|
|
561
561
|
if (typeof (jsonObj.composite.units[i].name) !== "string")
|
|
562
|
-
throw new Exception_1.
|
|
562
|
+
throw new Exception_1.ECSchemaError(Exception_1.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'.`);
|
|
563
563
|
if (undefined !== jsonObj.composite.units[i].label && typeof (jsonObj.composite.units[i].label) !== "string")
|
|
564
|
-
throw new Exception_1.
|
|
564
|
+
throw new Exception_1.ECSchemaError(Exception_1.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'.`);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
return jsonObj;
|
|
@@ -582,36 +582,36 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
582
582
|
checkPropertyProps(jsonObj) {
|
|
583
583
|
const propName = jsonObj.name;
|
|
584
584
|
if (undefined !== jsonObj.label && typeof (jsonObj.label) !== "string")
|
|
585
|
-
throw new Exception_1.
|
|
585
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'label' attribute. It should be of type 'string'.`);
|
|
586
586
|
if (undefined !== jsonObj.description && typeof (jsonObj.description) !== "string")
|
|
587
|
-
throw new Exception_1.
|
|
587
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'description' attribute. It should be of type 'string'.`);
|
|
588
588
|
if (undefined !== jsonObj.priority && typeof (jsonObj.priority) !== "number")
|
|
589
|
-
throw new Exception_1.
|
|
589
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'priority' attribute. It should be of type 'number'.`);
|
|
590
590
|
if (undefined !== jsonObj.isReadOnly && typeof (jsonObj.isReadOnly) !== "boolean")
|
|
591
|
-
throw new Exception_1.
|
|
591
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'isReadOnly' attribute. It should be of type 'boolean'.`);
|
|
592
592
|
if (undefined !== jsonObj.category && typeof (jsonObj.category) !== "string")
|
|
593
|
-
throw new Exception_1.
|
|
593
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'category' attribute. It should be of type 'string'.`);
|
|
594
594
|
if (undefined !== jsonObj.kindOfQuantity && typeof (jsonObj.kindOfQuantity) !== "string")
|
|
595
|
-
throw new Exception_1.
|
|
595
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'kindOfQuantity' attribute. It should be of type 'string'.`);
|
|
596
596
|
if (undefined !== jsonObj.inherited && typeof (jsonObj.inherited) !== "boolean")
|
|
597
|
-
throw new Exception_1.
|
|
597
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'inherited' attribute. It should be of type 'boolean'.`);
|
|
598
598
|
if (undefined !== jsonObj.customAttributes && !Array.isArray(jsonObj.customAttributes))
|
|
599
|
-
throw new Exception_1.
|
|
599
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'customAttributes' attribute. It should be of type 'array'.`);
|
|
600
600
|
return jsonObj;
|
|
601
601
|
}
|
|
602
602
|
checkPropertyTypename(jsonObj) {
|
|
603
603
|
const propName = jsonObj.name;
|
|
604
604
|
if (undefined === jsonObj.typeName)
|
|
605
|
-
throw new Exception_1.
|
|
605
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} is missing the required 'typeName' attribute.`);
|
|
606
606
|
if (typeof (jsonObj.typeName) !== "string")
|
|
607
|
-
throw new Exception_1.
|
|
607
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'typeName' attribute. It should be of type 'string'.`);
|
|
608
608
|
}
|
|
609
609
|
checkPropertyMinAndMaxOccurs(jsonObj) {
|
|
610
610
|
const propName = jsonObj.name;
|
|
611
611
|
if (undefined !== jsonObj.minOccurs && typeof (jsonObj.minOccurs) !== "number")
|
|
612
|
-
throw new Exception_1.
|
|
612
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minOccurs' attribute. It should be of type 'number'.`);
|
|
613
613
|
if (undefined !== jsonObj.maxOccurs && typeof (jsonObj.maxOccurs) !== "number")
|
|
614
|
-
throw new Exception_1.
|
|
614
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxOccurs' attribute. It should be of type 'number'.`);
|
|
615
615
|
}
|
|
616
616
|
/**
|
|
617
617
|
* Type checks PrimitiveOrEnumProperty and returns PrimitiveOrEnumPropertyBaseProps interface
|
|
@@ -623,15 +623,15 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
623
623
|
this.checkPropertyTypename(jsonObj);
|
|
624
624
|
const propName = jsonObj.name;
|
|
625
625
|
if (undefined !== jsonObj.minLength && typeof (jsonObj.minLength) !== "number")
|
|
626
|
-
throw new Exception_1.
|
|
626
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minLength' attribute. It should be of type 'number'.`);
|
|
627
627
|
if (undefined !== jsonObj.maxLength && typeof (jsonObj.maxLength) !== "number")
|
|
628
|
-
throw new Exception_1.
|
|
628
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxLength' attribute. It should be of type 'number'.`);
|
|
629
629
|
if (undefined !== jsonObj.minValue && typeof (jsonObj.minValue) !== "number")
|
|
630
|
-
throw new Exception_1.
|
|
630
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minValue' attribute. It should be of type 'number'.`);
|
|
631
631
|
if (undefined !== jsonObj.maxValue && typeof (jsonObj.maxValue) !== "number")
|
|
632
|
-
throw new Exception_1.
|
|
632
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maxValue' attribute. It should be of type 'number'.`);
|
|
633
633
|
if (undefined !== jsonObj.extendedTypeName && typeof (jsonObj.extendedTypeName) !== "string")
|
|
634
|
-
throw new Exception_1.
|
|
634
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'extendedTypeName' attribute. It should be of type 'string'.`);
|
|
635
635
|
return jsonObj;
|
|
636
636
|
}
|
|
637
637
|
/**
|
|
@@ -683,13 +683,13 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
683
683
|
this.checkPropertyProps(jsonObj);
|
|
684
684
|
const fullname = `${this._currentItemFullName}.${jsonObj.name}`;
|
|
685
685
|
if (undefined === jsonObj.relationshipName)
|
|
686
|
-
throw new Exception_1.
|
|
686
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'relationshipName' property.`);
|
|
687
687
|
if (typeof (jsonObj.relationshipName) !== "string")
|
|
688
|
-
throw new Exception_1.
|
|
688
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'relationshipName' property. It should be of type 'string'.`);
|
|
689
689
|
if (undefined === jsonObj.direction)
|
|
690
|
-
throw new Exception_1.
|
|
690
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} is missing the required 'direction' property.`);
|
|
691
691
|
if (typeof (jsonObj.direction) !== "string")
|
|
692
|
-
throw new Exception_1.
|
|
692
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Navigation Property ${fullname} has an invalid 'direction' property. It should be of type 'string'.`);
|
|
693
693
|
return jsonObj;
|
|
694
694
|
}
|
|
695
695
|
getSchemaCustomAttributeProviders() {
|
|
@@ -709,14 +709,14 @@ class JsonParser extends AbstractParser_1.AbstractParser {
|
|
|
709
709
|
*getCustomAttributeProviders(jsonObj, type, name) {
|
|
710
710
|
if (undefined !== jsonObj.customAttributes) {
|
|
711
711
|
if (!Array.isArray(jsonObj.customAttributes))
|
|
712
|
-
throw new Exception_1.
|
|
712
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
|
|
713
713
|
for (const instance of jsonObj.customAttributes) {
|
|
714
714
|
if (!isObject(instance) || Array.isArray(instance))
|
|
715
|
-
throw new Exception_1.
|
|
715
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ${type} ${name} has an invalid 'customAttributes' attribute. It should be of type 'object[]'.`);
|
|
716
716
|
if (undefined === instance.className)
|
|
717
|
-
throw new Exception_1.
|
|
717
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes is missing the required 'className' attribute.`);
|
|
718
718
|
if (typeof (instance.className) !== "string")
|
|
719
|
-
throw new Exception_1.
|
|
719
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `A CustomAttribute in ${name}.customAttributes has an invalid 'className' attribute. It should be of type 'string'.`);
|
|
720
720
|
const provider = (_caClass) => {
|
|
721
721
|
return instance;
|
|
722
722
|
};
|