@itwin/ecschema-metadata 5.0.0-dev.98 → 5.1.0-dev.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 +6 -1
- package/lib/cjs/Constants.js.map +1 -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/AbstractParser.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/SchemaGraphUtil.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/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.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/Constants.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/AbstractParser.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/SchemaGraphUtil.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/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/Parser.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { PrimitiveType, primitiveTypeToString } from "../ECObjects";
|
|
6
|
-
import {
|
|
6
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
7
7
|
/**
|
|
8
8
|
* Namespace holding utility functions for serializing EC types to the EC XML format.
|
|
9
9
|
* @internal
|
|
@@ -16,12 +16,11 @@ export var XmlSerializationUtils;
|
|
|
16
16
|
* @param customAttribute The CustomAttribute instance to serialize.
|
|
17
17
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
18
18
|
* @param schema The Schema object being serialized.
|
|
19
|
-
* @beta
|
|
20
19
|
*/
|
|
21
20
|
async function writeCustomAttribute(fullName, customAttribute, schemaDoc, schema) {
|
|
22
21
|
const caClass = await schema.lookupItem(fullName);
|
|
23
22
|
if (!caClass)
|
|
24
|
-
throw new
|
|
23
|
+
throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The class '${fullName}' could not be found in the current schema context.`);
|
|
25
24
|
const nameAndNamespace = await resolveCustomAttributeNamespace(fullName, schema);
|
|
26
25
|
const caElement = schemaDoc.createElement(nameAndNamespace[0]);
|
|
27
26
|
if (nameAndNamespace[1])
|
|
@@ -37,7 +36,6 @@ export var XmlSerializationUtils;
|
|
|
37
36
|
* @param instance The Property instance.
|
|
38
37
|
* @param instanceElement The XML Element that will contain the serialized property instance.
|
|
39
38
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
40
|
-
* @beta
|
|
41
39
|
*/
|
|
42
40
|
async function writeInstanceProperty(propertyClass, instance, instanceElement, schemaDoc) {
|
|
43
41
|
const propertyValue = instance[propertyClass.name];
|
|
@@ -62,7 +60,6 @@ export var XmlSerializationUtils;
|
|
|
62
60
|
* @param propertyValue An array holding the property values.
|
|
63
61
|
* @param arrayElement The XML Element that will contain the serialized property instance.
|
|
64
62
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
65
|
-
* @beta
|
|
66
63
|
*/
|
|
67
64
|
async function writeArrayProperty(propertyClass, propertyValue, arrayElement, schemaDoc) {
|
|
68
65
|
if (propertyClass.isPrimitive()) {
|
|
@@ -88,7 +85,6 @@ export var XmlSerializationUtils;
|
|
|
88
85
|
* @param propertyValue The struct object holding the property values.
|
|
89
86
|
* @param structElement The XML Element that will contain the serialized property instance.
|
|
90
87
|
* @param schemaDoc The Xml Document object holding the serialized EC Schema.
|
|
91
|
-
* @beta
|
|
92
88
|
*/
|
|
93
89
|
async function writeStructProperty(propertyClass, propertyValue, structElement, schemaDoc) {
|
|
94
90
|
const structClass = propertyClass.structClass;
|
|
@@ -101,16 +97,15 @@ export var XmlSerializationUtils;
|
|
|
101
97
|
* @param propertyClass The Property metadata object.
|
|
102
98
|
* @param propertyValue The struct object holding the property values.
|
|
103
99
|
* @param propertyElement The XML Element that will contain the serialized property instance.
|
|
104
|
-
* @beta
|
|
105
100
|
*/
|
|
106
101
|
async function writePrimitiveProperty(propertyClass, propertyValue, propertyElement) {
|
|
107
102
|
let primitiveType;
|
|
108
103
|
if (propertyClass.isEnumeration()) {
|
|
109
104
|
const enumeration = await propertyClass.enumeration;
|
|
110
105
|
if (!enumeration)
|
|
111
|
-
throw new
|
|
106
|
+
throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The enumeration on property class '${propertyClass.fullName}' could not be found in the current schema context.`);
|
|
112
107
|
if (enumeration.type === undefined)
|
|
113
|
-
throw new
|
|
108
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The enumeration on property class '${propertyClass.fullName}' has an invalid primitive type.`);
|
|
114
109
|
primitiveType = enumeration.type;
|
|
115
110
|
}
|
|
116
111
|
else
|
|
@@ -141,7 +136,7 @@ export var XmlSerializationUtils;
|
|
|
141
136
|
propertyElement.textContent = propertyValue;
|
|
142
137
|
return;
|
|
143
138
|
default:
|
|
144
|
-
throw new
|
|
139
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, `The property '${propertyClass.fullName}' has an invalid primitive type.`);
|
|
145
140
|
}
|
|
146
141
|
}
|
|
147
142
|
XmlSerializationUtils.writePrimitiveProperty = writePrimitiveProperty;
|
|
@@ -151,7 +146,7 @@ export var XmlSerializationUtils;
|
|
|
151
146
|
// Alias is required in Spec. It could be undefined (technically), so
|
|
152
147
|
// throw until fixed.
|
|
153
148
|
if (typeSchema.alias === undefined)
|
|
154
|
-
throw new
|
|
149
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaAlias, `The schema '${typeSchema.name}' has an invalid alias.`);
|
|
155
150
|
return `${typeSchema.alias}:${typeName}`;
|
|
156
151
|
}
|
|
157
152
|
XmlSerializationUtils.createXmlTypedName = createXmlTypedName;
|
|
@@ -161,7 +156,7 @@ export var XmlSerializationUtils;
|
|
|
161
156
|
return [caName, undefined];
|
|
162
157
|
const attributeSchema = nameParts[0].toUpperCase() === schema.name.toUpperCase() ? schema : await schema.getReference(nameParts[0]);
|
|
163
158
|
if (!attributeSchema)
|
|
164
|
-
throw new
|
|
159
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to resolve the namespace for CustomAttribute '${caName}' because the referenced schema '${nameParts[0]}' could not be located.`);
|
|
165
160
|
return [nameParts[1], `${nameParts[0]}.${attributeSchema.schemaKey.version.toString()}`];
|
|
166
161
|
}
|
|
167
162
|
})(XmlSerializationUtils || (XmlSerializationUtils = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XmlSerializationUtils.js","sourceRoot":"","sources":["../../../src/Deserialization/XmlSerializationUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAM/D;;;GAGG;AACH,MAAM,KAAW,qBAAqB,CAsKrC;AAtKD,WAAiB,qBAAqB;IACpC;;;;;;;OAOG;IACI,KAAK,UAAU,oBAAoB,CAAC,QAAgB,EAAE,eAAgC,EAAE,SAAmB,EAAE,MAAc;QAChI,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAyB,CAAC;QAC1E,IAAI,CAAC,OAAO;YACV,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,aAAa,EAAE,cAAc,QAAQ,qDAAqD,CAAC,CAAC;QAEvI,MAAM,gBAAgB,GAAG,MAAM,+BAA+B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjF,MAAM,SAAS,GAAG,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAA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C,CAAC,CAAC,CAAC,CAAC;QACpI,IAAI,CAAC,eAAe;YAClB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,wDAAwD,MAAM,oCAAoC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC;QAE1M,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC,EAtKgB,qBAAqB,KAArB,qBAAqB,QAsKrC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PrimitiveType, primitiveTypeToString } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\nimport { ArrayProperty, EnumerationProperty, PrimitiveOrEnumPropertyBase, PrimitiveProperty, Property, StructProperty } from \"../Metadata/Property\";\nimport { Schema } from \"../Metadata/Schema\";\n\n/**\n * Namespace holding utility functions for serializing EC types to the EC XML format.\n * @internal\n */\nexport namespace XmlSerializationUtils {\n /**\n * Serializes a CustomAttribute instance to the EC XML format.\n * @param fullName The full name of the CustomAttribute (qualified by schema name).\n * @param customAttribute The CustomAttribute instance to serialize.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n * @param schema The Schema object being serialized.\n * @beta\n */\n export async function writeCustomAttribute(fullName: string, customAttribute: CustomAttribute, schemaDoc: Document, schema: Schema): Promise<Element> {\n const caClass = await schema.lookupItem(fullName) as CustomAttributeClass;\n if (!caClass)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `The class '${fullName}' could not be found in the current schema context.`);\n\n const nameAndNamespace = await resolveCustomAttributeNamespace(fullName, schema);\n const caElement = schemaDoc.createElement(nameAndNamespace[0]);\n\n if (nameAndNamespace[1])\n caElement.setAttribute(\"xmlns\", nameAndNamespace[1]);\n\n for (const property of await caClass.getProperties())\n await writeInstanceProperty(property, customAttribute, caElement, schemaDoc);\n\n return caElement;\n }\n\n /**\n * Serializes an EC Property instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param instance The Property instance.\n * @param instanceElement The XML Element that will contain the serialized property instance.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n * @beta\n */\n export async function writeInstanceProperty(propertyClass: Property, instance: any, instanceElement: Element, schemaDoc: Document): Promise<void> {\n const propertyValue = instance[propertyClass.name];\n if (propertyValue === undefined)\n return;\n\n const propertyElement = schemaDoc.createElement(propertyClass.name);\n instanceElement.appendChild(propertyElement);\n\n if (propertyClass.isArray()) {\n await writeArrayProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\n } else if (propertyClass.isPrimitive()) {\n await writePrimitiveProperty(propertyClass, propertyValue, propertyElement);\n } else if (propertyClass.isStruct()) {\n await writeStructProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\n }\n }\n\n /**\n * Serializes an EC ArrayProperty instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param propertyValue An array holding the property values.\n * @param arrayElement The XML Element that will contain the serialized property instance.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n * @beta\n */\n export async function writeArrayProperty(propertyClass: ArrayProperty, propertyValue: any[], arrayElement: Element, schemaDoc: Document): Promise<void> {\n if (propertyClass.isPrimitive()) {\n const typeString = primitiveTypeToString(propertyClass.primitiveType);\n for (const value of propertyValue) {\n const entryElement = schemaDoc.createElement(typeString);\n await writePrimitiveProperty(propertyClass, value, entryElement);\n arrayElement.appendChild(entryElement);\n }\n }\n\n if (propertyClass.isStruct()) {\n for (const value of propertyValue) {\n const structElement = schemaDoc.createElement(propertyClass.structClass.name);\n arrayElement.appendChild(structElement);\n await writeStructProperty(propertyClass, value, structElement, schemaDoc);\n }\n }\n }\n\n /**\n * Serializes an EC StructProperty instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param propertyValue The struct object holding the property values.\n * @param structElement The XML Element that will contain the serialized property instance.\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\n * @beta\n */\n export async function writeStructProperty(propertyClass: StructProperty, propertyValue: any, structElement: Element, schemaDoc: Document): Promise<void> {\n const structClass = propertyClass.structClass;\n for (const propertyMetadata of structClass.getPropertiesSync(true))\n await writeInstanceProperty(propertyMetadata, propertyValue, structElement, schemaDoc);\n }\n\n /**\n * Serializes an EC PrimitiveProperty instance to the EC XML format.\n * @param propertyClass The Property metadata object.\n * @param propertyValue The struct object holding the property values.\n * @param propertyElement The XML Element that will contain the serialized property instance.\n * @beta\n */\n export async function writePrimitiveProperty(propertyClass: PrimitiveOrEnumPropertyBase, propertyValue: any, propertyElement: Element): Promise<void> {\n let primitiveType: PrimitiveType;\n if (propertyClass.isEnumeration()) {\n const enumeration = await (propertyClass as EnumerationProperty).enumeration;\n if (!enumeration)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `The enumeration on property class '${propertyClass.fullName}' could not be found in the current schema context.`);\n\n if (enumeration.type === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The enumeration on property class '${propertyClass.fullName}' has an invalid primitive type.`);\n\n primitiveType = enumeration.type;\n } else\n primitiveType = (propertyClass as PrimitiveProperty).primitiveType;\n\n switch (primitiveType) {\n case PrimitiveType.String:\n propertyElement.textContent = propertyValue;\n return;\n case PrimitiveType.Boolean:\n propertyElement.textContent = (propertyValue as boolean) ? \"True\" : \"False\";\n return;\n case PrimitiveType.Integer:\n case PrimitiveType.Double:\n case PrimitiveType.Long:\n propertyElement.textContent = propertyValue.toString();\n return;\n case PrimitiveType.DateTime:\n propertyElement.textContent = new Date(propertyValue).getTime().toString();\n return;\n case PrimitiveType.Point2d:\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y}`;\n return;\n case PrimitiveType.Point3d:\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y},${propertyValue.z}`;\n return;\n case PrimitiveType.IGeometry:\n case PrimitiveType.Binary:\n propertyElement.textContent = propertyValue;\n return;\n default:\n throw new ECObjectsError(ECObjectsStatus.InvalidPrimitiveType, `The property '${propertyClass.fullName}' has an invalid primitive type.`);\n }\n }\n\n export function createXmlTypedName(currentSchema: Schema, typeSchema: Schema, typeName: string) {\n if (currentSchema.schemaKey.matches(typeSchema.schemaKey))\n return typeName;\n\n // Alias is required in Spec. It could be undefined (technically), so\n // throw until fixed.\n if (typeSchema.alias === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaAlias, `The schema '${typeSchema.name}' has an invalid alias.`);\n\n return `${typeSchema.alias}:${typeName}`;\n }\n\n async function resolveCustomAttributeNamespace(caName: string, schema: Schema): Promise<[string, string | undefined]> {\n const nameParts = caName.split(\".\");\n if (nameParts.length === 1)\n return [caName, undefined];\n\n const attributeSchema = nameParts[0].toUpperCase() === schema.name.toUpperCase() ? schema : await schema.getReference(nameParts[0]);\n if (!attributeSchema)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to resolve the namespace for CustomAttribute '${caName}' because the referenced schema '${nameParts[0]}' could not be located.`);\n\n return [nameParts[1], `${nameParts[0]}.${attributeSchema.schemaKey.version.toString()}`];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"XmlSerializationUtils.js","sourceRoot":"","sources":["../../../src/Deserialization/XmlSerializationUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM7D;;;GAGG;AACH,MAAM,KAAW,qBAAqB,CAiKrC;AAjKD,WAAiB,qBAAqB;IACpC;;;;;;OAMG;IACI,KAAK,UAAU,oBAAoB,CAAC,Q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MAAc,EAAE,MAAc;QAC3E,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YACxB,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAE7B,MAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACpI,IAAI,CAAC,eAAe;YAClB,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,wDAAwD,MAAM,oCAAoC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC;QAExM,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC,EAjKgB,qBAAqB,KAArB,qBAAqB,QAiKrC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { PrimitiveType, primitiveTypeToString } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { ArrayProperty, EnumerationProperty, PrimitiveOrEnumPropertyBase, PrimitiveProperty, Property, StructProperty } from \"../Metadata/Property\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\n\r\n/**\r\n * Namespace holding utility functions for serializing EC types to the EC XML format.\r\n * @internal\r\n */\r\nexport namespace XmlSerializationUtils {\r\n /**\r\n * Serializes a CustomAttribute instance to the EC XML format.\r\n * @param fullName The full name of the CustomAttribute (qualified by schema name).\r\n * @param customAttribute The CustomAttribute instance to serialize.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n * @param schema The Schema object being serialized.\r\n */\r\n export async function writeCustomAttribute(fullName: string, customAttribute: CustomAttribute, schemaDoc: Document, schema: Schema): Promise<Element> {\r\n const caClass = await schema.lookupItem(fullName) as CustomAttributeClass;\r\n if (!caClass)\r\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The class '${fullName}' could not be found in the current schema context.`);\r\n\r\n const nameAndNamespace = await resolveCustomAttributeNamespace(fullName, schema);\r\n const caElement = schemaDoc.createElement(nameAndNamespace[0]);\r\n\r\n if (nameAndNamespace[1])\r\n caElement.setAttribute(\"xmlns\", nameAndNamespace[1]);\r\n\r\n for (const property of await caClass.getProperties())\r\n await writeInstanceProperty(property, customAttribute, caElement, schemaDoc);\r\n\r\n return caElement;\r\n }\r\n\r\n /**\r\n * Serializes an EC Property instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param instance The Property instance.\r\n * @param instanceElement The XML Element that will contain the serialized property instance.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n */\r\n export async function writeInstanceProperty(propertyClass: Property, instance: any, instanceElement: Element, schemaDoc: Document): Promise<void> {\r\n const propertyValue = instance[propertyClass.name];\r\n if (propertyValue === undefined)\r\n return;\r\n\r\n const propertyElement = schemaDoc.createElement(propertyClass.name);\r\n instanceElement.appendChild(propertyElement);\r\n\r\n if (propertyClass.isArray()) {\r\n await writeArrayProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\r\n } else if (propertyClass.isPrimitive()) {\r\n await writePrimitiveProperty(propertyClass, propertyValue, propertyElement);\r\n } else if (propertyClass.isStruct()) {\r\n await writeStructProperty(propertyClass, propertyValue, propertyElement, schemaDoc);\r\n }\r\n }\r\n\r\n /**\r\n * Serializes an EC ArrayProperty instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param propertyValue An array holding the property values.\r\n * @param arrayElement The XML Element that will contain the serialized property instance.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n */\r\n export async function writeArrayProperty(propertyClass: ArrayProperty, propertyValue: any[], arrayElement: Element, schemaDoc: Document): Promise<void> {\r\n if (propertyClass.isPrimitive()) {\r\n const typeString = primitiveTypeToString(propertyClass.primitiveType);\r\n for (const value of propertyValue) {\r\n const entryElement = schemaDoc.createElement(typeString);\r\n await writePrimitiveProperty(propertyClass, value, entryElement);\r\n arrayElement.appendChild(entryElement);\r\n }\r\n }\r\n\r\n if (propertyClass.isStruct()) {\r\n for (const value of propertyValue) {\r\n const structElement = schemaDoc.createElement(propertyClass.structClass.name);\r\n arrayElement.appendChild(structElement);\r\n await writeStructProperty(propertyClass, value, structElement, schemaDoc);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes an EC StructProperty instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param propertyValue The struct object holding the property values.\r\n * @param structElement The XML Element that will contain the serialized property instance.\r\n * @param schemaDoc The Xml Document object holding the serialized EC Schema.\r\n */\r\n export async function writeStructProperty(propertyClass: StructProperty, propertyValue: any, structElement: Element, schemaDoc: Document): Promise<void> {\r\n const structClass = propertyClass.structClass;\r\n for (const propertyMetadata of structClass.getPropertiesSync(true))\r\n await writeInstanceProperty(propertyMetadata, propertyValue, structElement, schemaDoc);\r\n }\r\n\r\n /**\r\n * Serializes an EC PrimitiveProperty instance to the EC XML format.\r\n * @param propertyClass The Property metadata object.\r\n * @param propertyValue The struct object holding the property values.\r\n * @param propertyElement The XML Element that will contain the serialized property instance.\r\n */\r\n export async function writePrimitiveProperty(propertyClass: PrimitiveOrEnumPropertyBase, propertyValue: any, propertyElement: Element): Promise<void> {\r\n let primitiveType: PrimitiveType;\r\n if (propertyClass.isEnumeration()) {\r\n const enumeration = await (propertyClass as EnumerationProperty).enumeration;\r\n if (!enumeration)\r\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `The enumeration on property class '${propertyClass.fullName}' could not be found in the current schema context.`);\r\n\r\n if (enumeration.type === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The enumeration on property class '${propertyClass.fullName}' has an invalid primitive type.`);\r\n\r\n primitiveType = enumeration.type;\r\n } else\r\n primitiveType = (propertyClass as PrimitiveProperty).primitiveType;\r\n\r\n switch (primitiveType) {\r\n case PrimitiveType.String:\r\n propertyElement.textContent = propertyValue;\r\n return;\r\n case PrimitiveType.Boolean:\r\n propertyElement.textContent = (propertyValue as boolean) ? \"True\" : \"False\";\r\n return;\r\n case PrimitiveType.Integer:\r\n case PrimitiveType.Double:\r\n case PrimitiveType.Long:\r\n propertyElement.textContent = propertyValue.toString();\r\n return;\r\n case PrimitiveType.DateTime:\r\n propertyElement.textContent = new Date(propertyValue).getTime().toString();\r\n return;\r\n case PrimitiveType.Point2d:\r\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y}`;\r\n return;\r\n case PrimitiveType.Point3d:\r\n propertyElement.textContent = `${propertyValue.x},${propertyValue.y},${propertyValue.z}`;\r\n return;\r\n case PrimitiveType.IGeometry:\r\n case PrimitiveType.Binary:\r\n propertyElement.textContent = propertyValue;\r\n return;\r\n default:\r\n throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, `The property '${propertyClass.fullName}' has an invalid primitive type.`);\r\n }\r\n }\r\n\r\n export function createXmlTypedName(currentSchema: Schema, typeSchema: Schema, typeName: string) {\r\n if (currentSchema.schemaKey.matches(typeSchema.schemaKey))\r\n return typeName;\r\n\r\n // Alias is required in Spec. It could be undefined (technically), so\r\n // throw until fixed.\r\n if (typeSchema.alias === undefined)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaAlias, `The schema '${typeSchema.name}' has an invalid alias.`);\r\n\r\n return `${typeSchema.alias}:${typeName}`;\r\n }\r\n\r\n async function resolveCustomAttributeNamespace(caName: string, schema: Schema): Promise<[string, string | undefined]> {\r\n const nameParts = caName.split(\".\");\r\n if (nameParts.length === 1)\r\n return [caName, undefined];\r\n\r\n const attributeSchema = nameParts[0].toUpperCase() === schema.name.toUpperCase() ? schema : await schema.getReference(nameParts[0]);\r\n if (!attributeSchema)\r\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to resolve the namespace for CustomAttribute '${caName}' because the referenced schema '${nameParts[0]}' could not be located.`);\r\n\r\n return [nameParts[1], `${nameParts[0]}.${attributeSchema.schemaKey.version.toString()}`];\r\n }\r\n}\r\n"]}
|
package/lib/esm/ECName.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
export declare class ECName {
|
|
15
15
|
private _name;
|
|
16
16
|
/** Construct a new ECName from a valid EC name.
|
|
17
|
-
* throws
|
|
17
|
+
* throws ECSchemaError if `name` does not meet the criteria for a valid EC name.
|
|
18
18
|
*/
|
|
19
19
|
constructor(name: string);
|
|
20
20
|
/** Returns true if a string meets the criteria of a valid EC name. */
|
|
@@ -22,7 +22,7 @@ export declare class ECName {
|
|
|
22
22
|
/** The underlying name as a string. */
|
|
23
23
|
get name(): string;
|
|
24
24
|
/** Create an ECName from an arbitrary string, encoding any special characters as "__x####__" where "####" is the UTF-16 character code.
|
|
25
|
-
* @throws
|
|
25
|
+
* @throws ECSchemaError if `input` is an empty string.
|
|
26
26
|
*/
|
|
27
27
|
static encode(input: string): ECName;
|
|
28
28
|
/** Decode this ECName, replacing encoded special characters with the characters they encode. */
|
package/lib/esm/ECName.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
8
|
import { assert } from "@itwin/core-bentley";
|
|
9
|
-
import {
|
|
9
|
+
import { ECSchemaError, ECSchemaStatus } from "./Exception";
|
|
10
10
|
const validECNameRegex = /^([a-zA-Z_]+[a-zA-Z0-9_]*)$/i;
|
|
11
11
|
const ecNameReplacerRegex = /__x([0-9a-fA-F]{4})__/g;
|
|
12
12
|
const leadingDigits = ["0000", "000", "00", "0", ""];
|
|
@@ -31,11 +31,11 @@ function isValidAlphaNumericCharacter(c) {
|
|
|
31
31
|
export class ECName {
|
|
32
32
|
_name;
|
|
33
33
|
/** Construct a new ECName from a valid EC name.
|
|
34
|
-
* throws
|
|
34
|
+
* throws ECSchemaError if `name` does not meet the criteria for a valid EC name.
|
|
35
35
|
*/
|
|
36
36
|
constructor(name) {
|
|
37
37
|
if (!ECName.validate(name))
|
|
38
|
-
throw new
|
|
38
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName);
|
|
39
39
|
this._name = name;
|
|
40
40
|
}
|
|
41
41
|
/** Returns true if a string meets the criteria of a valid EC name. */
|
|
@@ -47,11 +47,11 @@ export class ECName {
|
|
|
47
47
|
return this._name;
|
|
48
48
|
}
|
|
49
49
|
/** Create an ECName from an arbitrary string, encoding any special characters as "__x####__" where "####" is the UTF-16 character code.
|
|
50
|
-
* @throws
|
|
50
|
+
* @throws ECSchemaError if `input` is an empty string.
|
|
51
51
|
*/
|
|
52
52
|
static encode(input) {
|
|
53
53
|
if (0 === input.length)
|
|
54
|
-
throw new
|
|
54
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECName);
|
|
55
55
|
if (ECName.validate(input)) {
|
|
56
56
|
// It's already a valid EC name.
|
|
57
57
|
return new ECName(input);
|
package/lib/esm/ECName.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECName.js","sourceRoot":"","sources":["../../src/ECName.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ECName.js","sourceRoot":"","sources":["../../src/ECName.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,E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ACzF,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAChH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\r\n\r\nconst validECNameRegex = /^([a-zA-Z_]+[a-zA-Z0-9_]*)$/i;\r\nconst ecNameReplacerRegex = /__x([0-9a-fA-F]{4})__/g;\r\nconst leadingDigits = [\"0000\", \"000\", \"00\", \"0\", \"\"];\r\n\r\nfunction isDigit(character: string): boolean {\r\n assert(1 === character.length);\r\n return character >= \"0\" && character <= \"9\";\r\n}\r\n\r\nfunction isValidAlphaNumericCharacter(c: string): boolean {\r\n assert(1 === c.length);\r\n return (((c >= \"0\" && c <= \"9\") || (c >= \"A\" && c <= \"Z\") || (c >= \"a\" && c <= \"z\") || c === \"_\"));\r\n}\r\n\r\n/** The name of an item in a [[Schema]], encoded to meet restrictions on the characters usable in such names.\r\n * An ECName meets the following criteria:\r\n * - Contains at least one character.\r\n * - Does not begin with a digit.\r\n * - Consists entirely of characters in the ASCII ranges A-Z, a-z, and 0-9; and the underscore (\"_\") character.\r\n *\r\n * All characters not meeting the above criteria are encoded as \"__x####__\" where \"####\" is the UTF-16 character code.\r\n * Such names are often automatically generated from the item's display label, which is unrestricted in the characters it may contain.\r\n * @public\r\n */\r\nexport class ECName {\r\n private _name: string;\r\n\r\n /** Construct a new ECName from a valid EC name.\r\n * throws ECSchemaError if `name` does not meet the criteria for a valid EC name.\r\n */\r\n constructor(name: string) {\r\n if (!ECName.validate(name))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECName);\r\n\r\n this._name = name;\r\n }\r\n\r\n /** Returns true if a string meets the criteria of a valid EC name. */\r\n public static validate(name: string): boolean {\r\n return validECNameRegex.test(name);\r\n }\r\n\r\n /** The underlying name as a string. */\r\n public get name(): string {\r\n return this._name;\r\n }\r\n\r\n /** Create an ECName from an arbitrary string, encoding any special characters as \"__x####__\" where \"####\" is the UTF-16 character code.\r\n * @throws ECSchemaError if `input` is an empty string.\r\n */\r\n public static encode(input: string): ECName {\r\n if (0 === input.length)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECName);\r\n\r\n if (ECName.validate(input)) {\r\n // It's already a valid EC name.\r\n return new ECName(input);\r\n }\r\n\r\n let output = \"\";\r\n\r\n function appendEncodedCharacter(index: number): void {\r\n const hex = input.charCodeAt(index).toString(16).toUpperCase();\r\n assert(hex.length > 0 && hex.length < 5);\r\n output += `__x${leadingDigits[hex.length]}${hex}__`;\r\n }\r\n\r\n // First character cannot be a digit.\r\n const firstCharIsDigit = isDigit(input[0]);\r\n if (firstCharIsDigit)\r\n appendEncodedCharacter(0);\r\n\r\n for (let i = firstCharIsDigit ? 1 : 0; i < input.length; i++) {\r\n const char = input[i];\r\n if (!isValidAlphaNumericCharacter(char))\r\n appendEncodedCharacter(i);\r\n else\r\n output += char;\r\n }\r\n\r\n return new ECName(output);\r\n }\r\n\r\n /** Decode this ECName, replacing encoded special characters with the characters they encode. */\r\n public decode(): string {\r\n return this.name.replace(ecNameReplacerRegex, (_match, hex) => String.fromCharCode(Number.parseInt(hex, 16)));\r\n }\r\n}\r\n"]}
|
package/lib/esm/ECObjects.d.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* @module Metadata
|
|
3
3
|
*/
|
|
4
4
|
export { PropertyType } from "./PropertyTypes";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Identifies a class as abstract or sealed
|
|
7
|
+
*
|
|
8
|
+
* @public @preview
|
|
9
|
+
*/
|
|
6
10
|
export declare enum ECClassModifier {
|
|
7
11
|
None = 0,
|
|
8
12
|
Abstract = 1,
|
|
@@ -12,7 +16,7 @@ export declare enum ECClassModifier {
|
|
|
12
16
|
* An enumeration that has all the schema item type names as values
|
|
13
17
|
*
|
|
14
18
|
* @enum {string}
|
|
15
|
-
* @
|
|
19
|
+
* @public @preview
|
|
16
20
|
*/
|
|
17
21
|
export declare enum SchemaItemType {
|
|
18
22
|
EntityClass = "EntityClass",
|
|
@@ -32,7 +36,7 @@ export declare enum SchemaItemType {
|
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Additional Schema Item Types which define classes of item types
|
|
35
|
-
* @
|
|
39
|
+
* @public @preview
|
|
36
40
|
*/
|
|
37
41
|
export declare enum AbstractSchemaItemType {
|
|
38
42
|
Class = "Class",
|
|
@@ -40,12 +44,12 @@ export declare enum AbstractSchemaItemType {
|
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Defines types of items that may be provided to identify supported items
|
|
43
|
-
* @
|
|
47
|
+
* @public @preview
|
|
44
48
|
*/
|
|
45
49
|
export type SupportedSchemaItemType = SchemaItemType | AbstractSchemaItemType;
|
|
46
50
|
/**
|
|
47
51
|
* Primitive data types for ECProperties.
|
|
48
|
-
* @
|
|
52
|
+
* @public @preview
|
|
49
53
|
*/
|
|
50
54
|
export declare enum PrimitiveType {
|
|
51
55
|
Uninitialized = 0,
|
|
@@ -62,7 +66,7 @@ export declare enum PrimitiveType {
|
|
|
62
66
|
}
|
|
63
67
|
/**
|
|
64
68
|
* Defines the valid CustomAttribute container types.
|
|
65
|
-
* @
|
|
69
|
+
* @public @preview
|
|
66
70
|
*/
|
|
67
71
|
export declare enum CustomAttributeContainerType {
|
|
68
72
|
Schema = 1,
|
|
@@ -84,7 +88,7 @@ export declare enum CustomAttributeContainerType {
|
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* Defines what sort of match should be used when locating a schema.
|
|
87
|
-
* @
|
|
91
|
+
* @public @preview
|
|
88
92
|
*/
|
|
89
93
|
export declare enum SchemaMatchType {
|
|
90
94
|
Identical = 0,
|
|
@@ -95,21 +99,29 @@ export declare enum SchemaMatchType {
|
|
|
95
99
|
}
|
|
96
100
|
/**
|
|
97
101
|
* Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.
|
|
98
|
-
* @
|
|
102
|
+
* @public @preview
|
|
99
103
|
*/
|
|
100
104
|
export declare enum RelationshipEnd {
|
|
101
105
|
Source = 0,
|
|
102
106
|
Target = 1
|
|
103
107
|
}
|
|
104
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Defines the how the lifetime of the source and target are related.
|
|
110
|
+
*
|
|
111
|
+
* @public @preview */
|
|
105
112
|
export declare enum StrengthType {
|
|
106
113
|
Referencing = 0,
|
|
107
114
|
Holding = 1,
|
|
108
115
|
Embedding = 2
|
|
109
116
|
}
|
|
110
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Defines the which side of the relationship is the starting point of the relationship. This impacts how relationship strength is applied.
|
|
119
|
+
*
|
|
120
|
+
* @public @preview */
|
|
111
121
|
export declare enum StrengthDirection {
|
|
122
|
+
/** The source is the starting point of the relationship. */
|
|
112
123
|
Forward = 1,
|
|
124
|
+
/** The target is the starting point of the relationship. */
|
|
113
125
|
Backward = 2
|
|
114
126
|
}
|
|
115
127
|
/**
|
|
@@ -168,7 +180,7 @@ export declare function parseRelationshipEnd(end: string): RelationshipEnd | und
|
|
|
168
180
|
export declare function relationshipEndToString(end: RelationshipEnd): string;
|
|
169
181
|
/**
|
|
170
182
|
* Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.
|
|
171
|
-
* @throws
|
|
183
|
+
* @throws ECSchemaStatus.InvalidStrength if the provided string that is not valid
|
|
172
184
|
* @param strength
|
|
173
185
|
* @beta
|
|
174
186
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECObjects.d.ts","sourceRoot":"","sources":["../../src/ECObjects.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAO/C
|
|
1
|
+
{"version":3,"file":"ECObjects.d.ts","sourceRoot":"","sources":["../../src/ECObjects.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAO/C;;;;GAIG;AACH,oBAAY,eAAe;IAEzB,IAAI,IAAA;IAEJ,QAAQ,IAAA;IAER,MAAM,IAAA;CACP;AAED;;;;;GAKG;AACH,oBAAY,cAAc;IACxB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;IACf,WAAW,gBAAgB;IAC3B,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IACvC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,IAAI,SAAS;IACb,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,oBAAY,sBAAsB;IAEhC,KAAK,UAAU;IAEf,UAAU,eAAe;CAC1B;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,sBAAsB,CAAC;AAE9E;;;GAGG;AACH,oBAAY,aAAa;IACvB,aAAa,IAAO;IACpB,MAAM,MAAQ;IACd,OAAO,MAAQ;IACf,QAAQ,MAAQ;IAChB,MAAM,OAAQ;IACd,OAAO,OAAQ;IACf,IAAI,OAAQ;IACZ,OAAO,OAAQ;IACf,OAAO,OAAQ;IACf,MAAM,OAAQ;IACd,SAAS,OAAQ;CAClB;AAED;;;GAGG;AACH,oBAAY,4BAA4B;IACtC,MAAM,IAAc;IACpB,WAAW,IAAc;IACzB,oBAAoB,IAAc;IAClC,WAAW,IAAc;IACzB,iBA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AG,MAAM,CAejE;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAiExG;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,4BAA4B,GAAG,MAAM,CAuDhF;AAED,YAAY;AACZ,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAM7E;AAED,YAAY;AACZ,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAOpE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAOxE;AAED,YAAY;AACZ,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAQ/D;AAED,YAAY;AACZ,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAMvF;AAED,YAAY;AACZ,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAO9E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,uBAAuB,GAAG,OAAO,CAiB5G"}
|
package/lib/esm/ECObjects.js
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
8
|
import { ECStringConstants } from "./Constants";
|
|
9
|
-
import {
|
|
9
|
+
import { ECSchemaError, ECSchemaStatus } from "./Exception";
|
|
10
10
|
export { PropertyType } from "./PropertyTypes";
|
|
11
11
|
// NEEDSWORK: This shim is currently required to use async iterators. See https://github.com/Microsoft/TypeScript/issues/14151
|
|
12
12
|
if (!Symbol.asyncIterator) {
|
|
13
13
|
Symbol.asyncIterator = Symbol.for("Symbol.asyncIterator");
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Identifies a class as abstract or sealed
|
|
17
|
+
*
|
|
18
|
+
* @public @preview
|
|
19
|
+
*/
|
|
16
20
|
export var ECClassModifier;
|
|
17
21
|
(function (ECClassModifier) {
|
|
22
|
+
/* normal, instantiable class, can be subclassed */
|
|
18
23
|
ECClassModifier[ECClassModifier["None"] = 0] = "None";
|
|
24
|
+
/* abstract class, cannot be instantiated, can be subclassed */
|
|
19
25
|
ECClassModifier[ECClassModifier["Abstract"] = 1] = "Abstract";
|
|
26
|
+
/* sealed class, instantiable class, cannot be subclassed */
|
|
20
27
|
ECClassModifier[ECClassModifier["Sealed"] = 2] = "Sealed";
|
|
21
28
|
})(ECClassModifier || (ECClassModifier = {}));
|
|
22
29
|
/**
|
|
23
30
|
* An enumeration that has all the schema item type names as values
|
|
24
31
|
*
|
|
25
32
|
* @enum {string}
|
|
26
|
-
* @
|
|
33
|
+
* @public @preview
|
|
27
34
|
*/
|
|
28
35
|
export var SchemaItemType;
|
|
29
36
|
(function (SchemaItemType) {
|
|
@@ -44,16 +51,18 @@ export var SchemaItemType;
|
|
|
44
51
|
})(SchemaItemType || (SchemaItemType = {}));
|
|
45
52
|
/**
|
|
46
53
|
* Additional Schema Item Types which define classes of item types
|
|
47
|
-
* @
|
|
54
|
+
* @public @preview
|
|
48
55
|
*/
|
|
49
56
|
export var AbstractSchemaItemType;
|
|
50
57
|
(function (AbstractSchemaItemType) {
|
|
58
|
+
/* Item is EntityClass, Mixin, StructClass, CustomAttributeClass, or RelationshipClass */
|
|
51
59
|
AbstractSchemaItemType["Class"] = "Class";
|
|
60
|
+
/* Any item type including the Class types */
|
|
52
61
|
AbstractSchemaItemType["SchemaItem"] = "SchemaItem";
|
|
53
62
|
})(AbstractSchemaItemType || (AbstractSchemaItemType = {}));
|
|
54
63
|
/**
|
|
55
64
|
* Primitive data types for ECProperties.
|
|
56
|
-
* @
|
|
65
|
+
* @public @preview
|
|
57
66
|
*/
|
|
58
67
|
export var PrimitiveType;
|
|
59
68
|
(function (PrimitiveType) {
|
|
@@ -71,7 +80,7 @@ export var PrimitiveType;
|
|
|
71
80
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
72
81
|
/**
|
|
73
82
|
* Defines the valid CustomAttribute container types.
|
|
74
|
-
* @
|
|
83
|
+
* @public @preview
|
|
75
84
|
*/
|
|
76
85
|
export var CustomAttributeContainerType;
|
|
77
86
|
(function (CustomAttributeContainerType) {
|
|
@@ -94,14 +103,14 @@ export var CustomAttributeContainerType;
|
|
|
94
103
|
})(CustomAttributeContainerType || (CustomAttributeContainerType = {}));
|
|
95
104
|
/**
|
|
96
105
|
* Defines what sort of match should be used when locating a schema.
|
|
97
|
-
* @
|
|
106
|
+
* @public @preview
|
|
98
107
|
*/
|
|
99
108
|
export var SchemaMatchType;
|
|
100
109
|
(function (SchemaMatchType) {
|
|
101
110
|
/*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
* Find exact VersionRead, VersionWrite, VersionMinor match as well as Data. NOTE data is not yet matched
|
|
112
|
+
* @deprecated in 4.10 Use Exact instead.
|
|
113
|
+
*/
|
|
105
114
|
SchemaMatchType[SchemaMatchType["Identical"] = 0] = "Identical";
|
|
106
115
|
/* Find exact VersionRead, VersionWrite, VersionMinor match. */
|
|
107
116
|
SchemaMatchType[SchemaMatchType["Exact"] = 1] = "Exact";
|
|
@@ -114,24 +123,32 @@ export var SchemaMatchType;
|
|
|
114
123
|
})(SchemaMatchType || (SchemaMatchType = {}));
|
|
115
124
|
/**
|
|
116
125
|
* Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.
|
|
117
|
-
* @
|
|
126
|
+
* @public @preview
|
|
118
127
|
*/
|
|
119
128
|
export var RelationshipEnd;
|
|
120
129
|
(function (RelationshipEnd) {
|
|
121
130
|
RelationshipEnd[RelationshipEnd["Source"] = 0] = "Source";
|
|
122
131
|
RelationshipEnd[RelationshipEnd["Target"] = 1] = "Target";
|
|
123
132
|
})(RelationshipEnd || (RelationshipEnd = {}));
|
|
124
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Defines the how the lifetime of the source and target are related.
|
|
135
|
+
*
|
|
136
|
+
* @public @preview */
|
|
125
137
|
export var StrengthType;
|
|
126
138
|
(function (StrengthType) {
|
|
127
139
|
StrengthType[StrengthType["Referencing"] = 0] = "Referencing";
|
|
128
140
|
StrengthType[StrengthType["Holding"] = 1] = "Holding";
|
|
129
141
|
StrengthType[StrengthType["Embedding"] = 2] = "Embedding";
|
|
130
142
|
})(StrengthType || (StrengthType = {}));
|
|
131
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Defines the which side of the relationship is the starting point of the relationship. This impacts how relationship strength is applied.
|
|
145
|
+
*
|
|
146
|
+
* @public @preview */
|
|
132
147
|
export var StrengthDirection;
|
|
133
148
|
(function (StrengthDirection) {
|
|
149
|
+
/** The source is the starting point of the relationship. */
|
|
134
150
|
StrengthDirection[StrengthDirection["Forward"] = 1] = "Forward";
|
|
151
|
+
/** The target is the starting point of the relationship. */
|
|
135
152
|
StrengthDirection[StrengthDirection["Backward"] = 2] = "Backward";
|
|
136
153
|
})(StrengthDirection || (StrengthDirection = {}));
|
|
137
154
|
// Helper methods for going to/from string for the above Enumerations.
|
|
@@ -158,7 +175,8 @@ export function classModifierToString(modifier) {
|
|
|
158
175
|
case ECClassModifier.Abstract: return "Abstract";
|
|
159
176
|
case ECClassModifier.None: return "None";
|
|
160
177
|
case ECClassModifier.Sealed: return "Sealed";
|
|
161
|
-
default:
|
|
178
|
+
default:
|
|
179
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidModifier, "An invalid ECClassModifier has been provided.");
|
|
162
180
|
}
|
|
163
181
|
}
|
|
164
182
|
/**
|
|
@@ -213,7 +231,8 @@ export function schemaItemTypeToXmlString(value) {
|
|
|
213
231
|
case SchemaItemType.Phenomenon: return "Phenomenon";
|
|
214
232
|
case SchemaItemType.UnitSystem: return "UnitSystem";
|
|
215
233
|
case SchemaItemType.Format: return "Format";
|
|
216
|
-
default:
|
|
234
|
+
default:
|
|
235
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, "An invalid SchemaItemType has been provided.");
|
|
217
236
|
}
|
|
218
237
|
}
|
|
219
238
|
/**
|
|
@@ -251,7 +270,8 @@ export function primitiveTypeToString(type) {
|
|
|
251
270
|
case PrimitiveType.Point2d: return "point2d";
|
|
252
271
|
case PrimitiveType.Point3d: return "point3d";
|
|
253
272
|
case PrimitiveType.String: return "string";
|
|
254
|
-
default:
|
|
273
|
+
default:
|
|
274
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidPrimitiveType, "An invalid PrimitiveType has been provided.");
|
|
255
275
|
}
|
|
256
276
|
}
|
|
257
277
|
/**
|
|
@@ -317,7 +337,7 @@ export function parseCustomAttributeContainerType(type) {
|
|
|
317
337
|
containerType = containerType | CustomAttributeContainerType.Any;
|
|
318
338
|
break;
|
|
319
339
|
default:
|
|
320
|
-
throw new
|
|
340
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${typeToken} is not a valid CustomAttributeContainerType value.`);
|
|
321
341
|
}
|
|
322
342
|
});
|
|
323
343
|
return containerType;
|
|
@@ -330,7 +350,7 @@ export function parseCustomAttributeContainerType(type) {
|
|
|
330
350
|
*/
|
|
331
351
|
export function containerTypeToString(type) {
|
|
332
352
|
const testContainerTypeValue = (compareType, otherType) => {
|
|
333
|
-
return
|
|
353
|
+
return compareType === (compareType & otherType);
|
|
334
354
|
};
|
|
335
355
|
if (testContainerTypeValue(CustomAttributeContainerType.Any, type))
|
|
336
356
|
return ECStringConstants.CONTAINERTYPE_ANY;
|
|
@@ -392,12 +412,13 @@ export function relationshipEndToString(end) {
|
|
|
392
412
|
switch (end) {
|
|
393
413
|
case RelationshipEnd.Source: return ECStringConstants.RELATIONSHIP_END_SOURCE;
|
|
394
414
|
case RelationshipEnd.Target: return ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
395
|
-
default:
|
|
415
|
+
default:
|
|
416
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidRelationshipEnd, `An invalid RelationshipEnd has been provided.`);
|
|
396
417
|
}
|
|
397
418
|
}
|
|
398
419
|
/**
|
|
399
420
|
* Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.
|
|
400
|
-
* @throws
|
|
421
|
+
* @throws ECSchemaStatus.InvalidStrength if the provided string that is not valid
|
|
401
422
|
* @param strength
|
|
402
423
|
* @beta
|
|
403
424
|
*/
|
|
@@ -415,7 +436,8 @@ export function strengthToString(strength) {
|
|
|
415
436
|
case StrengthType.Embedding: return "Embedding";
|
|
416
437
|
case StrengthType.Holding: return "Holding";
|
|
417
438
|
case StrengthType.Referencing: return "Referencing";
|
|
418
|
-
default:
|
|
439
|
+
default:
|
|
440
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidStrength, `An invalid Strength has been provided.`);
|
|
419
441
|
}
|
|
420
442
|
}
|
|
421
443
|
/** @beta */
|
|
@@ -431,7 +453,8 @@ export function strengthDirectionToString(direction) {
|
|
|
431
453
|
switch (direction) {
|
|
432
454
|
case StrengthDirection.Forward: return "Forward";
|
|
433
455
|
case StrengthDirection.Backward: return "Backward";
|
|
434
|
-
default:
|
|
456
|
+
default:
|
|
457
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `An invalid StrengthDirection has been provided.`);
|
|
435
458
|
}
|
|
436
459
|
}
|
|
437
460
|
/** Compares a SchemaItemType against supported type.
|