@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
|
@@ -34,7 +34,7 @@ const Unit_1 = require("./Unit");
|
|
|
34
34
|
const UnitSystem_1 = require("./UnitSystem");
|
|
35
35
|
const Constants_1 = require("../Constants");
|
|
36
36
|
/**
|
|
37
|
-
* @
|
|
37
|
+
* @public @preview
|
|
38
38
|
*/
|
|
39
39
|
class Schema {
|
|
40
40
|
static _currentECSpecVersion = "3.2";
|
|
@@ -58,34 +58,34 @@ class Schema {
|
|
|
58
58
|
this._alias = alias;
|
|
59
59
|
}
|
|
60
60
|
else if (nameOrKey !== undefined) {
|
|
61
|
-
throw new Exception_1.
|
|
61
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
|
|
62
62
|
}
|
|
63
63
|
this._originalECSpecMajorVersion = Schema.currentECSpecMajorVersion;
|
|
64
64
|
this._originalECSpecMinorVersion = Schema.currentECSpecMinorVersion;
|
|
65
65
|
}
|
|
66
66
|
get schemaKey() {
|
|
67
67
|
if (undefined === this._schemaKey)
|
|
68
|
-
throw new Exception_1.
|
|
68
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
69
69
|
return this._schemaKey;
|
|
70
70
|
}
|
|
71
71
|
get name() {
|
|
72
72
|
if (this._schemaKey === undefined)
|
|
73
|
-
throw new Exception_1.
|
|
73
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
74
74
|
return this.schemaKey.name;
|
|
75
75
|
}
|
|
76
76
|
get readVersion() {
|
|
77
77
|
if (this._schemaKey === undefined)
|
|
78
|
-
throw new Exception_1.
|
|
78
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
79
79
|
return this.schemaKey.readVersion;
|
|
80
80
|
}
|
|
81
81
|
get writeVersion() {
|
|
82
82
|
if (this._schemaKey === undefined)
|
|
83
|
-
throw new Exception_1.
|
|
83
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
84
84
|
return this.schemaKey.writeVersion;
|
|
85
85
|
}
|
|
86
86
|
get minorVersion() {
|
|
87
87
|
if (this._schemaKey === undefined)
|
|
88
|
-
throw new Exception_1.
|
|
88
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The schema has an invalid or missing SchemaKey.`);
|
|
89
89
|
return this.schemaKey.minorVersion;
|
|
90
90
|
}
|
|
91
91
|
get originalECSpecMajorVersion() { return this._originalECSpecMajorVersion; }
|
|
@@ -98,7 +98,7 @@ class Schema {
|
|
|
98
98
|
}
|
|
99
99
|
get alias() {
|
|
100
100
|
if (this._alias === undefined || this._alias === null) {
|
|
101
|
-
throw new Exception_1.
|
|
101
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not have the required 'alias' attribute.`);
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
104
|
return this._alias;
|
|
@@ -123,18 +123,19 @@ class Schema {
|
|
|
123
123
|
if (this.name !== schemaName) {
|
|
124
124
|
const newSchemaRef = this.getReferenceSync(schemaName);
|
|
125
125
|
if (undefined === newSchemaRef)
|
|
126
|
-
throw new Exception_1.
|
|
126
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `Unable to find the referenced SchemaItem ${itemName}.`);
|
|
127
127
|
schemaKey = newSchemaRef.schemaKey;
|
|
128
128
|
}
|
|
129
129
|
return new SchemaKey_1.SchemaItemKey(itemName, schemaKey);
|
|
130
130
|
}
|
|
131
|
+
/** @internal */
|
|
131
132
|
addItem(item) {
|
|
132
133
|
if (undefined !== this.getItemSync(item.name))
|
|
133
|
-
throw new Exception_1.
|
|
134
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateItem, `The SchemaItem ${item.name} cannot be added to the schema ${this.name} because it already exists`);
|
|
134
135
|
this._items.set(item.name.toUpperCase(), item);
|
|
135
136
|
}
|
|
136
137
|
/**
|
|
137
|
-
* @
|
|
138
|
+
* @internal
|
|
138
139
|
*/
|
|
139
140
|
createClass(type, name, modifier) {
|
|
140
141
|
const item = new type(this, name, modifier);
|
|
@@ -144,7 +145,7 @@ class Schema {
|
|
|
144
145
|
/**
|
|
145
146
|
* Deletes a class from within this schema.
|
|
146
147
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
147
|
-
* @
|
|
148
|
+
* @internal
|
|
148
149
|
*/
|
|
149
150
|
async deleteClass(name) {
|
|
150
151
|
const schemaItem = await this.getItem(name);
|
|
@@ -155,7 +156,7 @@ class Schema {
|
|
|
155
156
|
/**
|
|
156
157
|
* Deletes a class from within this schema.
|
|
157
158
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
158
|
-
* @
|
|
159
|
+
* @internal
|
|
159
160
|
*/
|
|
160
161
|
deleteClassSync(name) {
|
|
161
162
|
const schemaItem = this.getItemSync(name);
|
|
@@ -165,7 +166,7 @@ class Schema {
|
|
|
165
166
|
/**
|
|
166
167
|
* Deletes a SchemaItem from within this schema.
|
|
167
168
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
168
|
-
* @
|
|
169
|
+
* @internal
|
|
169
170
|
*/
|
|
170
171
|
async deleteSchemaItem(name) {
|
|
171
172
|
const schemaItem = await this.getItem(name);
|
|
@@ -176,21 +177,20 @@ class Schema {
|
|
|
176
177
|
/**
|
|
177
178
|
* Deletes a SchemaItem from within this schema.
|
|
178
179
|
* @param name the local (unqualified) class name, lookup is case-insensitive
|
|
179
|
-
* @
|
|
180
|
+
* @internal
|
|
180
181
|
*/
|
|
181
182
|
deleteSchemaItemSync(name) {
|
|
182
183
|
const schemaItem = this.getItemSync(name);
|
|
183
184
|
if (SchemaItem_1.SchemaItem.isSchemaItem(schemaItem))
|
|
184
185
|
this._items.delete(name.toUpperCase());
|
|
185
186
|
}
|
|
186
|
-
/**
|
|
187
|
-
* @alpha
|
|
188
|
-
*/
|
|
187
|
+
/** @internal */
|
|
189
188
|
createItem(type, name) {
|
|
190
189
|
const item = new type(this, name);
|
|
191
190
|
this.addItem(item);
|
|
192
191
|
return item;
|
|
193
192
|
}
|
|
193
|
+
/** @internal */
|
|
194
194
|
addCustomAttribute(customAttribute) {
|
|
195
195
|
if (!this._customAttributes)
|
|
196
196
|
this._customAttributes = new Map();
|
|
@@ -200,27 +200,33 @@ class Schema {
|
|
|
200
200
|
* Creates a EntityClass with the provided name in this schema.
|
|
201
201
|
* @param name
|
|
202
202
|
* @param modifier
|
|
203
|
+
* @internal
|
|
203
204
|
*/
|
|
204
205
|
async createEntityClass(name, modifier) {
|
|
205
206
|
return this.createClass(EntityClass_1.EntityClass, name, modifier);
|
|
206
207
|
}
|
|
208
|
+
/** @internal */
|
|
207
209
|
createEntityClassSync(name, modifier) {
|
|
208
210
|
return this.createClass(EntityClass_1.EntityClass, name, modifier);
|
|
209
211
|
}
|
|
210
212
|
/**
|
|
211
213
|
* Creates a Mixin with the provided name in this schema.
|
|
212
214
|
* @param name
|
|
215
|
+
* @internal
|
|
213
216
|
*/
|
|
214
217
|
async createMixinClass(name) { return this.createClass(Mixin_1.Mixin, name); }
|
|
218
|
+
/** @internal */
|
|
215
219
|
createMixinClassSync(name) { return this.createClass(Mixin_1.Mixin, name); }
|
|
216
220
|
/**
|
|
217
221
|
* Creates a StructClass with the provided name in this schema.
|
|
218
222
|
* @param name
|
|
219
223
|
* @param modifier
|
|
224
|
+
* @internal
|
|
220
225
|
*/
|
|
221
226
|
async createStructClass(name, modifier) {
|
|
222
227
|
return this.createClass(Class_1.StructClass, name, modifier);
|
|
223
228
|
}
|
|
229
|
+
/** @internal */
|
|
224
230
|
createStructClassSync(name, modifier) {
|
|
225
231
|
return this.createClass(Class_1.StructClass, name, modifier);
|
|
226
232
|
}
|
|
@@ -228,10 +234,12 @@ class Schema {
|
|
|
228
234
|
* Creates a CustomAttributeClass with the provided name in this schema.
|
|
229
235
|
* @param name
|
|
230
236
|
* @param modifier
|
|
237
|
+
* @internal
|
|
231
238
|
*/
|
|
232
239
|
async createCustomAttributeClass(name, modifier) {
|
|
233
240
|
return this.createClass(CustomAttributeClass_1.CustomAttributeClass, name, modifier);
|
|
234
241
|
}
|
|
242
|
+
/** @internal */
|
|
235
243
|
createCustomAttributeClassSync(name, modifier) {
|
|
236
244
|
return this.createClass(CustomAttributeClass_1.CustomAttributeClass, name, modifier);
|
|
237
245
|
}
|
|
@@ -239,20 +247,26 @@ class Schema {
|
|
|
239
247
|
* Creates a RelationshipClass with the provided name in this schema.
|
|
240
248
|
* @param name
|
|
241
249
|
* @param modifier
|
|
250
|
+
* @internal
|
|
242
251
|
*/
|
|
243
252
|
async createRelationshipClass(name, modifier) {
|
|
244
253
|
return this.createRelationshipClassSync(name, modifier);
|
|
245
254
|
}
|
|
255
|
+
/** @internal */
|
|
246
256
|
createRelationshipClassSync(name, modifier) {
|
|
247
257
|
return this.createClass(RelationshipClass_1.RelationshipClass, name, modifier);
|
|
248
258
|
}
|
|
249
259
|
/**
|
|
250
260
|
* Creates an Enumeration with the provided name in this schema.
|
|
251
261
|
* @param name
|
|
262
|
+
* @param primitiveType
|
|
263
|
+
*
|
|
264
|
+
* @internal
|
|
252
265
|
*/
|
|
253
266
|
async createEnumeration(name, primitiveType) {
|
|
254
267
|
return this.createEnumerationSync(name, primitiveType);
|
|
255
268
|
}
|
|
269
|
+
/** @internal */
|
|
256
270
|
createEnumerationSync(name, primitiveType) {
|
|
257
271
|
const item = new Enumeration_1.Enumeration(this, name, primitiveType);
|
|
258
272
|
this.addItem(item);
|
|
@@ -261,97 +275,113 @@ class Schema {
|
|
|
261
275
|
/**
|
|
262
276
|
* Creates an KindOfQuantity with the provided name in this schema.
|
|
263
277
|
* @param name
|
|
278
|
+
* @internal
|
|
264
279
|
*/
|
|
265
280
|
async createKindOfQuantity(name) {
|
|
266
281
|
return this.createKindOfQuantitySync(name);
|
|
267
282
|
}
|
|
283
|
+
/** @internal */
|
|
268
284
|
createKindOfQuantitySync(name) {
|
|
269
285
|
return this.createItem(KindOfQuantity_1.KindOfQuantity, name);
|
|
270
286
|
}
|
|
271
287
|
/**
|
|
272
288
|
* Creates a Constant with the provided name in this schema.
|
|
273
289
|
* @param name
|
|
290
|
+
* @internal
|
|
274
291
|
*/
|
|
275
292
|
async createConstant(name) {
|
|
276
293
|
return this.createItem(Constant_1.Constant, name);
|
|
277
294
|
}
|
|
295
|
+
/** @internal */
|
|
278
296
|
createConstantSync(name) {
|
|
279
297
|
return this.createItem(Constant_1.Constant, name);
|
|
280
298
|
}
|
|
281
299
|
/**
|
|
282
300
|
* Creates a Inverted Unit with the provided name in this schema.
|
|
283
301
|
* @param name
|
|
302
|
+
* @internal
|
|
284
303
|
*/
|
|
285
304
|
async createInvertedUnit(name) {
|
|
286
305
|
return this.createItem(InvertedUnit_1.InvertedUnit, name);
|
|
287
306
|
}
|
|
307
|
+
/** @internal */
|
|
288
308
|
createInvertedUnitSync(name) {
|
|
289
309
|
return this.createItem(InvertedUnit_1.InvertedUnit, name);
|
|
290
310
|
}
|
|
291
311
|
/**
|
|
292
312
|
* Creates an Format with the provided name in this schema.
|
|
293
313
|
* @param name
|
|
314
|
+
* @internal
|
|
294
315
|
*/
|
|
295
316
|
async createFormat(name) {
|
|
296
317
|
return this.createItem(Format_1.Format, name);
|
|
297
318
|
}
|
|
319
|
+
/** @internal */
|
|
298
320
|
createFormatSync(name) {
|
|
299
321
|
return this.createItem(Format_1.Format, name);
|
|
300
322
|
}
|
|
301
323
|
/**
|
|
302
324
|
* Creates a UnitSystem with the provided name in this schema.
|
|
303
325
|
* @param name
|
|
326
|
+
* @internal
|
|
304
327
|
*/
|
|
305
328
|
async createUnitSystem(name) {
|
|
306
329
|
return this.createItem(UnitSystem_1.UnitSystem, name);
|
|
307
330
|
}
|
|
331
|
+
/** @internal */
|
|
308
332
|
createUnitSystemSync(name) {
|
|
309
333
|
return this.createItem(UnitSystem_1.UnitSystem, name);
|
|
310
334
|
}
|
|
311
335
|
/**
|
|
312
336
|
* Creates a Phenomenon with the provided name in this schema.
|
|
313
337
|
* @param name
|
|
338
|
+
* @internal
|
|
314
339
|
*/
|
|
315
340
|
async createPhenomenon(name) {
|
|
316
341
|
return this.createItem(Phenomenon_1.Phenomenon, name);
|
|
317
342
|
}
|
|
343
|
+
/** @internal */
|
|
318
344
|
createPhenomenonSync(name) {
|
|
319
345
|
return this.createItem(Phenomenon_1.Phenomenon, name);
|
|
320
346
|
}
|
|
321
347
|
/**
|
|
322
348
|
* Creates a Unit with the provided name in this schema.
|
|
323
349
|
* @param name
|
|
350
|
+
* @internal
|
|
324
351
|
*/
|
|
325
352
|
async createUnit(name) {
|
|
326
353
|
return this.createItem(Unit_1.Unit, name);
|
|
327
354
|
}
|
|
355
|
+
/** @internal */
|
|
328
356
|
createUnitSync(name) {
|
|
329
357
|
return this.createItem(Unit_1.Unit, name);
|
|
330
358
|
}
|
|
331
359
|
/**
|
|
332
360
|
* Creates an PropertyCategory with the provided name in this schema.
|
|
333
361
|
* @param name
|
|
362
|
+
* @internal
|
|
334
363
|
*/
|
|
335
364
|
async createPropertyCategory(name) {
|
|
336
365
|
return this.createItem(PropertyCategory_1.PropertyCategory, name);
|
|
337
366
|
}
|
|
367
|
+
/** @internal */
|
|
338
368
|
createPropertyCategorySync(name) {
|
|
339
369
|
return this.createItem(PropertyCategory_1.PropertyCategory, name);
|
|
340
370
|
}
|
|
341
371
|
/**
|
|
342
372
|
*
|
|
343
373
|
* @param refSchema
|
|
374
|
+
* @internal
|
|
344
375
|
*/
|
|
345
376
|
async addReference(refSchema) {
|
|
346
377
|
// TODO validation of reference schema. For now just adding
|
|
347
378
|
this.addReferenceSync(refSchema);
|
|
348
379
|
}
|
|
380
|
+
/** @internal */
|
|
349
381
|
addReferenceSync(refSchema) {
|
|
350
382
|
this.references.push(refSchema);
|
|
351
383
|
}
|
|
352
|
-
/**
|
|
353
|
-
* @alpha Used for schema editing.
|
|
354
|
-
*/
|
|
384
|
+
/** @internal */
|
|
355
385
|
setContext(context) {
|
|
356
386
|
this._context = context;
|
|
357
387
|
}
|
|
@@ -360,10 +390,11 @@ class Schema {
|
|
|
360
390
|
* @param readVersion The read version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
361
391
|
* @param writeVersion The write version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
362
392
|
* @param minorVersion The minor version of the schema. If undefined, the value from the existing SchemaKey will be used.
|
|
393
|
+
* @internal
|
|
363
394
|
*/
|
|
364
395
|
setVersion(readVersion, writeVersion, minorVersion) {
|
|
365
396
|
if (!this._schemaKey)
|
|
366
|
-
throw new Exception_1.
|
|
397
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaKey, `The schema '${this.name}' has an invalid SchemaKey.`);
|
|
367
398
|
const newVersion = new SchemaKey_1.ECVersion(readVersion ?? this._schemaKey.readVersion, writeVersion ?? this._schemaKey.writeVersion, minorVersion ?? this._schemaKey.minorVersion);
|
|
368
399
|
this._schemaKey = new SchemaKey_1.SchemaKey(this._schemaKey.name, newVersion);
|
|
369
400
|
}
|
|
@@ -548,7 +579,7 @@ class Schema {
|
|
|
548
579
|
*/
|
|
549
580
|
toJSON() {
|
|
550
581
|
if (this._isECSpecVersionUnsupported)
|
|
551
|
-
throw new Exception_1.
|
|
582
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
|
|
552
583
|
const schemaJson = {};
|
|
553
584
|
schemaJson.$schema = Constants_1.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON; // $schema is required
|
|
554
585
|
schemaJson.name = this.name; // name is required
|
|
@@ -577,7 +608,7 @@ class Schema {
|
|
|
577
608
|
*/
|
|
578
609
|
async toXml(schemaXml) {
|
|
579
610
|
if (this._isECSpecVersionUnsupported)
|
|
580
|
-
throw new Exception_1.
|
|
611
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.NewerECSpecVersion, `The Schema '${this.name}' has an unsupported ECSpecVersion and cannot be serialized.`);
|
|
581
612
|
const schemaMetadata = schemaXml.createElement("ECSchema");
|
|
582
613
|
schemaMetadata.setAttribute("xmlns", Constants_1.ECSchemaNamespaceUris.SCHEMAURL3_2_XML);
|
|
583
614
|
schemaMetadata.setAttribute("version", this.schemaKey.version.toString());
|
|
@@ -623,12 +654,12 @@ class Schema {
|
|
|
623
654
|
}
|
|
624
655
|
else {
|
|
625
656
|
if (schemaProps.name.toLowerCase() !== this.name.toLowerCase())
|
|
626
|
-
throw new Exception_1.
|
|
657
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} does not match the provided name, '${schemaProps.name}'.`);
|
|
627
658
|
if (this.schemaKey.version.compare(SchemaKey_1.ECVersion.fromString(schemaProps.version)))
|
|
628
|
-
throw new Exception_1.
|
|
659
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${this.name} has the version '${this.schemaKey.version}' that does not match the provided version '${schemaProps.version}'.`);
|
|
629
660
|
}
|
|
630
661
|
if (schemaProps.$schema.match(`https://dev\\.bentley\\.com/json_schemas/ec/([0-9]+)/ecschema`) == null && schemaProps.$schema.match(`http://www\\.bentley\\.com/schemas/Bentley\\.ECXML\\.([0-9]+)`) == null)
|
|
631
|
-
throw new Exception_1.
|
|
662
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.MissingSchemaUrl, `The Schema '${this.name}' has an unsupported namespace '${schemaProps.$schema}'.`);
|
|
632
663
|
// The schema props have not been parsed. Parse the ECXml version from the $schema attribute
|
|
633
664
|
let ecVersion;
|
|
634
665
|
if (schemaProps.ecSpecMajorVersion === undefined || schemaProps.ecSpecMinorVersion === undefined) {
|
|
@@ -640,12 +671,12 @@ class Schema {
|
|
|
640
671
|
this._originalECSpecMajorVersion = ecVersion.readVersion;
|
|
641
672
|
this._originalECSpecMinorVersion = ecVersion.writeVersion;
|
|
642
673
|
if (ecVersion.readVersion !== 3 || (ecVersion.readVersion === 3 && ecVersion.writeVersion < 2))
|
|
643
|
-
throw new Exception_1.
|
|
674
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECVersion, `The Schema '${this.name}' has an unsupported ECVersion ${ecVersion.readVersion}.${ecVersion.writeVersion} and cannot be loaded.`);
|
|
644
675
|
if (ECName_1.ECName.validate(schemaProps.alias)) {
|
|
645
676
|
this._alias = schemaProps.alias;
|
|
646
677
|
}
|
|
647
678
|
else {
|
|
648
|
-
throw new Exception_1.
|
|
679
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Schema ${schemaProps.name} does not have the required 'alias' attribute.`);
|
|
649
680
|
}
|
|
650
681
|
if (undefined !== schemaProps.label)
|
|
651
682
|
this._label = schemaProps.label;
|
|
@@ -692,27 +723,18 @@ class Schema {
|
|
|
692
723
|
const schema = object;
|
|
693
724
|
return schema !== undefined && schema.schemaKey !== undefined && schema.context !== undefined;
|
|
694
725
|
}
|
|
695
|
-
/**
|
|
696
|
-
* @alpha
|
|
697
|
-
* Used for schema editing.
|
|
698
|
-
*/
|
|
726
|
+
/** @internal */
|
|
699
727
|
setDisplayLabel(displayLabel) {
|
|
700
728
|
this._label = displayLabel;
|
|
701
729
|
}
|
|
702
|
-
/**
|
|
703
|
-
* @alpha
|
|
704
|
-
* Used for schema editing.
|
|
705
|
-
*/
|
|
730
|
+
/** @internal */
|
|
706
731
|
setDescription(description) {
|
|
707
732
|
this._description = description;
|
|
708
733
|
}
|
|
709
|
-
/**
|
|
710
|
-
* @alpha
|
|
711
|
-
* Used for schema editing.
|
|
712
|
-
*/
|
|
734
|
+
/** @internal */
|
|
713
735
|
setAlias(alias) {
|
|
714
736
|
if (!ECName_1.ECName.validate(alias)) {
|
|
715
|
-
throw new Exception_1.
|
|
737
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECName, "The specified schema alias is invalid.");
|
|
716
738
|
}
|
|
717
739
|
this._alias = alias;
|
|
718
740
|
}
|