@itwin/ecschema-metadata 5.0.0-dev.99 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -1
- package/lib/cjs/Context.d.ts +4 -4
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +7 -7
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.d.ts +9 -8
- package/lib/cjs/DelayedPromise.d.ts.map +1 -1
- package/lib/cjs/DelayedPromise.js +2 -2
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +27 -26
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +150 -150
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +34 -34
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js +3 -3
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +49 -49
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +6 -11
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.d.ts +2 -2
- package/lib/cjs/ECName.js +4 -4
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +24 -12
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +48 -25
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.d.ts +4 -4
- package/lib/cjs/Exception.d.ts.map +1 -1
- package/lib/cjs/Exception.js +60 -60
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +30 -34
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +107 -19
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +127 -47
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +12 -9
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +12 -9
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +6 -4
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +8 -6
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +20 -3
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +32 -14
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +16 -9
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +20 -13
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +32 -24
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +47 -27
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +11 -7
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +16 -10
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +24 -15
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +54 -29
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +16 -3
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +20 -7
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +27 -19
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +10 -2
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +11 -3
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +46 -28
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +46 -22
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +6 -3
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +12 -5
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +48 -25
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +54 -34
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +50 -28
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +64 -42
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +10 -19
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +12 -20
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +17 -21
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +20 -22
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +3 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +4 -2
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts +11 -11
- package/lib/cjs/PropertyTypes.d.ts.map +1 -1
- package/lib/cjs/PropertyTypes.js +28 -20
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
- package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/SchemaFormatsProvider.js +172 -0
- package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
- package/lib/cjs/SchemaJsonLocater.d.ts +5 -5
- package/lib/cjs/SchemaJsonLocater.js +4 -4
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +6 -6
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +9 -9
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +3 -3
- package/lib/cjs/SchemaLoader.js +4 -4
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/cjs/SchemaPartVisitorDelegate.js +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +2 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +1 -0
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +3 -3
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Context.d.ts +4 -4
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +8 -8
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.d.ts +9 -8
- package/lib/esm/DelayedPromise.d.ts.map +1 -1
- package/lib/esm/DelayedPromise.js +2 -2
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +28 -27
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +151 -151
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +34 -34
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js +3 -3
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +50 -50
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +7 -12
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.d.ts +2 -2
- package/lib/esm/ECName.js +5 -5
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +24 -12
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +49 -26
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.d.ts +4 -4
- package/lib/esm/Exception.d.ts.map +1 -1
- package/lib/esm/Exception.js +58 -58
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +30 -34
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +107 -19
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +128 -48
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +12 -9
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +13 -10
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +6 -4
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +9 -7
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +20 -3
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +33 -15
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +16 -9
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +21 -14
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +32 -24
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +48 -28
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +11 -7
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +17 -11
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +24 -15
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +55 -30
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +16 -3
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +21 -8
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +28 -20
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +10 -2
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +12 -4
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +46 -28
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +47 -23
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +6 -3
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +13 -6
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +48 -25
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +55 -35
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +50 -28
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +65 -43
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +10 -19
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +13 -21
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +17 -21
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +21 -23
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +3 -1
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +5 -3
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.d.ts +11 -11
- package/lib/esm/PropertyTypes.d.ts.map +1 -1
- package/lib/esm/PropertyTypes.js +29 -21
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
- package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/esm/SchemaFormatsProvider.js +168 -0
- package/lib/esm/SchemaFormatsProvider.js.map +1 -0
- package/lib/esm/SchemaJsonLocater.d.ts +5 -5
- package/lib/esm/SchemaJsonLocater.js +4 -4
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +6 -6
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +10 -10
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +3 -3
- package/lib/esm/SchemaLoader.js +5 -5
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/esm/SchemaPartVisitorDelegate.js +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +2 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +1 -0
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +4 -4
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +12 -6
|
@@ -13,21 +13,22 @@ const Exception_1 = require("../Exception");
|
|
|
13
13
|
const Class_1 = require("./Class");
|
|
14
14
|
/**
|
|
15
15
|
* A Typescript class representation of an ECCustomAttributeClass.
|
|
16
|
-
* @
|
|
16
|
+
* @public @preview
|
|
17
17
|
*/
|
|
18
18
|
class CustomAttributeClass extends Class_1.ECClass {
|
|
19
19
|
schemaItemType = CustomAttributeClass.schemaItemType;
|
|
20
|
+
/** @internal */
|
|
20
21
|
static get schemaItemType() { return ECObjects_1.SchemaItemType.CustomAttributeClass; }
|
|
21
22
|
_appliesTo;
|
|
22
23
|
/**
|
|
23
|
-
* @deprecated in 4.8
|
|
24
|
+
* @deprecated in 4.8 - will not be removed until after 2026-06-13. Use [[appliesTo]]
|
|
24
25
|
* */
|
|
25
26
|
get containerType() {
|
|
26
27
|
return this.appliesTo;
|
|
27
28
|
}
|
|
28
29
|
get appliesTo() {
|
|
29
30
|
if (undefined === this._appliesTo)
|
|
30
|
-
throw new Exception_1.
|
|
31
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);
|
|
31
32
|
return this._appliesTo;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
@@ -50,14 +51,14 @@ class CustomAttributeClass extends Class_1.ECClass {
|
|
|
50
51
|
super.fromJSONSync(customAttributeProps);
|
|
51
52
|
const appliesTo = (0, ECObjects_1.parseCustomAttributeContainerType)(customAttributeProps.appliesTo);
|
|
52
53
|
if (undefined === appliesTo)
|
|
53
|
-
throw new Exception_1.
|
|
54
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);
|
|
54
55
|
this._appliesTo = appliesTo;
|
|
55
56
|
}
|
|
56
57
|
async fromJSON(customAttributeProps) {
|
|
57
58
|
this.fromJSONSync(customAttributeProps);
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
|
-
* @
|
|
61
|
+
* @internal
|
|
61
62
|
*/
|
|
62
63
|
setAppliesTo(containerType) {
|
|
63
64
|
this._appliesTo = containerType;
|
|
@@ -76,10 +77,11 @@ class CustomAttributeClass extends Class_1.ECClass {
|
|
|
76
77
|
* Type assertion to check if the SchemaItem is of type CustomAttributeClass.
|
|
77
78
|
* @param item The SchemaItem to check.
|
|
78
79
|
* @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.
|
|
80
|
+
* @internal
|
|
79
81
|
*/
|
|
80
82
|
static assertIsCustomAttributeClass(item) {
|
|
81
83
|
if (!this.isCustomAttributeClass(item))
|
|
82
|
-
throw new Exception_1.
|
|
84
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
exports.CustomAttributeClass = CustomAttributeClass;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAEsB;AACtB,
|
|
1
|
+
{"version":3,"file":"CustomAttributeClass.js","sourceRoot":"","sources":["../../../src/Metadata/CustomAttributeClass.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,4CAEsB;AACtB,4CAA6D;AAC7D,mCAAkC;AAGlC;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,eAAO;IACtB,cAAc,GAAG,oBAAoB,CAAC,cAAc,CAAC;IAC9E,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC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AA+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,0BAAc,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,yBAAa,CAAC,0BAAc,CAAC,qBAAqB,EAAE,aAAa,0BAAc,CAAC,oBAAoB,0BAA0B,CAAC,CAAC;IAC9I,CAAC;CACF;AA9ED,oDA8EC;AACD;;;GAGG;AACH,MAAsB,cAAe,SAAQ,oBAAoB;CAGhE;AAHD,wCAGC","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/** @packageDocumentation\n * @module Metadata\n */\n\nimport { CustomAttributeClassProps } from \"../Deserialization/JsonProps\";\nimport {\n containerTypeToString, CustomAttributeContainerType, parseCustomAttributeContainerType, SchemaItemType,\n} from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { ECClass } from \"./Class\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECCustomAttributeClass.\n * @public @preview\n */\nexport class CustomAttributeClass extends ECClass {\n public override readonly schemaItemType = CustomAttributeClass.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.CustomAttributeClass; }\n private _appliesTo?: CustomAttributeContainerType;\n\n /**\n * @deprecated in 4.8 - will not be removed until after 2026-06-13. Use [[appliesTo]]\n * */\n public get containerType(): CustomAttributeContainerType {\n return this.appliesTo;\n }\n\n public get appliesTo(): CustomAttributeContainerType {\n if (undefined === this._appliesTo)\n throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `The CustomAttributeClass ${this.name} does not have a CustomAttributeContainerType.`);\n return this._appliesTo;\n }\n\n /**\n * Save this CustomAttributeClasses properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): CustomAttributeClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n schemaJson.appliesTo = containerTypeToString(this.appliesTo);\n return schemaJson as CustomAttributeClassProps;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n itemElement.setAttribute(\"appliesTo\", containerTypeToString(this.appliesTo));\n return itemElement;\n }\n\n public override fromJSONSync(customAttributeProps: CustomAttributeClassProps) {\n super.fromJSONSync(customAttributeProps);\n const appliesTo = parseCustomAttributeContainerType(customAttributeProps.appliesTo);\n if (undefined === appliesTo)\n throw new ECSchemaError(ECSchemaStatus.InvalidContainerType, `${appliesTo} is not a valid CustomAttributeContainerType.`);\n this._appliesTo = appliesTo;\n }\n\n public override async fromJSON(customAttributeProps: CustomAttributeClassProps) {\n this.fromJSONSync(customAttributeProps);\n }\n\n /**\n * @internal\n */\n protected setAppliesTo(containerType: CustomAttributeContainerType) {\n this._appliesTo = containerType;\n }\n\n /**\n * Type guard to check if the SchemaItem is of type CustomAttributeClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is a CustomAttributeClass, false otherwise.\n */\n public static isCustomAttributeClass(item?: SchemaItem): item is CustomAttributeClass {\n if (item && item.schemaItemType === SchemaItemType.CustomAttributeClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type CustomAttributeClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to CustomAttributeClass if it is a CustomAttributeClass, undefined otherwise.\n * @internal\n */\n public static assertIsCustomAttributeClass(item?: SchemaItem): asserts item is CustomAttributeClass {\n if (!this.isCustomAttributeClass(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.CustomAttributeClass}' (CustomAttributeClass)`);\n }\n}\n/**\n * @internal\n * An abstract class used for Schema editing.\n */\nexport abstract class MutableCAClass extends CustomAttributeClass {\n public abstract override setAppliesTo(containerType: CustomAttributeContainerType): void;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -11,17 +11,19 @@ import { RelationshipClass } from "./RelationshipClass";
|
|
|
11
11
|
import { SchemaItem } from "./SchemaItem";
|
|
12
12
|
/**
|
|
13
13
|
* A Typescript class representation of an ECEntityClass.
|
|
14
|
-
* @
|
|
14
|
+
* @public @preview
|
|
15
15
|
*/
|
|
16
16
|
export declare class EntityClass extends ECClass implements HasMixins {
|
|
17
17
|
readonly schemaItemType: SchemaItemType;
|
|
18
|
+
/** @internal */
|
|
18
19
|
static get schemaItemType(): SchemaItemType;
|
|
19
|
-
|
|
20
|
-
get mixins(): LazyLoadedMixin
|
|
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 implements HasMixins {
|
|
|
34
36
|
* @param name The name of the property to find.
|
|
35
37
|
*/
|
|
36
38
|
getInheritedPropertySync(name: string): Property | undefined;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param result
|
|
42
|
+
* @param existingValues
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
37
45
|
protected buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param result
|
|
49
|
+
* @param existingValues
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
38
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 implements HasMixins {
|
|
|
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
|
/**
|
|
@@ -70,6 +86,7 @@ export declare class EntityClass extends ECClass implements HasMixins {
|
|
|
70
86
|
* Type assertion to check if the SchemaItem is of type EntityClass.
|
|
71
87
|
* @param item The SchemaItem to check.
|
|
72
88
|
* @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
|
|
89
|
+
* @internal
|
|
73
90
|
*/
|
|
74
91
|
static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass;
|
|
75
92
|
}
|
|
@@ -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,EAA0B,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAA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AU,GAAG,IAAI,IAAI,WAAW;IAOnE;;;;;OAKG;WACW,mBAAmB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW;CAIlF;AAED;;;GAGG;AACH,8BAAsB,kBAAmB,SAAQ,WAAW;aACjC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG;aAC3B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;aACpJ,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;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"}
|
|
@@ -20,10 +20,11 @@ const Property_1 = require("./Property");
|
|
|
20
20
|
const RelationshipClass_1 = require("./RelationshipClass");
|
|
21
21
|
/**
|
|
22
22
|
* A Typescript class representation of an ECEntityClass.
|
|
23
|
-
* @
|
|
23
|
+
* @public @preview
|
|
24
24
|
*/
|
|
25
25
|
class EntityClass extends Class_1.ECClass {
|
|
26
26
|
schemaItemType = EntityClass.schemaItemType;
|
|
27
|
+
/** @internal */
|
|
27
28
|
static get schemaItemType() { return ECObjects_1.SchemaItemType.EntityClass; }
|
|
28
29
|
_mixins;
|
|
29
30
|
get mixins() {
|
|
@@ -33,7 +34,7 @@ class EntityClass extends Class_1.ECClass {
|
|
|
33
34
|
}
|
|
34
35
|
*getMixinsSync() {
|
|
35
36
|
if (!this._mixins)
|
|
36
|
-
return
|
|
37
|
+
return;
|
|
37
38
|
for (const mixin of this._mixins) {
|
|
38
39
|
const mObj = this.schema.lookupItemSync(mixin, Mixin_1.Mixin);
|
|
39
40
|
if (mObj) {
|
|
@@ -44,6 +45,7 @@ class EntityClass extends Class_1.ECClass {
|
|
|
44
45
|
/**
|
|
45
46
|
*
|
|
46
47
|
* @param mixin
|
|
48
|
+
* @internal
|
|
47
49
|
*/
|
|
48
50
|
addMixin(mixin) {
|
|
49
51
|
if (!this._mixins)
|
|
@@ -88,6 +90,12 @@ class EntityClass extends Class_1.ECClass {
|
|
|
88
90
|
}
|
|
89
91
|
return undefined;
|
|
90
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @param result
|
|
96
|
+
* @param existingValues
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
91
99
|
async buildPropertyCache(result, existingValues) {
|
|
92
100
|
if (!existingValues) {
|
|
93
101
|
existingValues = new Map();
|
|
@@ -100,9 +108,15 @@ class EntityClass extends Class_1.ECClass {
|
|
|
100
108
|
const resolvedMixin = await mixin;
|
|
101
109
|
Class_1.ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);
|
|
102
110
|
}
|
|
103
|
-
const localProps = await this.getProperties(
|
|
111
|
+
const localProps = await this.getProperties();
|
|
104
112
|
Class_1.ECClass.mergeProperties(result, existingValues, localProps, true);
|
|
105
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param result
|
|
117
|
+
* @param existingValues
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
106
120
|
buildPropertyCacheSync(result, existingValues) {
|
|
107
121
|
if (!existingValues) {
|
|
108
122
|
existingValues = new Map();
|
|
@@ -122,6 +136,7 @@ class EntityClass extends Class_1.ECClass {
|
|
|
122
136
|
* @param name
|
|
123
137
|
* @param relationship
|
|
124
138
|
* @param direction
|
|
139
|
+
* @internal
|
|
125
140
|
*/
|
|
126
141
|
async createNavigationProperty(name, relationship, direction) {
|
|
127
142
|
return this.addProperty(await createNavigationProperty(this, name, relationship, direction));
|
|
@@ -131,6 +146,7 @@ class EntityClass extends Class_1.ECClass {
|
|
|
131
146
|
* @param name
|
|
132
147
|
* @param relationship
|
|
133
148
|
* @param direction
|
|
149
|
+
* @internal
|
|
134
150
|
*/
|
|
135
151
|
createNavigationPropertySync(name, relationship, direction) {
|
|
136
152
|
return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));
|
|
@@ -149,7 +165,8 @@ class EntityClass extends Class_1.ECClass {
|
|
|
149
165
|
/** @internal */
|
|
150
166
|
async toXml(schemaXml) {
|
|
151
167
|
const itemElement = await super.toXml(schemaXml);
|
|
152
|
-
for (const
|
|
168
|
+
for (const lazyMixin of this.mixins) {
|
|
169
|
+
const mixin = await lazyMixin;
|
|
153
170
|
const mixinElement = schemaXml.createElement("BaseClass");
|
|
154
171
|
const mixinName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);
|
|
155
172
|
mixinElement.textContent = mixinName;
|
|
@@ -168,11 +185,11 @@ class EntityClass extends Class_1.ECClass {
|
|
|
168
185
|
for (const name of entityClassProps.mixins) {
|
|
169
186
|
const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);
|
|
170
187
|
if (!mixinSchemaItemKey)
|
|
171
|
-
throw new Exception_1.
|
|
188
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
|
|
172
189
|
this._mixins.push(new DelayedPromise_1.DelayedPromiseWithProps(mixinSchemaItemKey, async () => {
|
|
173
190
|
const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin_1.Mixin);
|
|
174
191
|
if (undefined === mixin)
|
|
175
|
-
throw new Exception_1.
|
|
192
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
|
|
176
193
|
return mixin;
|
|
177
194
|
}));
|
|
178
195
|
}
|
|
@@ -192,10 +209,11 @@ class EntityClass extends Class_1.ECClass {
|
|
|
192
209
|
* Type assertion to check if the SchemaItem is of type EntityClass.
|
|
193
210
|
* @param item The SchemaItem to check.
|
|
194
211
|
* @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.
|
|
212
|
+
* @internal
|
|
195
213
|
*/
|
|
196
214
|
static assertIsEntityClass(item) {
|
|
197
215
|
if (!this.isEntityClass(item))
|
|
198
|
-
throw new Exception_1.
|
|
216
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.EntityClass}' (EntityClass)`);
|
|
199
217
|
}
|
|
200
218
|
}
|
|
201
219
|
exports.EntityClass = EntityClass;
|
|
@@ -208,8 +226,8 @@ class MutableEntityClass extends EntityClass {
|
|
|
208
226
|
exports.MutableEntityClass = MutableEntityClass;
|
|
209
227
|
/** @internal */
|
|
210
228
|
async function createNavigationProperty(ecClass, name, relationship, direction) {
|
|
211
|
-
if (await ecClass.getProperty(name))
|
|
212
|
-
throw new Exception_1.
|
|
229
|
+
if (await ecClass.getProperty(name, true))
|
|
230
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
|
|
213
231
|
let resolvedRelationship;
|
|
214
232
|
if (typeof (relationship) === "string") {
|
|
215
233
|
resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass_1.RelationshipClass);
|
|
@@ -217,11 +235,11 @@ async function createNavigationProperty(ecClass, name, relationship, direction)
|
|
|
217
235
|
else
|
|
218
236
|
resolvedRelationship = relationship;
|
|
219
237
|
if (!resolvedRelationship)
|
|
220
|
-
throw new Exception_1.
|
|
238
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string
|
|
221
239
|
if (typeof (direction) === "string") {
|
|
222
240
|
const tmpDirection = (0, ECObjects_1.parseStrengthDirection)(direction);
|
|
223
241
|
if (undefined === tmpDirection)
|
|
224
|
-
throw new Exception_1.
|
|
242
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
|
|
225
243
|
direction = tmpDirection;
|
|
226
244
|
}
|
|
227
245
|
const lazyRelationship = new DelayedPromise_1.DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
|
|
@@ -230,7 +248,7 @@ async function createNavigationProperty(ecClass, name, relationship, direction)
|
|
|
230
248
|
/** @internal */
|
|
231
249
|
function createNavigationPropertySync(ecClass, name, relationship, direction) {
|
|
232
250
|
if (ecClass.getPropertySync(name))
|
|
233
|
-
throw new Exception_1.
|
|
251
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
|
|
234
252
|
let resolvedRelationship;
|
|
235
253
|
if (typeof (relationship) === "string") {
|
|
236
254
|
resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass_1.RelationshipClass);
|
|
@@ -238,11 +256,11 @@ function createNavigationPropertySync(ecClass, name, relationship, direction) {
|
|
|
238
256
|
else
|
|
239
257
|
resolvedRelationship = relationship;
|
|
240
258
|
if (!resolvedRelationship)
|
|
241
|
-
throw new Exception_1.
|
|
259
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string
|
|
242
260
|
if (typeof (direction) === "string") {
|
|
243
261
|
const tmpDirection = (0, ECObjects_1.parseStrengthDirection)(direction);
|
|
244
262
|
if (undefined === tmpDirection)
|
|
245
|
-
throw new Exception_1.
|
|
263
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
|
|
246
264
|
direction = tmpDirection;
|
|
247
265
|
}
|
|
248
266
|
const lazyRelationship = new DelayedPromise_1.DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAgPH,4DAsBC;AAGD,oEAsBC;AA7RD,sDAA4D;AAE5D,oFAAiF;AACjF,4CAAyF;AACzF,4CAA+D;AAG/D,mCAAkC;AAClC,mCAAgC;AAChC,yCAAuE;AACvE,2DAAwD;AAGxD;;;GAGG;AACH,MAAa,WAAY,SAAQ,eAAO;IACb,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAC9D,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,WAAW,CAAC,CAAC,CAAC;IACxE,OAAO,CAAqB;IAEtC,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,QAAQ,CAAC,MAAuB,CAAC,EAAE,CAAC,CAAC,iBAAiB;QAE/D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,M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AAC,YAAY,CAAC,KAAK,QAAQ,EAAE,CAAC;QACvC,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,qCAAiB,CAAC,CAAC;IACxF,CAAC;;QACC,oBAAoB,GAAG,YAAY,CAAC;IAEtC,IAAI,CAAC,oBAAoB;QACvB,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,WAAW,EAAE,mCAAmC,YAAY,8CAA8C,CAAC,CAAC,CAAE,2DAA2D;IAEpN,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,IAAA,kCAAsB,EAAC,SAAS,CAAC,CAAC;QACvD,IAAI,SAAS,KAAK,YAAY;YAC5B,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,wBAAwB,EAAE,mCAAmC,SAAS,qCAAqC,CAAC,CAAC;QACxJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,wCAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,6BAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","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/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @beta\n */\nexport class EntityClass extends ECClass implements HasMixins {\n public override readonly schemaItemType = EntityClass.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\n protected _mixins?: LazyLoadedMixin[];\n\n public get mixins(): LazyLoadedMixin[] {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return function* (): Iterable<Mixin> { }(); // empty iterable\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin);\n if (mObj && ECClass.isECClass(mObj)) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = await this.baseClass;\n if(baseClass) {\n ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);\n }\n\n for (const mixin of this.mixins) {\n const resolvedMixin = await mixin;\n ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);\n }\n\n const localProps = await this.getProperties(true);\n ECClass.mergeProperties(result, existingValues, localProps, true);\n }\n\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);\n }\n\n for (const mixin of this.getMixinsSync()) {\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(), false);\n }\n\n const localProps = this.getPropertiesSync(true);\n ECClass.mergeProperties(result, existingValues, localProps, true);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const mixin of this.getMixinsSync()) {\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\n if (undefined === mixin)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n\n /**\n * Type guard to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is an EntityClass, false otherwise.\n */\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\n */\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\n if(!this.isEntityClass(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name))\n throw new ECObjectsError(ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECObjectsError(ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAkQH,4DAsBC;AAGD,oEAsBC;AA/SD,sDAA4D;AAE5D,oFAAiF;AACjF,4CAAyF;AACzF,4CAA6D;AAG7D,mCAAkC;AAClC,mCAAgC;AAChC,yCAAuE;AACvE,2DAAwD;AAGxD;;;GAGG;AACH,MAAa,WAAY,SAAQ,eAAO;IACb,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IACrE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,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;Q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,0BAAc,CAAC,iBAAiB,EAAE,+BAA+B,IAAI,gCAAgC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAEhJ,IAAI,oBAAmD,CAAC;IACxD,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE,CAAC;QACvC,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,qCAAiB,CAAC,CAAC;IACxF,CAAC;;QACC,oBAAoB,GAAG,YAAY,CAAC;IAEtC,IAAI,CAAC,oBAAoB;QACvB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,mCAAmC,YAAY,8CAA8C,CAAC,CAAC,CAAE,2DAA2D;IAElN,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,IAAA,kCAAsB,EAAC,SAAS,CAAC,CAAC;QACvD,IAAI,SAAS,KAAK,YAAY;YAC5B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,wBAAwB,EAAE,mCAAmC,SAAS,qCAAqC,CAAC,CAAC;QACtJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,wCAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,6BAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","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/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @public @preview\n */\nexport class EntityClass extends ECClass implements HasMixins {\n public override readonly schemaItemType = EntityClass.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\n private _mixins?: LazyLoadedMixin[];\n\n public get mixins(): ReadonlyArray<LazyLoadedMixin> {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return;\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n * @internal\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin);\n if (mObj && ECClass.isECClass(mObj)) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n /**\n *\n * @param result\n * @param existingValues\n * @internal\n */\n protected override async buildPropertyCache(result: Property[], existingValues?: Map<string, number>): Promise<void> {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = await this.baseClass;\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, await baseClass.getProperties(), false);\n }\n\n for (const mixin of this.mixins) {\n const resolvedMixin = await mixin;\n ECClass.mergeProperties(result, existingValues, await resolvedMixin.getProperties(), false);\n }\n\n const localProps = await this.getProperties();\n ECClass.mergeProperties(result, existingValues, localProps, true);\n }\n\n /**\n *\n * @param result\n * @param existingValues\n * @internal\n */\n protected override buildPropertyCacheSync(result: Property[], existingValues?: Map<string, number>): void {\n if (!existingValues) {\n existingValues = new Map<string, number>();\n }\n\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(), false);\n }\n\n for (const mixin of this.getMixinsSync()) {\n ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(), false);\n }\n\n const localProps = this.getPropertiesSync(true);\n ECClass.mergeProperties(result, existingValues, localProps, true);\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const lazyMixin of this.mixins) {\n const mixin = await lazyMixin;\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\n if (undefined === mixin)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n\n /**\n * Type guard to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is an EntityClass, false otherwise.\n */\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\n * @internal\n */\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\n if (!this.isEntityClass(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name, true))\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name))\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}
|
|
@@ -5,28 +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
22
|
readonly schemaItemType: SchemaItemType;
|
|
23
|
+
/** @internal */
|
|
23
24
|
static get schemaItemType(): SchemaItemType;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
get enumerators(): AnyEnumerator
|
|
25
|
+
private _type?;
|
|
26
|
+
private _isStrict;
|
|
27
|
+
private _enumerators;
|
|
28
|
+
get enumerators(): ReadonlyArray<AnyEnumerator>;
|
|
28
29
|
get type(): PrimitiveType.Integer | PrimitiveType.String | undefined;
|
|
29
30
|
get isStrict(): boolean;
|
|
31
|
+
/** @internal */
|
|
30
32
|
constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String);
|
|
31
33
|
get isInt(): boolean;
|
|
32
34
|
get isString(): boolean;
|
|
@@ -55,11 +57,13 @@ export declare class Enumeration extends SchemaItem {
|
|
|
55
57
|
* @param label A localized display label that is used instead of the name in a GUI.
|
|
56
58
|
* @param description A localized description for the enumerator.
|
|
57
59
|
* @return AnyEnumerator object
|
|
60
|
+
* @internal
|
|
58
61
|
*/
|
|
59
62
|
createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator;
|
|
60
63
|
/**
|
|
61
64
|
* Adds enumerator to list of enumerators on this Enumeration
|
|
62
65
|
* @param enumerator The enumerator to add
|
|
66
|
+
* @internal
|
|
63
67
|
*/
|
|
64
68
|
protected addEnumerator(enumerator: AnyEnumerator): void;
|
|
65
69
|
/**
|
|
@@ -73,7 +77,7 @@ export declare class Enumeration extends SchemaItem {
|
|
|
73
77
|
fromJSONSync(enumerationProps: EnumerationProps): void;
|
|
74
78
|
fromJSON(enumerationProps: EnumerationProps): Promise<void>;
|
|
75
79
|
/**
|
|
76
|
-
* @
|
|
80
|
+
* @internal
|
|
77
81
|
*/
|
|
78
82
|
protected setIsStrict(isStrict: boolean): void;
|
|
79
83
|
/**
|
|
@@ -86,11 +90,14 @@ export declare class Enumeration extends SchemaItem {
|
|
|
86
90
|
* Type assertion to check if the SchemaItem is of type Enumeration.
|
|
87
91
|
* @param item The SchemaItem to check.
|
|
88
92
|
* @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise.
|
|
93
|
+
* @internal
|
|
89
94
|
*/
|
|
90
95
|
static assertIsEnumeration(item?: SchemaItem): asserts item is Enumeration;
|
|
91
96
|
}
|
|
92
|
-
/**
|
|
97
|
+
/**
|
|
93
98
|
* An abstract class used for schema editing.
|
|
99
|
+
*
|
|
100
|
+
* @internal
|
|
94
101
|
*/
|
|
95
102
|
export declare abstract class MutableEnumeration extends Enumeration {
|
|
96
103
|
abstract addEnumerator(enumerator: AnyEnumerator): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumeration.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Enumeration.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,aAAa,EAAyB,cAAc,EAAE,MAAM,cAAc,CAAC;AAGpF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"Enumeration.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Enumeration.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,aAAa,EAAyB,cAAc,EAAE,MAAM,cAAc,CAAC;AAGpF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,uBAAuB;AACvB,MAAM,WAAW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AAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,aAAa;IAWlH;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa;IAIjD;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,gBAAgB;IAe5G,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBlD,YAAY,CAAC,gBAAgB,EAAE,gBAAgB;IA6BzC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAIjE;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO;IAIvC;;;;OAIG;WACW,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,WAAW;IAInE;;;;;OAKG;WACW,mBAAmB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW;CAIlF;AAED;;;;GAIG;AACH,8BAAsB,kBAAmB,SAAQ,WAAW;aACjC,aAAa,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI;aAC9C,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;aACpC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -15,10 +15,11 @@ const ECName_1 = require("../ECName");
|
|
|
15
15
|
const SchemaItem_1 = require("./SchemaItem");
|
|
16
16
|
/**
|
|
17
17
|
* A Typescript class representation of an ECEnumeration.
|
|
18
|
-
* @
|
|
18
|
+
* @public @preview
|
|
19
19
|
*/
|
|
20
20
|
class Enumeration extends SchemaItem_1.SchemaItem {
|
|
21
21
|
schemaItemType = Enumeration.schemaItemType;
|
|
22
|
+
/** @internal */
|
|
22
23
|
static get schemaItemType() { return ECObjects_1.SchemaItemType.Enumeration; }
|
|
23
24
|
_type;
|
|
24
25
|
_isStrict;
|
|
@@ -26,6 +27,7 @@ class Enumeration extends SchemaItem_1.SchemaItem {
|
|
|
26
27
|
get enumerators() { return this._enumerators; }
|
|
27
28
|
get type() { return this._type; }
|
|
28
29
|
get isStrict() { return this._isStrict; }
|
|
30
|
+
/** @internal */
|
|
29
31
|
constructor(schema, name, primitiveType) {
|
|
30
32
|
super(schema, name);
|
|
31
33
|
this._type = primitiveType;
|
|
@@ -53,9 +55,9 @@ class Enumeration extends SchemaItem_1.SchemaItem {
|
|
|
53
55
|
findDuplicateEnumerators(name, value) {
|
|
54
56
|
this._enumerators.forEach((element) => {
|
|
55
57
|
if (element.name.toLowerCase() === name.toLowerCase())
|
|
56
|
-
throw new Exception_1.
|
|
58
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this.name} has a duplicate Enumerator with name '${name}'.`);
|
|
57
59
|
if (element.value === value)
|
|
58
|
-
throw new Exception_1.
|
|
60
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this.name} has a duplicate Enumerator with value '${value}'.`);
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
@@ -65,23 +67,25 @@ class Enumeration extends SchemaItem_1.SchemaItem {
|
|
|
65
67
|
* @param label A localized display label that is used instead of the name in a GUI.
|
|
66
68
|
* @param description A localized description for the enumerator.
|
|
67
69
|
* @return AnyEnumerator object
|
|
70
|
+
* @internal
|
|
68
71
|
*/
|
|
69
72
|
createEnumerator(name, value, label, description) {
|
|
70
73
|
if (this.isInt && typeof (value) === "string") // throws if backing type is int and value is string
|
|
71
|
-
throw new Exception_1.
|
|
74
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this.name} has a backing type 'integer' and an enumerator with value of type 'string'.`);
|
|
72
75
|
if (!this.isInt && typeof (value) === "number") // also throws if backing type is string and value is number
|
|
73
|
-
throw new Exception_1.
|
|
76
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this.name} has a backing type 'string' and an enumerator with value of type 'integer'.`);
|
|
74
77
|
this.findDuplicateEnumerators(name, value); // check for duplicates; throw if there are any
|
|
75
78
|
if (!ECName_1.ECName.validate(name))
|
|
76
|
-
throw new Exception_1.
|
|
79
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECName, `The Enumeration ${this.name} has an enumerator with an invalid 'name' attribute. ${name} is not a valid ECName.`);
|
|
77
80
|
return { name, value, label, description };
|
|
78
81
|
}
|
|
79
82
|
/**
|
|
80
83
|
* Adds enumerator to list of enumerators on this Enumeration
|
|
81
84
|
* @param enumerator The enumerator to add
|
|
85
|
+
* @internal
|
|
82
86
|
*/
|
|
83
87
|
addEnumerator(enumerator) {
|
|
84
|
-
this.
|
|
88
|
+
this._enumerators.push(enumerator);
|
|
85
89
|
}
|
|
86
90
|
/**
|
|
87
91
|
* Save this Enumeration's properties to an object for serializing to JSON.
|
|
@@ -134,19 +138,19 @@ class Enumeration extends SchemaItem_1.SchemaItem {
|
|
|
134
138
|
if (Helper_1.SchemaReadHelper.isECSpecVersionNewer({ readVersion: enumerationProps.originalECSpecMajorVersion, writeVersion: enumerationProps.originalECSpecMinorVersion }))
|
|
135
139
|
this._type = ECObjects_1.PrimitiveType.String;
|
|
136
140
|
else
|
|
137
|
-
throw new Exception_1.
|
|
141
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this.name} has an invalid 'type' attribute. It should be either "int" or "string".`);
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
else {
|
|
141
145
|
const primitiveTypePattern = (this.isInt) ? /int/i : /string/i;
|
|
142
146
|
if (!primitiveTypePattern.test(enumerationProps.type))
|
|
143
|
-
throw new Exception_1.
|
|
147
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidECJson, `The Enumeration ${this.name} has an incompatible type. It must be "${(this.isInt) ? "int" : "string"}", not "${(this.isInt) ? "string" : "int"}".`);
|
|
144
148
|
}
|
|
145
149
|
this._isStrict = enumerationProps.isStrict;
|
|
146
150
|
if (undefined !== enumerationProps.enumerators) {
|
|
147
151
|
enumerationProps.enumerators.forEach((enumerator) => {
|
|
148
152
|
// Creates a new enumerator (with the specified name, value, label and description- label and description are optional) and adds to the list of enumerators.
|
|
149
|
-
// Throws
|
|
153
|
+
// Throws ECSchemaError if there are duplicate names or values present in the enumeration
|
|
150
154
|
this.addEnumerator(this.createEnumerator(enumerator.name, enumerator.value, enumerator.label, enumerator.description));
|
|
151
155
|
});
|
|
152
156
|
}
|
|
@@ -155,7 +159,7 @@ class Enumeration extends SchemaItem_1.SchemaItem {
|
|
|
155
159
|
this.fromJSONSync(enumerationProps);
|
|
156
160
|
}
|
|
157
161
|
/**
|
|
158
|
-
* @
|
|
162
|
+
* @internal
|
|
159
163
|
*/
|
|
160
164
|
setIsStrict(isStrict) {
|
|
161
165
|
this._isStrict = isStrict;
|
|
@@ -172,15 +176,18 @@ class Enumeration extends SchemaItem_1.SchemaItem {
|
|
|
172
176
|
* Type assertion to check if the SchemaItem is of type Enumeration.
|
|
173
177
|
* @param item The SchemaItem to check.
|
|
174
178
|
* @returns The item cast to Enumeration if it is an Enumeration, undefined otherwise.
|
|
179
|
+
* @internal
|
|
175
180
|
*/
|
|
176
181
|
static assertIsEnumeration(item) {
|
|
177
182
|
if (!this.isEnumeration(item))
|
|
178
|
-
throw new Exception_1.
|
|
183
|
+
throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.InvalidSchemaItemType, `Expected '${ECObjects_1.SchemaItemType.Enumeration}' (Enumeration)`);
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
186
|
exports.Enumeration = Enumeration;
|
|
182
|
-
/**
|
|
187
|
+
/**
|
|
183
188
|
* An abstract class used for schema editing.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
184
191
|
*/
|
|
185
192
|
class MutableEnumeration extends Enumeration {
|
|
186
193
|
}
|