@itwin/ecschema-metadata 5.0.0-dev.11 → 5.0.0-dev.110
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/Constants.d.ts +8 -0
- package/lib/cjs/Constants.d.ts.map +1 -1
- package/lib/cjs/Constants.js +30 -21
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +85 -36
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +79 -29
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.d.ts +9 -8
- package/lib/cjs/DelayedPromise.d.ts.map +1 -1
- package/lib/cjs/DelayedPromise.js +8 -6
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js +1 -0
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts +3 -3
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +35 -26
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +153 -150
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +47 -33
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js +3 -3
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +60 -52
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +8 -17
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.d.ts +2 -2
- package/lib/cjs/ECName.js +5 -4
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +41 -9
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +78 -24
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.d.ts +4 -4
- package/lib/cjs/Exception.d.ts.map +1 -1
- package/lib/cjs/Exception.js +61 -60
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +35 -32
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +179 -32
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +290 -88
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +26 -10
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +38 -10
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +21 -7
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +28 -8
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +40 -11
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +72 -34
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +30 -10
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +41 -13
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +65 -17
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +107 -22
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +19 -10
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +32 -15
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +38 -18
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +90 -40
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +31 -4
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +42 -8
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +36 -19
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +24 -3
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +32 -3
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +47 -25
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +128 -49
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +20 -4
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +31 -4
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +63 -27
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +100 -43
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +167 -41
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +211 -111
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +19 -19
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +23 -21
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +24 -21
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +40 -24
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +17 -4
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +24 -4
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts +11 -11
- package/lib/cjs/PropertyTypes.d.ts.map +1 -1
- package/lib/cjs/PropertyTypes.js +28 -20
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
- package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/SchemaFormatsProvider.js +146 -0
- package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
- package/lib/cjs/SchemaJsonLocater.d.ts +8 -8
- package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js +7 -7
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +13 -7
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +22 -12
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +5 -5
- package/lib/cjs/SchemaLoader.d.ts.map +1 -1
- package/lib/cjs/SchemaLoader.js +5 -4
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/cjs/SchemaPartVisitorDelegate.js +2 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js +69 -65
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js +9 -7
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js +2 -0
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js +11 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js +8 -9
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js +6 -4
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +1 -0
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +1 -0
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +5 -6
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.d.ts +8 -0
- package/lib/esm/Constants.d.ts.map +1 -1
- package/lib/esm/Constants.js +29 -20
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Context.d.ts +85 -36
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +78 -28
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.d.ts +9 -8
- package/lib/esm/DelayedPromise.d.ts.map +1 -1
- package/lib/esm/DelayedPromise.js +8 -6
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js +1 -0
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts +3 -3
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +36 -27
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +154 -151
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +47 -33
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js +3 -3
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +61 -53
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +9 -18
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.d.ts +2 -2
- package/lib/esm/ECName.js +6 -5
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +41 -9
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +77 -24
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.d.ts +4 -4
- package/lib/esm/Exception.d.ts.map +1 -1
- package/lib/esm/Exception.js +59 -58
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +35 -32
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +179 -32
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +292 -90
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +26 -10
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +39 -11
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +21 -7
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +29 -9
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +40 -11
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +73 -35
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +30 -10
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +42 -14
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +65 -17
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +108 -23
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +19 -10
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +33 -16
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +38 -18
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +91 -41
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +31 -4
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +44 -10
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +37 -20
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +24 -3
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +33 -4
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +47 -25
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +130 -51
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +20 -4
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +31 -4
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +63 -27
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +102 -45
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +167 -41
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +212 -112
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +19 -19
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +25 -23
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +24 -21
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +41 -25
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +17 -4
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +24 -4
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.d.ts +11 -11
- package/lib/esm/PropertyTypes.d.ts.map +1 -1
- package/lib/esm/PropertyTypes.js +29 -21
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
- package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/esm/SchemaFormatsProvider.js +142 -0
- package/lib/esm/SchemaFormatsProvider.js.map +1 -0
- package/lib/esm/SchemaJsonLocater.d.ts +8 -8
- package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/esm/SchemaJsonLocater.js +7 -7
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +13 -7
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +23 -13
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +5 -5
- package/lib/esm/SchemaLoader.d.ts.map +1 -1
- package/lib/esm/SchemaLoader.js +6 -5
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/esm/SchemaPartVisitorDelegate.js +2 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js +69 -65
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts +1 -1
- package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js +9 -7
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js +2 -0
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.d.ts +2 -0
- package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js +11 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js +8 -9
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts +1 -1
- package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js +6 -4
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +1 -0
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +1 -0
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +6 -7
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +16 -14
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
8
|
import { containerTypeToString, parseCustomAttributeContainerType, SchemaItemType, } from "../ECObjects";
|
|
9
|
-
import {
|
|
9
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
10
10
|
import { ECClass } from "./Class";
|
|
11
11
|
/**
|
|
12
12
|
* A Typescript class representation of an ECCustomAttributeClass.
|
|
13
|
-
* @
|
|
13
|
+
* @public @preview
|
|
14
14
|
*/
|
|
15
15
|
export class CustomAttributeClass extends ECClass {
|
|
16
|
+
schemaItemType = CustomAttributeClass.schemaItemType;
|
|
17
|
+
/** @internal */
|
|
18
|
+
static get schemaItemType() { return SchemaItemType.CustomAttributeClass; }
|
|
19
|
+
_appliesTo;
|
|
16
20
|
/**
|
|
17
21
|
* @deprecated in 4.8 use [[appliesTo]]
|
|
18
22
|
* */
|
|
@@ -21,13 +25,9 @@ export class CustomAttributeClass extends ECClass {
|
|
|
21
25
|
}
|
|
22
26
|
get appliesTo() {
|
|
23
27
|
if (undefined === this._appliesTo)
|
|
24
|
-
throw new
|
|
28
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);
|
|
25
29
|
return this._appliesTo;
|
|
26
30
|
}
|
|
27
|
-
constructor(schema, name, modifier) {
|
|
28
|
-
super(schema, name, modifier);
|
|
29
|
-
this.schemaItemType = SchemaItemType.CustomAttributeClass;
|
|
30
|
-
}
|
|
31
31
|
/**
|
|
32
32
|
* Save this CustomAttributeClasses properties to an object for serializing to JSON.
|
|
33
33
|
* @param standalone Serialization includes only this object (as opposed to the full schema).
|
|
@@ -48,18 +48,38 @@ export class CustomAttributeClass extends ECClass {
|
|
|
48
48
|
super.fromJSONSync(customAttributeProps);
|
|
49
49
|
const appliesTo = parseCustomAttributeContainerType(customAttributeProps.appliesTo);
|
|
50
50
|
if (undefined === appliesTo)
|
|
51
|
-
throw new
|
|
51
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);
|
|
52
52
|
this._appliesTo = appliesTo;
|
|
53
53
|
}
|
|
54
54
|
async fromJSON(customAttributeProps) {
|
|
55
55
|
this.fromJSONSync(customAttributeProps);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* @
|
|
58
|
+
* @internal
|
|
59
59
|
*/
|
|
60
60
|
setAppliesTo(containerType) {
|
|
61
61
|
this._appliesTo = containerType;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Type guard to check if the SchemaItem is of type CustomAttributeClass.
|
|
65
|
+
* @param item The SchemaItem to check.
|
|
66
|
+
* @returns True if the item is a CustomAttributeClass, false otherwise.
|
|
67
|
+
*/
|
|
68
|
+
static isCustomAttributeClass(item) {
|
|
69
|
+
if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)
|
|
70
|
+
return true;
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Type assertion to check if the SchemaItem is of type CustomAttributeClass.
|
|
75
|
+
* @param item The SchemaItem to check.
|
|
76
|
+
* @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
static assertIsCustomAttributeClass(item) {
|
|
80
|
+
if (!this.isCustomAttributeClass(item))
|
|
81
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);
|
|
82
|
+
}
|
|
63
83
|
}
|
|
64
84
|
/**
|
|
65
85
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,qBAAqB,EAAgC,iCAAiC,EAAE,cAAc,GACvG,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,OAAO,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aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,GAAG,SAAS,+CAA+C,CAAC,CAAC;QAC5H,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,oBAA+C;QAC5E,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,aAA2C;QAChE,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,sBAAsB,CAAC,IAAiB;QACpD,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,oBAAoB;YACrE,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,4BAA4B,CAAC,IAAiB;QAC1D,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;YACpC,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,oBAAoB,0BAA0B,CAAC,CAAC;IAC9I,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,cAAe,SAAQ,oBAAoB;CAGhE","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 { CustomAttributeClassProps } from \"../Deserialization/JsonProps\";\r\nimport {\r\n containerTypeToString, CustomAttributeContainerType, parseCustomAttributeContainerType, SchemaItemType,\r\n} from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { ECClass } from \"./Class\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/**\r\n * A Typescript class representation of an ECCustomAttributeClass.\r\n * @public @preview\r\n */\r\nexport class CustomAttributeClass extends ECClass {\r\n public override readonly schemaItemType = CustomAttributeClass.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.CustomAttributeClass; }\r\n private _appliesTo?: CustomAttributeContainerType;\r\n\r\n /**\r\n * @deprecated in 4.8 use [[appliesTo]]\r\n * */\r\n public get containerType(): CustomAttributeContainerType {\r\n return this.appliesTo;\r\n }\r\n\r\n public get appliesTo(): CustomAttributeContainerType {\r\n if (undefined === this._appliesTo)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);\r\n return this._appliesTo;\r\n }\r\n\r\n /**\r\n * Save this CustomAttributeClasses properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): CustomAttributeClassProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.appliesTo = containerTypeToString(this.appliesTo);\r\n return schemaJson as CustomAttributeClassProps;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n itemElement.setAttribute(\"appliesTo\", containerTypeToString(this.appliesTo));\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(customAttributeProps: CustomAttributeClassProps) {\r\n super.fromJSONSync(customAttributeProps);\r\n const appliesTo = parseCustomAttributeContainerType(customAttributeProps.appliesTo);\r\n if (undefined === appliesTo)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);\r\n this._appliesTo = appliesTo;\r\n }\r\n\r\n public override async fromJSON(customAttributeProps: CustomAttributeClassProps) {\r\n this.fromJSONSync(customAttributeProps);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n protected setAppliesTo(containerType: CustomAttributeContainerType) {\r\n this._appliesTo = containerType;\r\n }\r\n\r\n /**\r\n * Type guard to check if the SchemaItem is of type CustomAttributeClass.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is a CustomAttributeClass, false otherwise.\r\n */\r\n public static isCustomAttributeClass(item?: SchemaItem): item is CustomAttributeClass {\r\n if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Type assertion to check if the SchemaItem is of type CustomAttributeClass.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.\r\n * @internal\r\n */\r\n public static assertIsCustomAttributeClass(item?: SchemaItem): asserts item is CustomAttributeClass {\r\n if (!this.isCustomAttributeClass(item))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for Schema editing.\r\n */\r\nexport abstract class MutableCAClass extends CustomAttributeClass {\r\n public abstract override setAppliesTo(containerType: CustomAttributeContainerType): void;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
|
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
* @module Metadata
|
|
3
3
|
*/
|
|
4
4
|
import { EntityClassProps } from "../Deserialization/JsonProps";
|
|
5
|
-
import {
|
|
6
|
-
import { LazyLoadedMixin } from "../Interfaces";
|
|
5
|
+
import { SchemaItemType, StrengthDirection } from "../ECObjects";
|
|
6
|
+
import { HasMixins, LazyLoadedMixin } from "../Interfaces";
|
|
7
7
|
import { ECClass } from "./Class";
|
|
8
8
|
import { Mixin } from "./Mixin";
|
|
9
9
|
import { AnyProperty, NavigationProperty, Property } from "./Property";
|
|
10
10
|
import { RelationshipClass } from "./RelationshipClass";
|
|
11
|
-
import {
|
|
11
|
+
import { SchemaItem } from "./SchemaItem";
|
|
12
12
|
/**
|
|
13
13
|
* A Typescript class representation of an ECEntityClass.
|
|
14
|
-
* @
|
|
14
|
+
* @public @preview
|
|
15
15
|
*/
|
|
16
|
-
export declare class EntityClass extends ECClass {
|
|
17
|
-
readonly schemaItemType: SchemaItemType
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
export declare class EntityClass extends ECClass implements HasMixins {
|
|
17
|
+
readonly schemaItemType: SchemaItemType;
|
|
18
|
+
/** @internal */
|
|
19
|
+
static get schemaItemType(): SchemaItemType;
|
|
20
|
+
private _mixins?;
|
|
21
|
+
get mixins(): ReadonlyArray<LazyLoadedMixin>;
|
|
21
22
|
getMixinsSync(): Iterable<Mixin>;
|
|
22
23
|
/**
|
|
23
24
|
*
|
|
24
25
|
* @param mixin
|
|
26
|
+
* @internal
|
|
25
27
|
*/
|
|
26
28
|
protected addMixin(mixin: Mixin): void;
|
|
27
29
|
/**
|
|
@@ -34,13 +36,26 @@ export declare class EntityClass extends ECClass {
|
|
|
34
36
|
* @param name The name of the property to find.
|
|
35
37
|
*/
|
|
36
38
|
getInheritedPropertySync(name: string): Property | undefined;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param result
|
|
42
|
+
* @param existingValues
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
protected buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param result
|
|
49
|
+
* @param existingValues
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
protected buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>): void;
|
|
39
53
|
/**
|
|
40
54
|
*
|
|
41
55
|
* @param name
|
|
42
56
|
* @param relationship
|
|
43
57
|
* @param direction
|
|
58
|
+
* @internal
|
|
44
59
|
*/
|
|
45
60
|
protected createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
|
|
46
61
|
/**
|
|
@@ -48,6 +63,7 @@ export declare class EntityClass extends ECClass {
|
|
|
48
63
|
* @param name
|
|
49
64
|
* @param relationship
|
|
50
65
|
* @param direction
|
|
66
|
+
* @internal
|
|
51
67
|
*/
|
|
52
68
|
protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
|
|
53
69
|
/**
|
|
@@ -60,6 +76,19 @@ export declare class EntityClass extends ECClass {
|
|
|
60
76
|
toXml(schemaXml: Document): Promise<Element>;
|
|
61
77
|
fromJSON(entityClassProps: EntityClassProps): Promise<void>;
|
|
62
78
|
fromJSONSync(entityClassProps: EntityClassProps): void;
|
|
79
|
+
/**
|
|
80
|
+
* Type guard to check if the SchemaItem is of type EntityClass.
|
|
81
|
+
* @param item The SchemaItem to check.
|
|
82
|
+
* @returns True if the item is an EntityClass, false otherwise.
|
|
83
|
+
*/
|
|
84
|
+
static isEntityClass(item?: SchemaItem): item is EntityClass;
|
|
85
|
+
/**
|
|
86
|
+
* Type assertion to check if the SchemaItem is of type EntityClass.
|
|
87
|
+
* @param item The SchemaItem to check.
|
|
88
|
+
* @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass;
|
|
63
92
|
}
|
|
64
93
|
/**
|
|
65
94
|
* Hackish approach that works like a "friend class" so we can access protected members without making them public.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,
|
|
1
|
+
{"version":3,"file":"EntityClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAIA;;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CACrE;AAED,gBAAgB;AAChB,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB3L;AAED,gBAAgB;AAChB,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB,CAsBhL"}
|
|
@@ -8,18 +8,20 @@
|
|
|
8
8
|
import { DelayedPromiseWithProps } from "../DelayedPromise";
|
|
9
9
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
10
10
|
import { parseStrengthDirection, SchemaItemType } from "../ECObjects";
|
|
11
|
-
import {
|
|
11
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
12
12
|
import { ECClass } from "./Class";
|
|
13
|
+
import { Mixin } from "./Mixin";
|
|
13
14
|
import { NavigationProperty } from "./Property";
|
|
15
|
+
import { RelationshipClass } from "./RelationshipClass";
|
|
14
16
|
/**
|
|
15
17
|
* A Typescript class representation of an ECEntityClass.
|
|
16
|
-
* @
|
|
18
|
+
* @public @preview
|
|
17
19
|
*/
|
|
18
20
|
export class EntityClass extends ECClass {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
schemaItemType = EntityClass.schemaItemType;
|
|
22
|
+
/** @internal */
|
|
23
|
+
static get schemaItemType() { return SchemaItemType.EntityClass; }
|
|
24
|
+
_mixins;
|
|
23
25
|
get mixins() {
|
|
24
26
|
if (!this._mixins)
|
|
25
27
|
return [];
|
|
@@ -27,9 +29,9 @@ export class EntityClass extends ECClass {
|
|
|
27
29
|
}
|
|
28
30
|
*getMixinsSync() {
|
|
29
31
|
if (!this._mixins)
|
|
30
|
-
return
|
|
32
|
+
return;
|
|
31
33
|
for (const mixin of this._mixins) {
|
|
32
|
-
const mObj = this.schema.lookupItemSync(mixin);
|
|
34
|
+
const mObj = this.schema.lookupItemSync(mixin, Mixin);
|
|
33
35
|
if (mObj) {
|
|
34
36
|
yield mObj;
|
|
35
37
|
}
|
|
@@ -38,6 +40,7 @@ export class EntityClass extends ECClass {
|
|
|
38
40
|
/**
|
|
39
41
|
*
|
|
40
42
|
* @param mixin
|
|
43
|
+
* @internal
|
|
41
44
|
*/
|
|
42
45
|
addMixin(mixin) {
|
|
43
46
|
if (!this._mixins)
|
|
@@ -73,7 +76,7 @@ export class EntityClass extends ECClass {
|
|
|
73
76
|
}
|
|
74
77
|
for (const mixin of this._mixins) {
|
|
75
78
|
const mObj = this.schema.lookupItemSync(mixin);
|
|
76
|
-
if (mObj) {
|
|
79
|
+
if (mObj && ECClass.isECClass(mObj)) {
|
|
77
80
|
const result = mObj.getPropertySync(name, true);
|
|
78
81
|
if (result) {
|
|
79
82
|
return result;
|
|
@@ -82,40 +85,53 @@ export class EntityClass extends ECClass {
|
|
|
82
85
|
}
|
|
83
86
|
return undefined;
|
|
84
87
|
}
|
|
85
|
-
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @param result
|
|
91
|
+
* @param existingValues
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
async buildPropertyCache(result, existingValues) {
|
|
86
95
|
if (!existingValues) {
|
|
87
96
|
existingValues = new Map();
|
|
88
97
|
}
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
const baseClass = await this.baseClass;
|
|
99
|
+
if (baseClass) {
|
|
100
|
+
ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);
|
|
91
101
|
}
|
|
92
102
|
for (const mixin of this.mixins) {
|
|
93
|
-
|
|
103
|
+
const resolvedMixin = await mixin;
|
|
104
|
+
ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);
|
|
94
105
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
ECClass.mergeProperties(result, existingValues, [...this.properties], true);
|
|
106
|
+
const localProps = await this.getProperties();
|
|
107
|
+
ECClass.mergeProperties(result, existingValues, localProps, true);
|
|
98
108
|
}
|
|
99
|
-
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @param result
|
|
112
|
+
* @param existingValues
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
buildPropertyCacheSync(result, existingValues) {
|
|
100
116
|
if (!existingValues) {
|
|
101
117
|
existingValues = new Map();
|
|
102
118
|
}
|
|
103
119
|
const baseClass = this.getBaseClassSync();
|
|
104
120
|
if (baseClass) {
|
|
105
|
-
ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(
|
|
121
|
+
ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);
|
|
106
122
|
}
|
|
107
123
|
for (const mixin of this.getMixinsSync()) {
|
|
108
|
-
ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(
|
|
124
|
+
ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(), false);
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
ECClass.mergeProperties(result, existingValues, [...this.properties], true);
|
|
126
|
+
const localProps = this.getPropertiesSync(true);
|
|
127
|
+
ECClass.mergeProperties(result, existingValues, localProps, true);
|
|
113
128
|
}
|
|
114
129
|
/**
|
|
115
130
|
*
|
|
116
131
|
* @param name
|
|
117
132
|
* @param relationship
|
|
118
133
|
* @param direction
|
|
134
|
+
* @internal
|
|
119
135
|
*/
|
|
120
136
|
async createNavigationProperty(name, relationship, direction) {
|
|
121
137
|
return this.addProperty(await createNavigationProperty(this, name, relationship, direction));
|
|
@@ -125,6 +141,7 @@ export class EntityClass extends ECClass {
|
|
|
125
141
|
* @param name
|
|
126
142
|
* @param relationship
|
|
127
143
|
* @param direction
|
|
144
|
+
* @internal
|
|
128
145
|
*/
|
|
129
146
|
createNavigationPropertySync(name, relationship, direction) {
|
|
130
147
|
return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));
|
|
@@ -143,7 +160,8 @@ export class EntityClass extends ECClass {
|
|
|
143
160
|
/** @internal */
|
|
144
161
|
async toXml(schemaXml) {
|
|
145
162
|
const itemElement = await super.toXml(schemaXml);
|
|
146
|
-
for (const
|
|
163
|
+
for (const lazyMixin of this.mixins) {
|
|
164
|
+
const mixin = await lazyMixin;
|
|
147
165
|
const mixinElement = schemaXml.createElement("BaseClass");
|
|
148
166
|
const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);
|
|
149
167
|
mixinElement.textContent = mixinName;
|
|
@@ -162,16 +180,36 @@ export class EntityClass extends ECClass {
|
|
|
162
180
|
for (const name of entityClassProps.mixins) {
|
|
163
181
|
const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);
|
|
164
182
|
if (!mixinSchemaItemKey)
|
|
165
|
-
throw new
|
|
183
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
|
|
166
184
|
this._mixins.push(new DelayedPromiseWithProps(mixinSchemaItemKey, async () => {
|
|
167
|
-
const mixin = await this.schema.lookupItem(mixinSchemaItemKey);
|
|
185
|
+
const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);
|
|
168
186
|
if (undefined === mixin)
|
|
169
|
-
throw new
|
|
187
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
|
|
170
188
|
return mixin;
|
|
171
189
|
}));
|
|
172
190
|
}
|
|
173
191
|
}
|
|
174
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Type guard to check if the SchemaItem is of type EntityClass.
|
|
195
|
+
* @param item The SchemaItem to check.
|
|
196
|
+
* @returns True if the item is an EntityClass, false otherwise.
|
|
197
|
+
*/
|
|
198
|
+
static isEntityClass(item) {
|
|
199
|
+
if (item && item.schemaItemType === SchemaItemType.EntityClass)
|
|
200
|
+
return true;
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Type assertion to check if the SchemaItem is of type EntityClass.
|
|
205
|
+
* @param item The SchemaItem to check.
|
|
206
|
+
* @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
static assertIsEntityClass(item) {
|
|
210
|
+
if (!this.isEntityClass(item))
|
|
211
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);
|
|
212
|
+
}
|
|
175
213
|
}
|
|
176
214
|
/**
|
|
177
215
|
* Hackish approach that works like a "friend class" so we can access protected members without making them public.
|
|
@@ -181,20 +219,20 @@ export class MutableEntityClass extends EntityClass {
|
|
|
181
219
|
}
|
|
182
220
|
/** @internal */
|
|
183
221
|
export async function createNavigationProperty(ecClass, name, relationship, direction) {
|
|
184
|
-
if (await ecClass.getProperty(name))
|
|
185
|
-
throw new
|
|
222
|
+
if (await ecClass.getProperty(name, true))
|
|
223
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
|
|
186
224
|
let resolvedRelationship;
|
|
187
225
|
if (typeof (relationship) === "string") {
|
|
188
|
-
resolvedRelationship = await ecClass.schema.lookupItem(relationship);
|
|
226
|
+
resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);
|
|
189
227
|
}
|
|
190
228
|
else
|
|
191
229
|
resolvedRelationship = relationship;
|
|
192
230
|
if (!resolvedRelationship)
|
|
193
|
-
throw new
|
|
231
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string
|
|
194
232
|
if (typeof (direction) === "string") {
|
|
195
233
|
const tmpDirection = parseStrengthDirection(direction);
|
|
196
234
|
if (undefined === tmpDirection)
|
|
197
|
-
throw new
|
|
235
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
|
|
198
236
|
direction = tmpDirection;
|
|
199
237
|
}
|
|
200
238
|
const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
|
|
@@ -203,19 +241,19 @@ export async function createNavigationProperty(ecClass, name, relationship, dire
|
|
|
203
241
|
/** @internal */
|
|
204
242
|
export function createNavigationPropertySync(ecClass, name, relationship, direction) {
|
|
205
243
|
if (ecClass.getPropertySync(name))
|
|
206
|
-
throw new
|
|
244
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
|
|
207
245
|
let resolvedRelationship;
|
|
208
246
|
if (typeof (relationship) === "string") {
|
|
209
|
-
resolvedRelationship = ecClass.schema.lookupItemSync(relationship);
|
|
247
|
+
resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);
|
|
210
248
|
}
|
|
211
249
|
else
|
|
212
250
|
resolvedRelationship = relationship;
|
|
213
251
|
if (!resolvedRelationship)
|
|
214
|
-
throw new
|
|
252
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string
|
|
215
253
|
if (typeof (direction) === "string") {
|
|
216
254
|
const tmpDirection = parseStrengthDirection(direction);
|
|
217
255
|
if (undefined === tmpDirection)
|
|
218
|
-
throw new
|
|
256
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
|
|
219
257
|
direction = tmpDirection;
|
|
220
258
|
}
|
|
221
259
|
const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship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EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { ECClassModifier, parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedMixin } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { Mixin } from \"./Mixin\";\r\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/**\r\n * A Typescript class representation of an ECEntityClass.\r\n * @beta\r\n */\r\nexport class EntityClass extends ECClass {\r\n public override readonly schemaItemType!: SchemaItemType.EntityClass;\r\n protected _mixins?: LazyLoadedMixin[];\r\n\r\n constructor(schema: Schema, name: string, modifier?: ECClassModifier) {\r\n super(schema, name, modifier);\r\n this.schemaItemType = SchemaItemType.EntityClass;\r\n }\r\n\r\n public get mixins(): LazyLoadedMixin[] {\r\n if (!this._mixins)\r\n return [];\r\n return this._mixins;\r\n }\r\n\r\n public *getMixinsSync(): Iterable<Mixin> {\r\n if (!this._mixins)\r\n return function* (): Iterable<Mixin> { }(); // empty iterable\r\n\r\n for (const mixin of this._mixins) {\r\n const mObj = this.schema.lookupItemSync<Mixin>(mixin);\r\n if (mObj) {\r\n yield mObj;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param mixin\r\n */\r\n protected addMixin(mixin: Mixin) {\r\n if (!this._mixins)\r\n this._mixins = [];\r\n\r\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\r\n return;\r\n }\r\n\r\n /**\r\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\r\n * @param name The name of the property to find.\r\n */\r\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\r\n let inheritedProperty = await super.getInheritedProperty(name);\r\n\r\n if (!inheritedProperty && this._mixins) {\r\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\r\n mixinProps.some((prop) => {\r\n inheritedProperty = prop as AnyProperty;\r\n return inheritedProperty !== undefined;\r\n });\r\n }\r\n\r\n return inheritedProperty as AnyProperty | undefined;\r\n }\r\n\r\n /**\r\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\r\n * @param name The name of the property to find.\r\n */\r\n public override getInheritedPropertySync(name: string): Property | undefined {\r\n const inheritedProperty = super.getInheritedPropertySync(name);\r\n if (inheritedProperty)\r\n return inheritedProperty;\r\n\r\n if (!this._mixins) {\r\n return undefined;\r\n }\r\n\r\n for (const mixin of this._mixins) {\r\n const mObj = this.schema.lookupItemSync<ECClass>(mixin);\r\n if (mObj) {\r\n const result = mObj.getPropertySync(name, true);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): Promise<void> {\r\n if (!existingValues) {\r\n existingValues = new Map<string, number>();\r\n }\r\n\r\n if (this.baseClass) {\r\n ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);\r\n }\r\n\r\n for (const mixin of this.mixins) {\r\n ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);\r\n }\r\n\r\n if (!this.properties)\r\n return;\r\n\r\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\r\n }\r\n\r\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>, resetBaseCaches: boolean = false): void {\r\n if (!existingValues) {\r\n existingValues = new Map<string, number>();\r\n }\r\n\r\n const baseClass = this.getBaseClassSync();\r\n if (baseClass) {\r\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);\r\n }\r\n\r\n for (const mixin of this.getMixinsSync()) {\r\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);\r\n }\r\n\r\n if (!this.properties)\r\n return;\r\n\r\n ECClass.mergeProperties(result, existingValues, [...this.properties], true);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n */\r\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n */\r\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n * Save this EntityClass' properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (this.mixins.length > 0)\r\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n for (const mixin of this.getMixinsSync()) {\r\n const mixinElement = schemaXml.createElement(\"BaseClass\");\r\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\r\n mixinElement.textContent = mixinName;\r\n itemElement.appendChild(mixinElement);\r\n }\r\n return itemElement;\r\n }\r\n\r\n public override async fromJSON(entityClassProps: EntityClassProps) {\r\n this.fromJSONSync(entityClassProps);\r\n }\r\n\r\n public override fromJSONSync(entityClassProps: EntityClassProps) {\r\n super.fromJSONSync(entityClassProps);\r\n\r\n if (undefined !== entityClassProps.mixins) {\r\n if (!this._mixins)\r\n this._mixins = [];\r\n for (const name of entityClassProps.mixins) {\r\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\r\n if (!mixinSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\r\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\r\n async () => {\r\n const mixin = await this.schema.lookupItem<Mixin>(mixinSchemaItemKey);\r\n if (undefined === mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\r\n return mixin;\r\n }));\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\r\n * @internal\r\n */\r\nexport abstract class MutableEntityClass extends EntityClass {\r\n public abstract override addMixin(mixin: Mixin): any;\r\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\r\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n if (await ecClass.getProperty(name))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\r\n\r\n let resolvedRelationship: RelationshipClass | undefined;\r\n if (typeof (relationship) === \"string\") {\r\n resolvedRelationship = await ecClass.schema.lookupItem<RelationshipClass>(relationship);\r\n } else\r\n resolvedRelationship = relationship;\r\n\r\n if (!resolvedRelationship)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\r\n\r\n if (typeof (direction) === \"string\") {\r\n const tmpDirection = parseStrengthDirection(direction);\r\n if (undefined === tmpDirection)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\r\n direction = tmpDirection;\r\n }\r\n\r\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\r\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\r\n}\r\n\r\n/** @internal */\r\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n if (ecClass.getPropertySync(name))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\r\n\r\n let resolvedRelationship: RelationshipClass | undefined;\r\n if (typeof (relationship) === \"string\") {\r\n resolvedRelationship = ecClass.schema.lookupItemSync<RelationshipClass>(relationship);\r\n } else\r\n resolvedRelationship = relationship;\r\n\r\n if (!resolvedRelationship)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\r\n\r\n if (typeof (direction) === \"string\") {\r\n const tmpDirection = parseStrengthDirection(direction);\r\n if (undefined === tmpDirection)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\r\n direction = tmpDirection;\r\n }\r\n\r\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\r\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAe,kBAAkB,EAAY,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IACb,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IACrE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAqB;IAEpC,IAAW,MAAM;QACf,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,CAAC,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO;QAET,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG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,CAAC;IACxD,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE,CAAC;QACvC,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACxF,CAAC;;QACC,oBAAoB,GAAG,YAAY,CAAC;IAEtC,IAAI,CAAC,oBAAoB;QACvB,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,WAAW,EAAE,mCAAmC,YAAY,8CAA8C,CAAC,CAAC,CAAE,2DAA2D;IAElN,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,SAAS,KAAK,YAAY;YAC5B,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,wBAAwB,EAAE,mCAAmC,SAAS,qCAAqC,CAAC,CAAC;QACtJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","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 { DelayedPromiseWithProps } from \"../DelayedPromise\";\r\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\r\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\r\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { ECClass } from \"./Class\";\r\nimport { Mixin } from \"./Mixin\";\r\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\r\nimport { RelationshipClass } from \"./RelationshipClass\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/**\r\n * A Typescript class representation of an ECEntityClass.\r\n * @public @preview\r\n */\r\nexport class EntityClass extends ECClass implements HasMixins {\r\n public override readonly schemaItemType = EntityClass.schemaItemType;\r\n /** @internal */\r\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\r\n private _mixins?: LazyLoadedMixin[];\r\n\r\n public get mixins(): ReadonlyArray<LazyLoadedMixin> {\r\n if (!this._mixins)\r\n return [];\r\n return this._mixins;\r\n }\r\n\r\n public *getMixinsSync(): Iterable<Mixin> {\r\n if (!this._mixins)\r\n return;\r\n\r\n for (const mixin of this._mixins) {\r\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\r\n if (mObj) {\r\n yield mObj;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param mixin\r\n * @internal\r\n */\r\n protected addMixin(mixin: Mixin) {\r\n if (!this._mixins)\r\n this._mixins = [];\r\n\r\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\r\n return;\r\n }\r\n\r\n /**\r\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\r\n * @param name The name of the property to find.\r\n */\r\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\r\n let inheritedProperty = await super.getInheritedProperty(name);\r\n\r\n if (!inheritedProperty && this._mixins) {\r\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\r\n mixinProps.some((prop) => {\r\n inheritedProperty = prop as AnyProperty;\r\n return inheritedProperty !== undefined;\r\n });\r\n }\r\n\r\n return inheritedProperty as AnyProperty | undefined;\r\n }\r\n\r\n /**\r\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\r\n * @param name The name of the property to find.\r\n */\r\n public override getInheritedPropertySync(name: string): Property | undefined {\r\n const inheritedProperty = super.getInheritedPropertySync(name);\r\n if (inheritedProperty)\r\n return inheritedProperty;\r\n\r\n if (!this._mixins) {\r\n return undefined;\r\n }\r\n\r\n for (const mixin of this._mixins) {\r\n const mObj = this.schema.lookupItemSync(mixin);\r\n if (mObj && ECClass.isECClass(mObj)) {\r\n const result = mObj.getPropertySync(name, true);\r\n if (result) {\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n *\r\n * @param result\r\n * @param existingValues\r\n * @internal\r\n */\r\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void> {\r\n if (!existingValues) {\r\n existingValues = new Map<string, number>();\r\n }\r\n\r\n const baseClass = await this.baseClass;\r\n if (baseClass) {\r\n ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);\r\n }\r\n\r\n for (const mixin of this.mixins) {\r\n const resolvedMixin = await mixin;\r\n ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);\r\n }\r\n\r\n const localProps = await this.getProperties();\r\n ECClass.mergeProperties(result, existingValues, localProps, true);\r\n }\r\n\r\n /**\r\n *\r\n * @param result\r\n * @param existingValues\r\n * @internal\r\n */\r\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>): void {\r\n if (!existingValues) {\r\n existingValues = new Map<string, number>();\r\n }\r\n\r\n const baseClass = this.getBaseClassSync();\r\n if (baseClass) {\r\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);\r\n }\r\n\r\n for (const mixin of this.getMixinsSync()) {\r\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(), false);\r\n }\r\n\r\n const localProps = this.getPropertiesSync(true);\r\n ECClass.mergeProperties(result, existingValues, localProps, true);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n * @internal\r\n */\r\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param relationship\r\n * @param direction\r\n * @internal\r\n */\r\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\r\n }\r\n\r\n /**\r\n * Save this EntityClass' properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n if (this.mixins.length > 0)\r\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n\r\n for (const lazyMixin of this.mixins) {\r\n const mixin = await lazyMixin;\r\n const mixinElement = schemaXml.createElement(\"BaseClass\");\r\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\r\n mixinElement.textContent = mixinName;\r\n itemElement.appendChild(mixinElement);\r\n }\r\n return itemElement;\r\n }\r\n\r\n public override async fromJSON(entityClassProps: EntityClassProps) {\r\n this.fromJSONSync(entityClassProps);\r\n }\r\n\r\n public override fromJSONSync(entityClassProps: EntityClassProps) {\r\n super.fromJSONSync(entityClassProps);\r\n\r\n if (undefined !== entityClassProps.mixins) {\r\n if (!this._mixins)\r\n this._mixins = [];\r\n for (const name of entityClassProps.mixins) {\r\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\r\n if (!mixinSchemaItemKey)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\r\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\r\n async () => {\r\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\r\n if (undefined === mixin)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\r\n return mixin;\r\n }));\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Type guard to check if the SchemaItem is of type EntityClass.\r\n * @param item The SchemaItem to check.\r\n * @returns True if the item is an EntityClass, false otherwise.\r\n */\r\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\r\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Type assertion to check if the SchemaItem is of type EntityClass.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\r\n * @internal\r\n */\r\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\r\n if (!this.isEntityClass(item))\r\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\r\n }\r\n}\r\n\r\n/**\r\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\r\n * @internal\r\n */\r\nexport abstract class MutableEntityClass extends EntityClass {\r\n public abstract override addMixin(mixin: Mixin): any;\r\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\r\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\r\n if (await ecClass.getProperty(name, true))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\r\n\r\n let resolvedRelationship: RelationshipClass | undefined;\r\n if (typeof (relationship) === \"string\") {\r\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\r\n } else\r\n resolvedRelationship = relationship;\r\n\r\n if (!resolvedRelationship)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\r\n\r\n if (typeof (direction) === \"string\") {\r\n const tmpDirection = parseStrengthDirection(direction);\r\n if (undefined === tmpDirection)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\r\n direction = tmpDirection;\r\n }\r\n\r\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\r\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\r\n}\r\n\r\n/** @internal */\r\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\r\n if (ecClass.getPropertySync(name))\r\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\r\n\r\n let resolvedRelationship: RelationshipClass | undefined;\r\n if (typeof (relationship) === \"string\") {\r\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\r\n } else\r\n resolvedRelationship = relationship;\r\n\r\n if (!resolvedRelationship)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\r\n\r\n if (typeof (direction) === \"string\") {\r\n const tmpDirection = parseStrengthDirection(direction);\r\n if (undefined === tmpDirection)\r\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\r\n direction = tmpDirection;\r\n }\r\n\r\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\r\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\r\n}\r\n"]}
|
|
@@ -5,27 +5,30 @@ import { EnumerationProps } from "../Deserialization/JsonProps";
|
|
|
5
5
|
import { PrimitiveType, SchemaItemType } from "../ECObjects";
|
|
6
6
|
import { Schema } from "./Schema";
|
|
7
7
|
import { SchemaItem } from "./SchemaItem";
|
|
8
|
-
/** @
|
|
8
|
+
/** @public @preview */
|
|
9
9
|
export interface Enumerator<T> {
|
|
10
10
|
readonly name: string;
|
|
11
11
|
readonly value: T;
|
|
12
12
|
readonly label?: string;
|
|
13
13
|
readonly description?: string;
|
|
14
14
|
}
|
|
15
|
-
/** @
|
|
15
|
+
/** @public @preview */
|
|
16
16
|
export type AnyEnumerator = Enumerator<string | number>;
|
|
17
17
|
/**
|
|
18
18
|
* A Typescript class representation of an ECEnumeration.
|
|
19
|
-
* @
|
|
19
|
+
* @public @preview
|
|
20
20
|
*/
|
|
21
21
|
export declare class Enumeration extends SchemaItem {
|
|
22
|
-
readonly schemaItemType: SchemaItemType
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
readonly schemaItemType: SchemaItemType;
|
|
23
|
+
/** @internal */
|
|
24
|
+
static get schemaItemType(): SchemaItemType;
|
|
25
|
+
private _type?;
|
|
26
|
+
private _isStrict;
|
|
27
|
+
private _enumerators;
|
|
28
|
+
get enumerators(): ReadonlyArray<AnyEnumerator>;
|
|
27
29
|
get type(): PrimitiveType.Integer | PrimitiveType.String | undefined;
|
|
28
30
|
get isStrict(): boolean;
|
|
31
|
+
/** @internal */
|
|
29
32
|
constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String);
|
|
30
33
|
get isInt(): boolean;
|
|
31
34
|
get isString(): boolean;
|
|
@@ -54,11 +57,13 @@ export declare class Enumeration extends SchemaItem {
|
|
|
54
57
|
* @param label A localized display label that is used instead of the name in a GUI.
|
|
55
58
|
* @param description A localized description for the enumerator.
|
|
56
59
|
* @return AnyEnumerator object
|
|
60
|
+
* @internal
|
|
57
61
|
*/
|
|
58
62
|
createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator;
|
|
59
63
|
/**
|
|
60
64
|
* Adds enumerator to list of enumerators on this Enumeration
|
|
61
65
|
* @param enumerator The enumerator to add
|
|
66
|
+
* @internal
|
|
62
67
|
*/
|
|
63
68
|
protected addEnumerator(enumerator: AnyEnumerator): void;
|
|
64
69
|
/**
|
|
@@ -72,12 +77,27 @@ export declare class Enumeration extends SchemaItem {
|
|
|
72
77
|
fromJSONSync(enumerationProps: EnumerationProps): void;
|
|
73
78
|
fromJSON(enumerationProps: EnumerationProps): Promise<void>;
|
|
74
79
|
/**
|
|
75
|
-
* @
|
|
80
|
+
* @internal
|
|
76
81
|
*/
|
|
77
82
|
protected setIsStrict(isStrict: boolean): void;
|
|
83
|
+
/**
|
|
84
|
+
* Type guard to check if the SchemaItem is of type Enumeration.
|
|
85
|
+
* @param item The SchemaItem to check.
|
|
86
|
+
* @returns True if the item is an Enumeration, false otherwise.
|
|
87
|
+
*/
|
|
88
|
+
static isEnumeration(item?: SchemaItem): item is Enumeration;
|
|
89
|
+
/**
|
|
90
|
+
* Type assertion to check if the SchemaItem is of type Enumeration.
|
|
91
|
+
* @param item The SchemaItem to check.
|
|
92
|
+
* @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise.
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
static assertIsEnumeration(item?: SchemaItem): asserts item is Enumeration;
|
|
78
96
|
}
|
|
79
|
-
/**
|
|
97
|
+
/**
|
|
80
98
|
* An abstract class used for schema editing.
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
81
101
|
*/
|
|
82
102
|
export declare abstract class MutableEnumeration extends Enumeration {
|
|
83
103
|
abstract addEnumerator(enumerator: AnyEnumerator): void;
|