@itwin/ecschema-metadata 5.0.0-dev.9 → 5.0.0-dev.90
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 +51 -1
- package/lib/cjs/Constants.js +20 -20
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +83 -34
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +73 -23
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.js +6 -4
- 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 +8 -0
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +3 -0
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +3 -0
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +11 -3
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +2 -6
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js +1 -0
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +21 -1
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +33 -2
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js +1 -0
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +10 -3
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +75 -16
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +168 -46
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +14 -1
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +27 -2
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +16 -4
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +22 -4
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +20 -8
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +42 -22
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +14 -1
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +22 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +41 -1
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +68 -3
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +8 -3
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +17 -6
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +14 -3
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +43 -18
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +15 -1
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +23 -2
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +9 -0
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +14 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +22 -1
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +5 -1
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +83 -28
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +14 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +21 -1
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +15 -2
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +47 -10
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +116 -11
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +135 -33
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +11 -2
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +10 -0
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +8 -1
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +21 -3
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +14 -3
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +21 -3
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaJsonLocater.d.ts +3 -3
- package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonLocater.js +3 -3
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +7 -1
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +13 -3
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +2 -2
- package/lib/cjs/SchemaLoader.d.ts.map +1 -1
- package/lib/cjs/SchemaLoader.js +1 -0
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js +1 -0
- 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/Parser.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 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +2 -3
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.js +20 -20
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Context.d.ts +83 -34
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +71 -21
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.js +6 -4
- 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 +8 -0
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +3 -0
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +3 -0
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +11 -3
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +2 -6
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.js +1 -0
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +21 -1
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +31 -1
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.js +1 -0
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +10 -3
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +75 -16
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +169 -47
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +14 -1
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +27 -2
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +16 -4
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +22 -4
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +20 -8
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +42 -22
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +14 -1
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +22 -1
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +41 -1
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +68 -3
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +8 -3
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +17 -6
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +14 -3
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +43 -18
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +15 -1
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +24 -3
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +9 -0
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +14 -1
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +22 -1
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +5 -1
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +84 -29
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +14 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +21 -1
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +15 -2
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +48 -11
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +116 -11
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +135 -33
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +11 -2
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +11 -1
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +8 -1
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +21 -3
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +14 -3
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +21 -3
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaJsonLocater.d.ts +3 -3
- package/lib/esm/SchemaJsonLocater.d.ts.map +1 -1
- package/lib/esm/SchemaJsonLocater.js +3 -3
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +7 -1
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +13 -3
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +2 -2
- package/lib/esm/SchemaLoader.d.ts.map +1 -1
- package/lib/esm/SchemaLoader.js +1 -0
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js +1 -0
- 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/Parser.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 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +2 -3
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +14 -14
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
|
-
import { schemaItemTypeToXmlString } from "../ECObjects";
|
|
8
|
+
import { AbstractSchemaItemType, SchemaItemType, schemaItemTypeToXmlString } from "../ECObjects";
|
|
9
9
|
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
10
10
|
import { ECVersion, SchemaItemKey } from "../SchemaKey";
|
|
11
11
|
const SCHEMAURL3_2 = "https://dev.bentley.com/json_schemas/ec/32/schemaitem";
|
|
@@ -14,6 +14,15 @@ const SCHEMAURL3_2 = "https://dev.bentley.com/json_schemas/ec/32/schemaitem";
|
|
|
14
14
|
* @beta
|
|
15
15
|
*/
|
|
16
16
|
export class SchemaItem {
|
|
17
|
+
/**
|
|
18
|
+
* Get the type of item represented by this class
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
static get schemaItemType() { return AbstractSchemaItemType.SchemaItem; }
|
|
22
|
+
schema;
|
|
23
|
+
_key;
|
|
24
|
+
_description;
|
|
25
|
+
_label;
|
|
17
26
|
constructor(schema, name) {
|
|
18
27
|
this._key = new SchemaItemKey(name, schema.schemaKey);
|
|
19
28
|
this.schema = schema;
|
|
@@ -104,6 +113,7 @@ export class SchemaItem {
|
|
|
104
113
|
static equalByKey(thisSchemaItem, thatSchemaItemOrKey) {
|
|
105
114
|
if (!thatSchemaItemOrKey)
|
|
106
115
|
return true;
|
|
116
|
+
SchemaItemType.EntityClass;
|
|
107
117
|
const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;
|
|
108
118
|
return thisSchemaItem.key.matches(key);
|
|
109
119
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItem.js","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAkB,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E;;;GAGG;AACH,MAAM,OAAgB,UAAU;IAO9B,YAAY,MAAc,EAAE,IAAY;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI,KAAK,O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,CAAC,CAAC;QAE5G,2FAA2F;QAC3F,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAC1C,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,cAA0B,EAAE,mBAAgD;QACnG,IAAI,CAAC,mBAAmB;YACtB,OAAO,IAAI,CAAC;QAEd,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACzG,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;MAEE;IACK,MAAM,CAAC,YAAY,CAAC,MAAW;QACpC,MAAM,UAAU,GAAG,MAAoB,CAAC;QAExC,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;eACtF,UAAU,CAAC,cAAc,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,OAAO,CAAC,IAAY;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,YAAoB;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { SchemaItemProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType, schemaItemTypeToXmlString } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { ECVersion, SchemaItemKey } from \"../SchemaKey\";\r\nimport { Schema } from \"./Schema\";\r\n\r\nconst SCHEMAURL3_2 = \"https://dev.bentley.com/json_schemas/ec/32/schemaitem\";\r\n\r\n/**\r\n * An abstract class that supplies all of the common parts of a SchemaItem.\r\n * @beta\r\n */\r\nexport abstract class SchemaItem {\r\n public readonly schemaItemType!: SchemaItemType; // allow the derived classes to define their own schemaItemType\r\n public readonly schema: Schema;\r\n protected _key: SchemaItemKey;\r\n protected _description?: string;\r\n protected _label?: string;\r\n\r\n constructor(schema: Schema, name: string) {\r\n this._key = new SchemaItemKey(name, schema.schemaKey);\r\n this.schema = schema;\r\n }\r\n\r\n public get name() { return this.key.name; }\r\n public get fullName() { return this.key.schemaKey ? `${this.key.schemaName}.${this.name}` : this.name; }\r\n public get key() { return this._key; }\r\n public get label() { return this._label; }\r\n public get description() { return this._description; }\r\n\r\n // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().\r\n /**\r\n * Save this SchemaItem's 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 toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false) {\r\n const itemJson: { [value: string]: any } = {};\r\n if (standalone) {\r\n itemJson.$schema = SCHEMAURL3_2; // $schema is required\r\n itemJson.schema = this.schema.name;\r\n itemJson.name = this.name; // name is required\r\n if (includeSchemaVersion) // check flag to see if we should output version\r\n itemJson.schemaVersion = this.key.schemaKey.version.toString();\r\n }\r\n itemJson.schemaItemType = this.schemaItemType;\r\n if (undefined !== this.label)\r\n itemJson.label = this.label;\r\n if (undefined !== this.description)\r\n itemJson.description = this.description;\r\n\r\n return itemJson as SchemaItemProps;\r\n }\r\n\r\n /** @internal */\r\n public async toXml(schemaXml: Document): Promise<Element> {\r\n const itemType = schemaItemTypeToXmlString(this.schemaItemType);\r\n const itemElement = schemaXml.createElement(itemType);\r\n itemElement.setAttribute(\"typeName\", this.name);\r\n if (undefined !== this.label)\r\n itemElement.setAttribute(\"displayLabel\", this.label);\r\n if (undefined !== this.description)\r\n itemElement.setAttribute(\"description\", this.description);\r\n\r\n // When all schema items support custom attributes they should be added here rather than in ECClass\r\n\r\n return itemElement;\r\n }\r\n\r\n public fromJSONSync(schemaItemProps: SchemaItemProps) {\r\n if (undefined !== schemaItemProps.label)\r\n this._label = schemaItemProps.label;\r\n\r\n this._description = schemaItemProps.description;\r\n\r\n if (undefined !== schemaItemProps.schema) {\r\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}.`);\r\n }\r\n\r\n if (undefined !== schemaItemProps.schemaVersion) {\r\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\r\n }\r\n }\r\n\r\n public async fromJSON(schemaItemProps: SchemaItemProps) {\r\n if (undefined !== schemaItemProps.label)\r\n this._label = schemaItemProps.label;\r\n\r\n this._description = schemaItemProps.description;\r\n\r\n if (undefined !== schemaItemProps.schema) {\r\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem ${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}`);\r\n }\r\n\r\n if (undefined !== schemaItemProps.schemaVersion) {\r\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Parses the given full name, {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}, into two separate strings.\r\n * @note The schema name can be a schema alias.\r\n * @param fullName The full name to be parsed.\r\n * @returns A tuple of the parsed Schema name and Schema Item name. If the full name does not contain a '.' or ':', the second string in the tuple will returned the exact string pass in.\r\n */\r\n public static parseFullName(fullName: string): [string, string] {\r\n const matches = /^([a-zA-Z_]+[a-zA-Z0-9_]*(\\.\\d+\\.\\d+\\.\\d+)?)[.:]([a-zA-Z_]+[a-zA-Z0-9_]*)$/.exec(fullName);\r\n\r\n // The first match will be the full string match, the second three will be the three groups\r\n if (matches === null || matches.length !== 4)\r\n return [\"\", fullName];\r\n\r\n return [matches[1], matches[3]];\r\n }\r\n\r\n /**\r\n * Indicates if the two SchemaItem objects are equal by comparing their respective [[key]] properties.\r\n * @param thisSchemaItem The first SchemaItem.\r\n * @param thatSchemaItemOrKey The second SchemaItem or SchemaItemKey.\r\n */\r\n public static equalByKey(thisSchemaItem: SchemaItem, thatSchemaItemOrKey?: SchemaItem | SchemaItemKey): boolean {\r\n if (!thatSchemaItemOrKey)\r\n return true;\r\n\r\n const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;\r\n return thisSchemaItem.key.matches(key);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static isSchemaItem(object: any): object is SchemaItem {\r\n const schemaItem = object as SchemaItem;\r\n\r\n return schemaItem !== undefined && schemaItem.key !== undefined && schemaItem.schema !== undefined\r\n && schemaItem.schemaItemType !== undefined;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setName(name: string) {\r\n this._key = new SchemaItemKey(name, this.schema.schemaKey);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setDisplayLabel(displayLabel: string) {\r\n this._label = displayLabel;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setDescription(description: string) {\r\n this._description = description;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaItem.js","sourceRoot":"","sources":["../../../src/Metadata/SchemaItem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,yBAAyB,EAA2B,MAAM,cAAc,CAAC;AAC1H,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGxD,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E;;;GAGG;AACH,MAAM,OAAgB,UAAU;IAC9B;;;OAGG;IACI,MAAM,KAAK,cAAc,KAA8B,OAAO,sBAAsB,CAAC,UAAU,CAAA,CAAC,CAAC;IAOxF,MAAM,CAAS;IACrB,IAAI,CAAgB;IACpB,YAAY,CAAU;IACtB,MAAM,CAAU;IAE1B,YAAY,MAAc,EAAE,IAAY;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,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IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAC1C,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,cAA0B,EAAE,mBAAgD;QACnG,IAAI,CAAC,mBAAmB;YACtB,OAAO,IAAI,CAAC;QACd,cAAc,CAAC,WAAW,CAAA;QAC1B,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACzG,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;MAEE;IACK,MAAM,CAAC,YAAY,CAAC,MAAW;QACpC,MAAM,UAAU,GAAG,MAAoB,CAAC;QAExC,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;eACtF,UAAU,CAAC,cAAc,KAAK,SAAS,CAAC;IACtD,CAAC;IAED;;;OAGG;IACO,OAAO,CAAC,IAAY;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,YAAoB;QAC5C,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACO,cAAc,CAAC,WAAmB;QAC1C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;CACF","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 { SchemaItemProps } from \"../Deserialization/JsonProps\";\nimport { AbstractSchemaItemType, SchemaItemType, schemaItemTypeToXmlString, SupportedSchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { ECVersion, SchemaItemKey } from \"../SchemaKey\";\nimport { Schema } from \"./Schema\";\n\nconst SCHEMAURL3_2 = \"https://dev.bentley.com/json_schemas/ec/32/schemaitem\";\n\n/**\n * An abstract class that supplies all of the common parts of a SchemaItem.\n * @beta\n */\nexport abstract class SchemaItem {\n /**\n * Get the type of item represented by this class\n * @beta\n */\n public static get schemaItemType(): SupportedSchemaItemType { return AbstractSchemaItemType.SchemaItem }\n\n /**\n * Get the type of item represented by this instance\n * @beta\n */\n public abstract get schemaItemType(): SchemaItemType;\n public readonly schema: Schema;\n protected _key: SchemaItemKey;\n protected _description?: string;\n protected _label?: string;\n\n constructor(schema: Schema, name: string) {\n this._key = new SchemaItemKey(name, schema.schemaKey);\n this.schema = schema;\n }\n\n public get name() { return this.key.name; }\n public get fullName() { return this.key.schemaKey ? `${this.key.schemaName}.${this.name}` : this.name; }\n public get key() { return this._key; }\n public get label() { return this._label; }\n public get description() { return this._description; }\n\n // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().\n /**\n * Save this SchemaItem's 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 toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false) {\n const itemJson: { [value: string]: any } = {};\n if (standalone) {\n itemJson.$schema = SCHEMAURL3_2; // $schema is required\n itemJson.schema = this.schema.name;\n itemJson.name = this.name; // name is required\n if (includeSchemaVersion) // check flag to see if we should output version\n itemJson.schemaVersion = this.key.schemaKey.version.toString();\n }\n itemJson.schemaItemType = this.schemaItemType;\n if (undefined !== this.label)\n itemJson.label = this.label;\n if (undefined !== this.description)\n itemJson.description = this.description;\n\n return itemJson as SchemaItemProps;\n }\n\n /** @internal */\n public async toXml(schemaXml: Document): Promise<Element> {\n const itemType = schemaItemTypeToXmlString(this.schemaItemType);\n const itemElement = schemaXml.createElement(itemType);\n itemElement.setAttribute(\"typeName\", this.name);\n if (undefined !== this.label)\n itemElement.setAttribute(\"displayLabel\", this.label);\n if (undefined !== this.description)\n itemElement.setAttribute(\"description\", this.description);\n\n // When all schema items support custom attributes they should be added here rather than in ECClass\n\n return itemElement;\n }\n\n public fromJSONSync(schemaItemProps: SchemaItemProps) {\n if (undefined !== schemaItemProps.label)\n this._label = schemaItemProps.label;\n\n this._description = schemaItemProps.description;\n\n if (undefined !== schemaItemProps.schema) {\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}.`);\n }\n\n if (undefined !== schemaItemProps.schemaVersion) {\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\n }\n }\n\n public async fromJSON(schemaItemProps: SchemaItemProps) {\n if (undefined !== schemaItemProps.label)\n this._label = schemaItemProps.label;\n\n this._description = schemaItemProps.description;\n\n if (undefined !== schemaItemProps.schema) {\n if (schemaItemProps.schema.toLowerCase() !== this.schema.name.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem ${this.fullName}' with a different schema name, ${schemaItemProps.schema}, than the current Schema of this SchemaItem, ${this.schema.fullName}`);\n }\n\n if (undefined !== schemaItemProps.schemaVersion) {\n if (this.key.schemaKey.version.compare(ECVersion.fromString(schemaItemProps.schemaVersion)))\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to deserialize the SchemaItem '${this.fullName}' with a different schema version, ${schemaItemProps.schemaVersion}, than the current Schema version of this SchemaItem, ${this.key.schemaKey.version}.`);\n }\n }\n\n /**\n * Parses the given full name, {schemaName}.{schemaItemName} or {schemaName}:{schemaItemName}, into two separate strings.\n * @note The schema name can be a schema alias.\n * @param fullName The full name to be parsed.\n * @returns A tuple of the parsed Schema name and Schema Item name. If the full name does not contain a '.' or ':', the second string in the tuple will returned the exact string pass in.\n */\n public static parseFullName(fullName: string): [string, string] {\n const matches = /^([a-zA-Z_]+[a-zA-Z0-9_]*(\\.\\d+\\.\\d+\\.\\d+)?)[.:]([a-zA-Z_]+[a-zA-Z0-9_]*)$/.exec(fullName);\n\n // The first match will be the full string match, the second three will be the three groups\n if (matches === null || matches.length !== 4)\n return [\"\", fullName];\n\n return [matches[1], matches[3]];\n }\n\n /**\n * Indicates if the two SchemaItem objects are equal by comparing their respective [[key]] properties.\n * @param thisSchemaItem The first SchemaItem.\n * @param thatSchemaItemOrKey The second SchemaItem or SchemaItemKey.\n */\n public static equalByKey(thisSchemaItem: SchemaItem, thatSchemaItemOrKey?: SchemaItem | SchemaItemKey): boolean {\n if (!thatSchemaItemOrKey)\n return true;\n SchemaItemType.EntityClass\n const key = SchemaItem.isSchemaItem(thatSchemaItemOrKey) ? thatSchemaItemOrKey.key : thatSchemaItemOrKey;\n return thisSchemaItem.key.matches(key);\n }\n\n /**\n * @internal\n */\n public static isSchemaItem(object: any): object is SchemaItem {\n const schemaItem = object as SchemaItem;\n\n return schemaItem !== undefined && schemaItem.key !== undefined && schemaItem.schema !== undefined\n && schemaItem.schemaItemType !== undefined;\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setName(name: string) {\n this._key = new SchemaItemKey(name, this.schema.schemaKey);\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setDisplayLabel(displayLabel: string) {\n this._label = displayLabel;\n }\n\n /**\n * @alpha\n * Used for schema editing.\n */\n protected setDescription(description: string) {\n this._description = description;\n }\n}\n\n"]}
|
|
@@ -12,7 +12,8 @@ import { SchemaItem } from "./SchemaItem";
|
|
|
12
12
|
* @beta
|
|
13
13
|
*/
|
|
14
14
|
export declare class Unit extends SchemaItem {
|
|
15
|
-
readonly schemaItemType: SchemaItemType
|
|
15
|
+
readonly schemaItemType: SchemaItemType;
|
|
16
|
+
static get schemaItemType(): SchemaItemType;
|
|
16
17
|
protected _phenomenon?: LazyLoadedPhenomenon;
|
|
17
18
|
protected _unitSystem?: LazyLoadedUnitSystem;
|
|
18
19
|
protected _definition: string;
|
|
@@ -63,6 +64,12 @@ export declare class Unit extends SchemaItem {
|
|
|
63
64
|
* Used for schema editing.
|
|
64
65
|
*/
|
|
65
66
|
protected setDefinition(definition: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Type assertion to check if the SchemaItem is of type Unit.
|
|
69
|
+
* @param item The SchemaItem to check.
|
|
70
|
+
* @returns The item cast to Unit if it is a Unit, undefined otherwise.
|
|
71
|
+
*/
|
|
72
|
+
static assertIsUnit(item?: SchemaItem): asserts item is Unit;
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
75
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unit.d.ts","sourceRoot":"","sources":["../../../src/Metadata/Unit.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG3E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,U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,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7E;;OAEG;WACW,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,IAAI;IAIjD;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,mBAAmB;IAc/G,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IA0BlD,YAAY,CAAC,SAAS,EAAE,mBAAmB;IA8CrC,QAAQ,CAAC,SAAS,EAAE,mBAAmB;IAI7D;;;OAGG;cACa,aAAa,CAAC,UAAU,EAAE,oBAAoB;IAI9D;;;OAGG;cACa,aAAa,CAAC,UAAU,EAAE,oBAAoB;IAI9D;;;OAGG;cACa,aAAa,CAAC,UAAU,EAAE,MAAM;IAIhD;;;;OAIG;WACW,YAAY,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI;CAIpE;AACD;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,IAAI;aACnB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;aAC9D,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;aAC9D,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;aAChD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
package/lib/esm/Metadata/Unit.js
CHANGED
|
@@ -9,16 +9,25 @@ import { DelayedPromiseWithProps } from "../DelayedPromise";
|
|
|
9
9
|
import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
|
|
10
10
|
import { SchemaItemType } from "../ECObjects";
|
|
11
11
|
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
12
|
+
import { Phenomenon } from "./Phenomenon";
|
|
12
13
|
import { SchemaItem } from "./SchemaItem";
|
|
14
|
+
import { UnitSystem } from "./UnitSystem";
|
|
13
15
|
/**
|
|
14
16
|
* An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a
|
|
15
17
|
* first-class concept is to allow the iModel to not be dependent on any hard-coded Units
|
|
16
18
|
* @beta
|
|
17
19
|
*/
|
|
18
20
|
export class Unit extends SchemaItem {
|
|
21
|
+
schemaItemType = Unit.schemaItemType;
|
|
22
|
+
static get schemaItemType() { return SchemaItemType.Unit; }
|
|
23
|
+
_phenomenon;
|
|
24
|
+
_unitSystem;
|
|
25
|
+
_definition;
|
|
26
|
+
_numerator;
|
|
27
|
+
_denominator;
|
|
28
|
+
_offset;
|
|
19
29
|
constructor(schema, name) {
|
|
20
30
|
super(schema, name);
|
|
21
|
-
this.schemaItemType = SchemaItemType.Unit;
|
|
22
31
|
this._definition = "";
|
|
23
32
|
}
|
|
24
33
|
get phenomenon() { return this._phenomenon; }
|
|
@@ -93,7 +102,7 @@ export class Unit extends SchemaItem {
|
|
|
93
102
|
if (!phenomenonSchemaItemKey)
|
|
94
103
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
|
|
95
104
|
this._phenomenon = new DelayedPromiseWithProps(phenomenonSchemaItemKey, async () => {
|
|
96
|
-
const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey);
|
|
105
|
+
const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey, Phenomenon);
|
|
97
106
|
if (undefined === phenom)
|
|
98
107
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);
|
|
99
108
|
return phenom;
|
|
@@ -102,7 +111,7 @@ export class Unit extends SchemaItem {
|
|
|
102
111
|
if (!unitSystemSchemaItemKey)
|
|
103
112
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
|
|
104
113
|
this._unitSystem = new DelayedPromiseWithProps(unitSystemSchemaItemKey, async () => {
|
|
105
|
-
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey);
|
|
114
|
+
const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);
|
|
106
115
|
if (undefined === unitSystem)
|
|
107
116
|
throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);
|
|
108
117
|
return unitSystem;
|
|
@@ -148,6 +157,15 @@ export class Unit extends SchemaItem {
|
|
|
148
157
|
async setDefinition(definition) {
|
|
149
158
|
this._definition = definition;
|
|
150
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Type assertion to check if the SchemaItem is of type Unit.
|
|
162
|
+
* @param item The SchemaItem to check.
|
|
163
|
+
* @returns The item cast to Unit if it is a Unit, undefined otherwise.
|
|
164
|
+
*/
|
|
165
|
+
static assertIsUnit(item) {
|
|
166
|
+
if (!this.isUnit(item))
|
|
167
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Unit}' (Unit)`);
|
|
168
|
+
}
|
|
151
169
|
}
|
|
152
170
|
/**
|
|
153
171
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unit.js","sourceRoot":"","sources":["../../../src/Metadata/Unit.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,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;;;GAIG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IASlC,YAAY,M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AC;QAC1C,CAAC;QAED,IAAI,SAAS,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC;YACxC,IAAI,SAAS,CAAC,WAAW,KAAK,IAAI,CAAC,YAAY;gBAC7C,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC;QAC9C,CAAC;QAED,IAAI,SAAS,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO;gBACnC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC;QACpC,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,SAA8B;QAC3D,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,CAAC,UAAgC;QAC5D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,CAAC,UAAgC;QAC5D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,CAAC,UAAkB;QAC9C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CACF;AACD;;;GAGG;AACH,MAAM,OAAgB,WAAY,SAAQ,IAAI;CAK7C","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 { SchemaItemUnitProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedPhenomenon, LazyLoadedUnitSystem } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { Phenomenon } from \"./Phenomenon\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { UnitSystem } from \"./UnitSystem\";\r\n\r\n/**\r\n * An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a\r\n * first-class concept is to allow the iModel to not be dependent on any hard-coded Units\r\n * @beta\r\n */\r\nexport class Unit extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.Unit;\r\n protected _phenomenon?: LazyLoadedPhenomenon;\r\n protected _unitSystem?: LazyLoadedUnitSystem;\r\n protected _definition: string;\r\n protected _numerator?: number;\r\n protected _denominator?: number;\r\n protected _offset?: number;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.Unit;\r\n this._definition = \"\";\r\n }\r\n\r\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\r\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\r\n public get definition(): string { return this._definition; }\r\n public get numerator(): number { return this._numerator ?? 1.0; }\r\n public get offset(): number { return this._offset ?? 0.0; }\r\n public get denominator(): number { return this._denominator ?? 1.0; }\r\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\r\n public get hasOffset(): boolean { return (this._offset !== undefined); }\r\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\r\n\r\n /**\r\n * Returns true if a conversion can be calculated between the input units\r\n * @alpha\r\n */\r\n public static async areCompatible(unitA: Unit, unitB: Unit): Promise<boolean> {\r\n const unitAPhenomenon = await unitA.phenomenon;\r\n const unitBPhenomenon = await unitB.phenomenon;\r\n\r\n if (!unitAPhenomenon || !unitBPhenomenon || !unitAPhenomenon.key.matches(unitBPhenomenon.key))\r\n return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * @alpha\r\n */\r\n public static isUnit(object: any): object is Unit {\r\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.Unit;\r\n }\r\n\r\n /**\r\n * Save this Unit's 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): SchemaItemUnitProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.phenomenon = this.phenomenon!.fullName;\r\n schemaJson.unitSystem = this.unitSystem!.fullName;\r\n schemaJson.definition = this.definition;\r\n if (this.hasNumerator)\r\n schemaJson.numerator = this.numerator;\r\n if (this.hasDenominator)\r\n schemaJson.denominator = this.denominator;\r\n if (this.hasOffset)\r\n schemaJson.offset = this.offset;\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 const phenomenon = await this.phenomenon;\r\n if (undefined !== phenomenon) {\r\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\r\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\r\n }\r\n\r\n const unitSystem = await this.unitSystem;\r\n if (undefined !== unitSystem) {\r\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\r\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\r\n }\r\n\r\n itemElement.setAttribute(\"definition\", this.definition);\r\n if (this.hasNumerator)\r\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\r\n if (this.hasDenominator)\r\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\r\n if (this.hasOffset)\r\n itemElement.setAttribute(\"offset\", this.offset.toString());\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(unitProps: SchemaItemUnitProps) {\r\n super.fromJSONSync(unitProps);\r\n\r\n const phenomenonSchemaItemKey = this.schema.getSchemaItemKey(unitProps.phenomenon);\r\n if (!phenomenonSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenonSchemaItemKey,\r\n async () => {\r\n const phenom = await this.schema.lookupItem<Phenomenon>(phenomenonSchemaItemKey);\r\n if (undefined === phenom)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n return phenom;\r\n });\r\n\r\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(unitProps.unitSystem);\r\n if (!unitSystemSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\r\n async () => {\r\n const unitSystem = await this.schema.lookupItem<UnitSystem>(unitSystemSchemaItemKey);\r\n if (undefined === unitSystem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n return unitSystem;\r\n });\r\n\r\n if (this._definition !== \"\" && unitProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = unitProps.definition;\r\n\r\n if (undefined !== unitProps.numerator) {\r\n if (unitProps.numerator !== this._numerator)\r\n this._numerator = unitProps.numerator;\r\n }\r\n\r\n if (undefined !== unitProps.denominator) {\r\n if (unitProps.denominator !== this._denominator)\r\n this._denominator = unitProps.denominator;\r\n }\r\n\r\n if (undefined !== unitProps.offset) {\r\n if (unitProps.offset !== this._offset)\r\n this._offset = unitProps.offset;\r\n }\r\n }\r\n\r\n public override async fromJSON(unitProps: SchemaItemUnitProps) {\r\n this.fromJSONSync(unitProps);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\r\n this._phenomenon = phenomenon;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableUnit extends Unit {\r\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;\r\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Unit.js","sourceRoot":"","sources":["../../../src/Metadata/Unit.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,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IACT,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IACvD,MAAM,KAA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["/*---------------------------------------------------------------------------------------------\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 { SchemaItemUnitProps } from \"../Deserialization/JsonProps\";\r\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { LazyLoadedPhenomenon, LazyLoadedUnitSystem } from \"../Interfaces\";\r\nimport { SchemaItemKey } from \"../SchemaKey\";\r\nimport { Phenomenon } from \"./Phenomenon\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\nimport { UnitSystem } from \"./UnitSystem\";\r\n\r\n/**\r\n * An abstract class that adds the ability to define Units and everything that goes with them, within an ECSchema as a\r\n * first-class concept is to allow the iModel to not be dependent on any hard-coded Units\r\n * @beta\r\n */\r\nexport class Unit extends SchemaItem {\r\n public override readonly schemaItemType = Unit.schemaItemType;\r\n public static override get schemaItemType() { return SchemaItemType.Unit; }\r\n protected _phenomenon?: LazyLoadedPhenomenon;\r\n protected _unitSystem?: LazyLoadedUnitSystem;\r\n protected _definition: string;\r\n protected _numerator?: number;\r\n protected _denominator?: number;\r\n protected _offset?: number;\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this._definition = \"\";\r\n }\r\n\r\n public get phenomenon(): LazyLoadedPhenomenon | undefined { return this._phenomenon; }\r\n public get unitSystem(): LazyLoadedUnitSystem | undefined { return this._unitSystem; }\r\n public get definition(): string { return this._definition; }\r\n public get numerator(): number { return this._numerator ?? 1.0; }\r\n public get offset(): number { return this._offset ?? 0.0; }\r\n public get denominator(): number { return this._denominator ?? 1.0; }\r\n public get hasNumerator(): boolean { return (this._numerator !== undefined); }\r\n public get hasOffset(): boolean { return (this._offset !== undefined); }\r\n public get hasDenominator(): boolean { return (this._denominator !== undefined); }\r\n\r\n /**\r\n * Returns true if a conversion can be calculated between the input units\r\n * @alpha\r\n */\r\n public static async areCompatible(unitA: Unit, unitB: Unit): Promise<boolean> {\r\n const unitAPhenomenon = await unitA.phenomenon;\r\n const unitBPhenomenon = await unitB.phenomenon;\r\n\r\n if (!unitAPhenomenon || !unitBPhenomenon || !unitAPhenomenon.key.matches(unitBPhenomenon.key))\r\n return false;\r\n return true;\r\n }\r\n\r\n /**\r\n * @alpha\r\n */\r\n public static isUnit(object: any): object is Unit {\r\n return SchemaItem.isSchemaItem(object) && object.schemaItemType === SchemaItemType.Unit;\r\n }\r\n\r\n /**\r\n * Save this Unit's 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): SchemaItemUnitProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.phenomenon = this.phenomenon!.fullName;\r\n schemaJson.unitSystem = this.unitSystem!.fullName;\r\n schemaJson.definition = this.definition;\r\n if (this.hasNumerator)\r\n schemaJson.numerator = this.numerator;\r\n if (this.hasDenominator)\r\n schemaJson.denominator = this.denominator;\r\n if (this.hasOffset)\r\n schemaJson.offset = this.offset;\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 const phenomenon = await this.phenomenon;\r\n if (undefined !== phenomenon) {\r\n const phenomenonName = XmlSerializationUtils.createXmlTypedName(this.schema, phenomenon.schema, phenomenon.name);\r\n itemElement.setAttribute(\"phenomenon\", phenomenonName);\r\n }\r\n\r\n const unitSystem = await this.unitSystem;\r\n if (undefined !== unitSystem) {\r\n const unitSystemName = XmlSerializationUtils.createXmlTypedName(this.schema, unitSystem.schema, unitSystem.name);\r\n itemElement.setAttribute(\"unitSystem\", unitSystemName);\r\n }\r\n\r\n itemElement.setAttribute(\"definition\", this.definition);\r\n if (this.hasNumerator)\r\n itemElement.setAttribute(\"numerator\", this.numerator.toString());\r\n if (this.hasDenominator)\r\n itemElement.setAttribute(\"denominator\", this.denominator.toString());\r\n if (this.hasOffset)\r\n itemElement.setAttribute(\"offset\", this.offset.toString());\r\n\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(unitProps: SchemaItemUnitProps) {\r\n super.fromJSONSync(unitProps);\r\n\r\n const phenomenonSchemaItemKey = this.schema.getSchemaItemKey(unitProps.phenomenon);\r\n if (!phenomenonSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n this._phenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenonSchemaItemKey,\r\n async () => {\r\n const phenom = await this.schema.lookupItem(phenomenonSchemaItemKey, Phenomenon);\r\n if (undefined === phenom)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the phenomenon ${unitProps.phenomenon}.`);\r\n return phenom;\r\n });\r\n\r\n const unitSystemSchemaItemKey = this.schema.getSchemaItemKey(unitProps.unitSystem);\r\n if (!unitSystemSchemaItemKey)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n this._unitSystem = new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystemSchemaItemKey,\r\n async () => {\r\n const unitSystem = await this.schema.lookupItem(unitSystemSchemaItemKey, UnitSystem);\r\n if (undefined === unitSystem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the unitSystem ${unitProps.unitSystem}.`);\r\n return unitSystem;\r\n });\r\n\r\n if (this._definition !== \"\" && unitProps.definition.toLowerCase() !== this._definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Unit ${this.name} has an invalid 'definition' attribute.`);\r\n else if (this._definition === \"\")\r\n this._definition = unitProps.definition;\r\n\r\n if (undefined !== unitProps.numerator) {\r\n if (unitProps.numerator !== this._numerator)\r\n this._numerator = unitProps.numerator;\r\n }\r\n\r\n if (undefined !== unitProps.denominator) {\r\n if (unitProps.denominator !== this._denominator)\r\n this._denominator = unitProps.denominator;\r\n }\r\n\r\n if (undefined !== unitProps.offset) {\r\n if (unitProps.offset !== this._offset)\r\n this._offset = unitProps.offset;\r\n }\r\n }\r\n\r\n public override async fromJSON(unitProps: SchemaItemUnitProps) {\r\n this.fromJSONSync(unitProps);\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setPhenomenon(phenomenon: LazyLoadedPhenomenon) {\r\n this._phenomenon = phenomenon;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setUnitSystem(unitSystem: LazyLoadedUnitSystem) {\r\n this._unitSystem = unitSystem;\r\n }\r\n\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected async setDefinition(definition: string) {\r\n this._definition = definition;\r\n }\r\n\r\n /**\r\n * Type assertion to check if the SchemaItem is of type Unit.\r\n * @param item The SchemaItem to check.\r\n * @returns The item cast to Unit if it is a Unit, undefined otherwise.\r\n */\r\n public static assertIsUnit(item?: SchemaItem): asserts item is Unit {\r\n if(!this.isUnit(item))\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.Unit}' (Unit)`);\r\n }\r\n}\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutableUnit extends Unit {\r\n public abstract override setPhenomenon(phenomenon: LazyLoadedPhenomenon): Promise<void>;\r\n public abstract override setUnitSystem(unitSystem: LazyLoadedUnitSystem): Promise<void>;\r\n public abstract override setDefinition(definition: string): Promise<void>;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
|
|
@@ -2,14 +2,25 @@
|
|
|
2
2
|
* @module Metadata
|
|
3
3
|
*/
|
|
4
4
|
import { SchemaItemType } from "../ECObjects";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
6
5
|
import { SchemaItem } from "./SchemaItem";
|
|
7
6
|
/**
|
|
8
7
|
* @beta
|
|
9
8
|
*/
|
|
10
9
|
export declare class UnitSystem extends SchemaItem {
|
|
11
|
-
readonly schemaItemType: SchemaItemType
|
|
12
|
-
|
|
10
|
+
readonly schemaItemType: SchemaItemType;
|
|
11
|
+
static get schemaItemType(): SchemaItemType;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if the SchemaItem is of type UnitSystem.
|
|
14
|
+
* @param item The SchemaItem to check.
|
|
15
|
+
* @returns True if the item is a UnitSystem, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
static isUnitSystem(item?: SchemaItem): item is UnitSystem;
|
|
18
|
+
/**
|
|
19
|
+
* Type assertion to check if the SchemaItem is of type UnitSystem.
|
|
20
|
+
* @param item The SchemaItem to check.
|
|
21
|
+
* @returns The item cast to UnitSystem if it is a UnitSystem, undefined otherwise.
|
|
22
|
+
*/
|
|
23
|
+
static assertIsUnitSystem(item?: SchemaItem): asserts item is UnitSystem;
|
|
13
24
|
}
|
|
14
25
|
/**
|
|
15
26
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystem.d.ts","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"UnitSystem.d.ts","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAyB,cAAc,iBAA6B;IACpE,WAA2B,cAAc,mBAAwC;IAEjF;;;;OAIG;WACW,YAAY,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,IAAI,UAAU;IAOjE;;;;OAIG;WACW,kBAAkB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,UAAU;CAIhF;AAED;;;GAGG;AACH,8BAAsB,iBAAkB,SAAQ,UAAU;aAC/B,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -6,14 +6,32 @@
|
|
|
6
6
|
* @module Metadata
|
|
7
7
|
*/
|
|
8
8
|
import { SchemaItemType } from "../ECObjects";
|
|
9
|
+
import { ECObjectsError, ECObjectsStatus } from "../Exception";
|
|
9
10
|
import { SchemaItem } from "./SchemaItem";
|
|
10
11
|
/**
|
|
11
12
|
* @beta
|
|
12
13
|
*/
|
|
13
14
|
export class UnitSystem extends SchemaItem {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
schemaItemType = UnitSystem.schemaItemType;
|
|
16
|
+
static get schemaItemType() { return SchemaItemType.UnitSystem; }
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if the SchemaItem is of type UnitSystem.
|
|
19
|
+
* @param item The SchemaItem to check.
|
|
20
|
+
* @returns True if the item is a UnitSystem, false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
static isUnitSystem(item) {
|
|
23
|
+
if (item && item.schemaItemType === SchemaItemType.UnitSystem)
|
|
24
|
+
return true;
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Type assertion to check if the SchemaItem is of type UnitSystem.
|
|
29
|
+
* @param item The SchemaItem to check.
|
|
30
|
+
* @returns The item cast to UnitSystem if it is a UnitSystem, undefined otherwise.
|
|
31
|
+
*/
|
|
32
|
+
static assertIsUnitSystem(item) {
|
|
33
|
+
if (!this.isUnitSystem(item))
|
|
34
|
+
throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.UnitSystem}' (UnitSystem)`);
|
|
17
35
|
}
|
|
18
36
|
}
|
|
19
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystem.js","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"UnitSystem.js","sourceRoot":"","sources":["../../../src/Metadata/UnitSystem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACf,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;IAC7D,MAAM,KAAc,cAAc,KAAK,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjF;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,IAAiB;QAC1C,IAAI,IAAI,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,UAAU;YAC3D,OAAO,IAAI,CAAC;QAEd,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,kBAAkB,CAAC,IAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;YAC1B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,qBAAqB,EAAE,aAAa,cAAc,CAAC,UAAU,gBAAgB,CAAC,CAAC;IAC5H,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,iBAAkB,SAAQ,UAAU;CAEzD","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 { SchemaItemType } from \"../ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * @beta\n */\nexport class UnitSystem extends SchemaItem {\n public override readonly schemaItemType = UnitSystem.schemaItemType;\n public static override get schemaItemType() { return SchemaItemType.UnitSystem; }\n\n /**\n * Type guard to check if the SchemaItem is of type UnitSystem.\n * @param item The SchemaItem to check.\n * @returns True if the item is a UnitSystem, false otherwise.\n */\n public static isUnitSystem(item?: SchemaItem): item is UnitSystem {\n if (item && item.schemaItemType === SchemaItemType.UnitSystem)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type UnitSystem.\n * @param item The SchemaItem to check.\n * @returns The item cast to UnitSystem if it is a UnitSystem, undefined otherwise.\n */\n public static assertIsUnitSystem(item?: SchemaItem): asserts item is UnitSystem {\n if (!this.isUnitSystem(item))\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.UnitSystem}' (UnitSystem)`);\n }\n}\n\n/**\n * @internal\n * Used for schema editing.\n */\nexport abstract class MutableUnitSystem extends UnitSystem {\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyTypes.js","sourceRoot":"","sources":["../../src/PropertyTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW9D;;GAEG;AACH,MAAM,CAAN,IAAY,YA4BX;AA5BD,WAAY,YAAY;IACtB,mDAA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,OAAO,CAAC,CAAC,KAAK,CAAC,qCAA4B,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAFe,+BAAa,gBAE5B,CAAA;IACD,SAAgB,OAAO,CAAC,CAAe;QACrC,OAAO,CAAC,8BAAsB,CAAC;IACjC,CAAC;IAFe,yBAAO,UAEtB,CAAA;IACD,SAAgB,gBAAgB,CAAC,CAAe;QAC9C,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtB,CAAC;IAFe,kCAAgB,mBAE/B,CAAA;IACD,SAAgB,iBAAiB,CAAC,CAAgB;QAChD,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAFe,mCAAiB,oBAEhC,CAAA;AACH,CAAC,EAzBgB,iBAAiB,KAAjB,iBAAiB,QAyBjC;AAED,YAAY;AACZ,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,IAAI,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC5F,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACtF,IAAI,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC;QACtC,OAAO,oBAAoB,CAAC;IAC9B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;AAChF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"PropertyTypes.js","sourceRoot":"","sources":["../../src/PropertyTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,eA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2B,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAFe,8BAAY,eAE3B,CAAA;IACD,SAAgB,aAAa,CAAC,CAAe;QAC3C,OAAO,CAAC,CAAC,KAAK,CAAC,qCAA4B,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAFe,+BAAa,gBAE5B,CAAA;IACD,SAAgB,OAAO,CAAC,CAAe;QACrC,OAAO,CAAC,8BAAsB,CAAC;IACjC,CAAC;IAFe,yBAAO,UAEtB,CAAA;IACD,SAAgB,gBAAgB,CAAC,CAAe;QAC9C,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtB,CAAC;IAFe,kCAAgB,mBAE/B,CAAA;IACD,SAAgB,iBAAiB,CAAC,CAAgB;QAChD,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAFe,mCAAiB,oBAEhC,CAAA;AACH,CAAC,EAzBgB,iBAAiB,KAAjB,iBAAiB,QAyBjC;AAED,YAAY;AACZ,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,IAAI,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC5F,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;QAClC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACtF,IAAI,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC;QACtC,OAAO,oBAAoB,CAAC;IAC9B,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;AAChF,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 { PrimitiveType } from \"./ECObjects\";\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\n\n/** @beta */\nconst enum PropertyFlags { // eslint-disable-line no-restricted-syntax\n Primitive = 0x01,\n Struct = 0x02,\n Array = 0x04,\n Navigation = 0x08,\n Enumeration = 0x10,\n}\n\n/**\n * @beta\n */\nexport enum PropertyType {\n Struct = 0x02, // PropertyFlags.Struct\n Struct_Array = 0x06, // PropertyFlags.Struct | PropertyFlags.Array\n Navigation = 0x08, // PropertyFlags.Navigation\n Binary = 0x101, // PrimitiveType.Binary\n Binary_Array = 0x105, // PrimitiveType.Binary | PropertyFlags.Array\n Boolean = 0x201, // PrimitiveType.Boolean\n Boolean_Array = 0x205, // PrimitiveType.Boolean | PropertyFlags.Array\n DateTime = 0x301, // PrimitiveType.DateTime\n DateTime_Array = 0x305, // PrimitiveType.DateTime | PropertyFlags.Array\n Double = 0x401, // PrimitiveType.Double\n Double_Array = 0x405, // PrimitiveType.Double | PropertyFlags.Array\n Integer = 0x501, // PrimitiveType.Integer\n Integer_Array = 0x505, // PrimitiveType.Integer | PropertyFlags.Array\n Integer_Enumeration = 0x511, // PrimitiveType.Integer | PropertyFlags.Enumeration\n Integer_Enumeration_Array = 0x515, // PrimitiveType.Integer | PropertyFlags.Enumeration | PropertyFlags.Array\n Long = 0x601, // PrimitiveType.Long\n Long_Array = 0x605, // PrimitiveType.Long | PropertyFlags.Array\n Point2d = 0x701, // PrimitiveType.Point2d\n Point2d_Array = 0x705, // PrimitiveType.Point2d | PropertyFlags.Array\n Point3d = 0x801, // PrimitiveType.Point3d\n Point3d_Array = 0x805, // PrimitiveType.Point3d | PropertyFlags.Array\n String = 0x901, // PrimitiveType.String\n String_Array = 0x905, // PrimitiveType.String | PropertyFlags.Array\n String_Enumeration = 0x911, // PrimitiveType.String | PropertyFlags.Enumeration\n String_Enumeration_Array = 0x915, // PrimitiveType.String | PropertyFlags.Enumeration | PropertyFlags.Array\n IGeometry = 0xA01, // PrimitiveType.IGeometry\n IGeometry_Array = 0xA05, // PrimitiveType.IGeometry | PropertyFlags.Array\n}\n\n/** @beta */\nexport namespace PropertyTypeUtils {\n export function isArray(t: PropertyType) {\n return (t === (PropertyFlags.Array | t));\n }\n export function isPrimitive(t: PropertyType) {\n return (t === (PropertyFlags.Primitive | t));\n }\n export function isStruct(t: PropertyType) {\n return (t === (PropertyFlags.Struct | t));\n }\n export function isNavigation(t: PropertyType) {\n return (t === (PropertyFlags.Navigation | t));\n }\n export function isEnumeration(t: PropertyType) {\n return (t === (PropertyFlags.Enumeration | t));\n }\n export function asArray(t: PropertyType): PropertyType {\n return t | PropertyFlags.Array;\n }\n export function getPrimitiveType(t: PropertyType): PrimitiveType {\n return (0xFF01 & t);\n }\n export function fromPrimitiveType(t: PrimitiveType): PropertyType {\n return t | 0;\n }\n}\n\n/** @beta */\nexport function propertyTypeToString(type: PropertyType) {\n if (PropertyTypeUtils.isPrimitive(type))\n return (PropertyTypeUtils.isArray(type)) ? \"PrimitiveArrayProperty\" : \"PrimitiveProperty\";\n if (PropertyTypeUtils.isStruct(type))\n return (PropertyTypeUtils.isArray(type)) ? \"StructArrayProperty\" : \"StructProperty\";\n if (PropertyTypeUtils.isNavigation(type))\n return \"NavigationProperty\";\n throw new ECObjectsError(ECObjectsStatus.InvalidType, \"Invalid propertyType\");\n}\n"]}
|
|
@@ -24,19 +24,19 @@ export declare class SchemaJsonLocater implements ISchemaLocater {
|
|
|
24
24
|
* @param context The [SchemaContext] used to facilitate schema location.
|
|
25
25
|
* @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
|
|
26
26
|
*/
|
|
27
|
-
getSchema
|
|
27
|
+
getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;
|
|
28
28
|
/**
|
|
29
29
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
30
30
|
* @param schemaKey The SchemaKey describing the schema to get from the cache.
|
|
31
31
|
* @param matchType The match type to use when locating the schema
|
|
32
32
|
*/
|
|
33
|
-
getSchemaInfo(schemaKey:
|
|
33
|
+
getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;
|
|
34
34
|
/** Get a schema by [SchemaKey] synchronously.
|
|
35
35
|
* @param schemaKey The [SchemaKey] that identifies the schema.
|
|
36
36
|
* * @param matchType The [SchemaMatchType] to used for comparing schema versions.
|
|
37
37
|
* @param context The [SchemaContext] used to facilitate schema location.
|
|
38
38
|
* @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.
|
|
39
39
|
*/
|
|
40
|
-
getSchemaSync
|
|
40
|
+
getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=SchemaJsonLocater.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACnC,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,iBAAiB;IAExD;;;;;OAKG;IACU,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACnC,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,iBAAiB;IAExD;;;;;OAKG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7H;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAYrI;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOpH"}
|
|
@@ -10,6 +10,7 @@ import { Schema } from "./Metadata/Schema";
|
|
|
10
10
|
* @beta
|
|
11
11
|
*/
|
|
12
12
|
export class SchemaJsonLocater {
|
|
13
|
+
_getSchema;
|
|
13
14
|
constructor(_getSchema) {
|
|
14
15
|
this._getSchema = _getSchema;
|
|
15
16
|
}
|
|
@@ -21,7 +22,7 @@ export class SchemaJsonLocater {
|
|
|
21
22
|
*/
|
|
22
23
|
async getSchema(schemaKey, matchType, context) {
|
|
23
24
|
await this.getSchemaInfo(schemaKey, matchType, context);
|
|
24
|
-
return
|
|
25
|
+
return context.getCachedSchema(schemaKey, matchType);
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
@@ -47,8 +48,7 @@ export class SchemaJsonLocater {
|
|
|
47
48
|
const schemaProps = this._getSchema(schemaKey.name);
|
|
48
49
|
if (!schemaProps)
|
|
49
50
|
return undefined;
|
|
50
|
-
|
|
51
|
-
return Schema.fromJsonSync(schemaProps, context);
|
|
51
|
+
return Schema.fromJsonSync(schemaProps, context || new SchemaContext());
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
//# sourceMappingURL=SchemaJsonLocater.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;
|
|
1
|
+
{"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACD;IAA3B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { SchemaInfo } from \"./Interfaces\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaKey } from \"./SchemaKey\";\n\n/**\n * Gets the full schema Json for the input schema name or undefined if not found\n * @throws [Error] if the schema is found but json cannot be returned\n * @beta\n */\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\n\n/**\n * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\n * that returns the Schema Json for a given schema name\n * @beta\n */\nexport class SchemaJsonLocater implements ISchemaLocater {\n public constructor(private _getSchema: SchemaPropsGetter) { }\n\n /** Get a schema by [SchemaKey]\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n return context.getCachedSchema(schemaKey, matchType);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\n return schemaInfo;\n\n return undefined;\n }\n\n /** Get a schema by [SchemaKey] synchronously.\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\n }\n}\n"]}
|
package/lib/esm/SchemaKey.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export declare class ECVersion {
|
|
|
10
10
|
private _read;
|
|
11
11
|
private _write;
|
|
12
12
|
private _minor;
|
|
13
|
+
/**
|
|
14
|
+
* Using a version with all zero is invalid
|
|
15
|
+
* for a schema, but it can be used to indicate
|
|
16
|
+
* "no version has been specified" when locating things
|
|
17
|
+
*/
|
|
18
|
+
static readonly NO_VERSION: ECVersion;
|
|
13
19
|
/**
|
|
14
20
|
* The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
|
|
15
21
|
* @param read Can support up to 999.
|
|
@@ -76,7 +82,7 @@ export declare class SchemaKey {
|
|
|
76
82
|
* @param rhs The SchemaKey to compare with
|
|
77
83
|
* @param matchType The match type to use for comparison.
|
|
78
84
|
*/
|
|
79
|
-
matches(rhs:
|
|
85
|
+
matches(rhs: SchemaKey, matchType?: SchemaMatchType): boolean;
|
|
80
86
|
/**
|
|
81
87
|
* Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
|
|
82
88
|
* @param props SchemaKeyProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaKey.d.ts","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAa;IAE3B;;;;;;OAMG;gBACS,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EA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C,GAAG,OAAO;IA2B3F;;;;OAIG;WACW,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS;IAIxD;;OAEG;IACI,MAAM,IAAI,cAAc;CAQhC;AAED;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC;gBAEpB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IAK3C,IAAW,SAAS,cAA8B;IAClD,IAAW,IAAI,WAA8B;IAE7C,IAAW,UAAU,WAAkC;IAEvD,2DAA2D;IAC3D,IAAW,QAAQ,WAAgD;IAEnE;;;OAGG;IAEI,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO;IAUpC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAK9C"}
|
package/lib/esm/SchemaKey.js
CHANGED
|
@@ -12,6 +12,15 @@ import { ECName } from "./ECName";
|
|
|
12
12
|
* @beta
|
|
13
13
|
*/
|
|
14
14
|
export class ECVersion {
|
|
15
|
+
_read = 0;
|
|
16
|
+
_write = 0;
|
|
17
|
+
_minor = 0;
|
|
18
|
+
/**
|
|
19
|
+
* Using a version with all zero is invalid
|
|
20
|
+
* for a schema, but it can be used to indicate
|
|
21
|
+
* "no version has been specified" when locating things
|
|
22
|
+
*/
|
|
23
|
+
static NO_VERSION = new ECVersion(0, 0, 0);
|
|
15
24
|
/**
|
|
16
25
|
* The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
|
|
17
26
|
* @param read Can support up to 999.
|
|
@@ -20,9 +29,6 @@ export class ECVersion {
|
|
|
20
29
|
*
|
|
21
30
|
*/
|
|
22
31
|
constructor(read, write, minor) {
|
|
23
|
-
this._read = 0;
|
|
24
|
-
this._write = 0;
|
|
25
|
-
this._minor = 0;
|
|
26
32
|
if (undefined !== read)
|
|
27
33
|
this._read = read;
|
|
28
34
|
if (undefined !== write)
|
|
@@ -80,6 +86,8 @@ export class ECVersion {
|
|
|
80
86
|
* @beta
|
|
81
87
|
*/
|
|
82
88
|
export class SchemaKey {
|
|
89
|
+
_name;
|
|
90
|
+
_version;
|
|
83
91
|
constructor(name, readOrVersion, writeVersion, minorVersion) {
|
|
84
92
|
this._name = new ECName(name);
|
|
85
93
|
if (readOrVersion !== undefined && typeof (readOrVersion) !== "number")
|
|
@@ -180,6 +188,8 @@ export class SchemaKey {
|
|
|
180
188
|
* @beta
|
|
181
189
|
*/
|
|
182
190
|
export class SchemaItemKey {
|
|
191
|
+
_name;
|
|
192
|
+
_schemaKey;
|
|
183
193
|
constructor(name, schema) {
|
|
184
194
|
this._name = new ECName(name);
|
|
185
195
|
this._schemaKey = schema;
|