@itwin/ecschema-metadata 5.0.0-dev.8 → 5.0.0-dev.83
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 +46 -1
- package/lib/cjs/Constants.js +20 -20
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +60 -20
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +43 -19
- 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/XmlParser.js +11 -1
- package/lib/cjs/Deserialization/XmlParser.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 +34 -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 +53 -5
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +118 -19
- 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/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 +18 -6
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +29 -9
- 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 +1 -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/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/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.js +6 -3
- 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 +4 -0
- package/lib/cjs/Validation/SchemaWalker.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 +60 -20
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +41 -17
- 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/XmlParser.js +11 -1
- package/lib/esm/Deserialization/XmlParser.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 +32 -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 +53 -5
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +119 -20
- 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/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 +18 -6
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +29 -9
- 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 +1 -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/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/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.js +6 -3
- 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 +4 -0
- package/lib/esm/Validation/SchemaWalker.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
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
# Change Log - @itwin/ecschema-metadata
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 11 Mar 2025 15:27:53 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.10.10
|
|
6
|
+
Tue, 11 Mar 2025 15:25:11 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.10.9
|
|
11
|
+
Tue, 11 Mar 2025 05:17:33 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 4.10.8
|
|
16
|
+
Thu, 06 Mar 2025 14:13:37 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.10.7
|
|
21
|
+
Tue, 18 Feb 2025 17:27:03 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 4.10.6
|
|
26
|
+
Fri, 24 Jan 2025 08:02:40 GMT
|
|
27
|
+
|
|
28
|
+
_Version update only_
|
|
29
|
+
|
|
30
|
+
## 4.10.5
|
|
31
|
+
Tue, 21 Jan 2025 21:56:45 GMT
|
|
32
|
+
|
|
33
|
+
_Version update only_
|
|
34
|
+
|
|
35
|
+
## 4.10.4
|
|
36
|
+
Mon, 13 Jan 2025 14:06:43 GMT
|
|
37
|
+
|
|
38
|
+
_Version update only_
|
|
39
|
+
|
|
40
|
+
## 4.10.3
|
|
41
|
+
Mon, 06 Jan 2025 14:00:13 GMT
|
|
42
|
+
|
|
43
|
+
_Version update only_
|
|
44
|
+
|
|
45
|
+
## 4.10.2
|
|
46
|
+
Thu, 21 Nov 2024 15:22:20 GMT
|
|
47
|
+
|
|
48
|
+
_Version update only_
|
|
4
49
|
|
|
5
50
|
## 4.10.1
|
|
6
51
|
Thu, 14 Nov 2024 18:11:00 GMT
|
package/lib/cjs/Constants.js
CHANGED
|
@@ -9,26 +9,26 @@ exports.ECStringConstants = void 0;
|
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
11
|
class ECStringConstants {
|
|
12
|
+
// Relationship End
|
|
13
|
+
static RELATIONSHIP_END_SOURCE = "Source";
|
|
14
|
+
static RELATIONSHIP_END_TARGET = "Target";
|
|
15
|
+
// Container Type
|
|
16
|
+
static CONTAINERTYPE_SCHEMA = "Schema";
|
|
17
|
+
static CONTAINERTYPE_ENTITYCLASS = "EntityClass";
|
|
18
|
+
static CONTAINERTYPE_CUSTOMATTRIBUTECLASS = "CustomAttributeClass";
|
|
19
|
+
static CONTAINERTYPE_STRUCTCLASS = "StructClass";
|
|
20
|
+
static CONTAINERTYPE_RELATIONSHIPCLASS = "RelationshipClass";
|
|
21
|
+
static CONTAINERTYPE_ANYCLASS = "AnyClass";
|
|
22
|
+
static CONTAINERTYPE_PRIMITIVEPROPERTY = "PrimitiveProperty";
|
|
23
|
+
static CONTAINERTYPE_STRUCTPROPERTY = "StructProperty";
|
|
24
|
+
static CONTAINERTYPE_PRIMITIVEARRAYPROPERTY = "ArrayProperty";
|
|
25
|
+
static CONTAINERTYPE_STRUCTARRAYPROPERTY = "StructArrayProperty";
|
|
26
|
+
static CONTAINERTYPE_NAVIGATIONPROPERTY = "NavigationProperty";
|
|
27
|
+
static CONTAINERTYPE_ANYPROPERTY = "AnyProperty";
|
|
28
|
+
static CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT = "SourceRelationshipConstraint";
|
|
29
|
+
static CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT = "TargetRelationshipConstraint";
|
|
30
|
+
static CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT = "AnyRelationshipConstraint";
|
|
31
|
+
static CONTAINERTYPE_ANY = "Any";
|
|
12
32
|
}
|
|
13
33
|
exports.ECStringConstants = ECStringConstants;
|
|
14
|
-
// Relationship End
|
|
15
|
-
ECStringConstants.RELATIONSHIP_END_SOURCE = "Source";
|
|
16
|
-
ECStringConstants.RELATIONSHIP_END_TARGET = "Target";
|
|
17
|
-
// Container Type
|
|
18
|
-
ECStringConstants.CONTAINERTYPE_SCHEMA = "Schema";
|
|
19
|
-
ECStringConstants.CONTAINERTYPE_ENTITYCLASS = "EntityClass";
|
|
20
|
-
ECStringConstants.CONTAINERTYPE_CUSTOMATTRIBUTECLASS = "CustomAttributeClass";
|
|
21
|
-
ECStringConstants.CONTAINERTYPE_STRUCTCLASS = "StructClass";
|
|
22
|
-
ECStringConstants.CONTAINERTYPE_RELATIONSHIPCLASS = "RelationshipClass";
|
|
23
|
-
ECStringConstants.CONTAINERTYPE_ANYCLASS = "AnyClass";
|
|
24
|
-
ECStringConstants.CONTAINERTYPE_PRIMITIVEPROPERTY = "PrimitiveProperty";
|
|
25
|
-
ECStringConstants.CONTAINERTYPE_STRUCTPROPERTY = "StructProperty";
|
|
26
|
-
ECStringConstants.CONTAINERTYPE_PRIMITIVEARRAYPROPERTY = "ArrayProperty";
|
|
27
|
-
ECStringConstants.CONTAINERTYPE_STRUCTARRAYPROPERTY = "StructArrayProperty";
|
|
28
|
-
ECStringConstants.CONTAINERTYPE_NAVIGATIONPROPERTY = "NavigationProperty";
|
|
29
|
-
ECStringConstants.CONTAINERTYPE_ANYPROPERTY = "AnyProperty";
|
|
30
|
-
ECStringConstants.CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT = "SourceRelationshipConstraint";
|
|
31
|
-
ECStringConstants.CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT = "TargetRelationshipConstraint";
|
|
32
|
-
ECStringConstants.CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT = "AnyRelationshipConstraint";
|
|
33
|
-
ECStringConstants.CONTAINERTYPE_ANY = "Any";
|
|
34
34
|
//# sourceMappingURL=Constants.js.map
|
package/lib/cjs/Constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,MAAa,iBAAiB
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,MAAa,iBAAiB;IAC5B,mBAAmB;IACZ,MAAM,CAAU,uBAAuB,GAAW,QAAQ,CAAC;IAC3D,MAAM,CAAU,uBAAuB,GAAW,QAAQ,CAAC;IAElE,iBAAiB;IACV,MAAM,CAAU,oBAAoB,GAAW,QAAQ,CAAC;IACxD,MAAM,CAAU,yBAAyB,GAAW,aAAa,CAAC;IAClE,MAAM,CAAU,kCAAkC,GAAW,sBAAsB,CAAC;IACpF,MAAM,CAAU,yBAAyB,GAAW,aAAa,CAAC;IAClE,MAAM,CAAU,+BAA+B,GAAW,mBAAmB,CAAC;IAC9E,MAAM,CAAU,sBAAsB,GAAW,UAAU,CAAC;IAE5D,MAAM,CAAU,+BAA+B,GAAW,mBAAmB,CAAC;IAC9E,MAAM,CAAU,4BAA4B,GAAW,gBAAgB,CAAC;IACxE,MAAM,CAAU,oCAAoC,GAAW,eAAe,CAAC;IAC/E,MAAM,CAAU,iCAAiC,GAAW,qBAAqB,CAAC;IAClF,MAAM,CAAU,gCAAgC,GAAW,oBAAoB,CAAC;IAChF,MAAM,CAAU,yBAAyB,GAAW,aAAa,CAAC;IAElE,MAAM,CAAU,0CAA0C,GAAW,8BAA8B,CAAC;IACpG,MAAM,CAAU,0CAA0C,GAAW,8BAA8B,CAAC;IACpG,MAAM,CAAU,uCAAuC,GAAW,2BAA2B,CAAC;IAE9F,MAAM,CAAU,iBAAiB,GAAW,KAAK,CAAC;;AAxB3D,8CAyBC","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\n/**\n * @internal\n */\nexport class ECStringConstants {\n // Relationship End\n public static readonly RELATIONSHIP_END_SOURCE: string = \"Source\";\n public static readonly RELATIONSHIP_END_TARGET: string = \"Target\";\n\n // Container Type\n public static readonly CONTAINERTYPE_SCHEMA: string = \"Schema\";\n public static readonly CONTAINERTYPE_ENTITYCLASS: string = \"EntityClass\";\n public static readonly CONTAINERTYPE_CUSTOMATTRIBUTECLASS: string = \"CustomAttributeClass\";\n public static readonly CONTAINERTYPE_STRUCTCLASS: string = \"StructClass\";\n public static readonly CONTAINERTYPE_RELATIONSHIPCLASS: string = \"RelationshipClass\";\n public static readonly CONTAINERTYPE_ANYCLASS: string = \"AnyClass\";\n\n public static readonly CONTAINERTYPE_PRIMITIVEPROPERTY: string = \"PrimitiveProperty\";\n public static readonly CONTAINERTYPE_STRUCTPROPERTY: string = \"StructProperty\";\n public static readonly CONTAINERTYPE_PRIMITIVEARRAYPROPERTY: string = \"ArrayProperty\";\n public static readonly CONTAINERTYPE_STRUCTARRAYPROPERTY: string = \"StructArrayProperty\";\n public static readonly CONTAINERTYPE_NAVIGATIONPROPERTY: string = \"NavigationProperty\";\n public static readonly CONTAINERTYPE_ANYPROPERTY: string = \"AnyProperty\";\n\n public static readonly CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT: string = \"SourceRelationshipConstraint\";\n public static readonly CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT: string = \"TargetRelationshipConstraint\";\n public static readonly CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT: string = \"AnyRelationshipConstraint\";\n\n public static readonly CONTAINERTYPE_ANY: string = \"Any\";\n}\n"]}
|
package/lib/cjs/Context.d.ts
CHANGED
|
@@ -19,14 +19,14 @@ export interface ISchemaLocater {
|
|
|
19
19
|
* @param matchType how to match key against candidate schemas
|
|
20
20
|
* @param context context for loading schema references
|
|
21
21
|
*/
|
|
22
|
-
getSchema
|
|
22
|
+
getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;
|
|
23
23
|
/**
|
|
24
24
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
25
25
|
* May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.
|
|
26
26
|
* @param schemaKey The SchemaKey describing the schema to get from the cache.
|
|
27
27
|
* @param matchType The match type to use when locating the schema
|
|
28
28
|
*/
|
|
29
|
-
getSchemaInfo(schemaKey:
|
|
29
|
+
getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;
|
|
30
30
|
/**
|
|
31
31
|
* Attempts to get a schema from the locater. Yields undefined if no matching schema is found.
|
|
32
32
|
* For schemas that may have references, construct and call through a SchemaContext instead.
|
|
@@ -34,13 +34,30 @@ export interface ISchemaLocater {
|
|
|
34
34
|
* @param matchType how to match key against candidate schemas
|
|
35
35
|
* @param context context for loading schema references
|
|
36
36
|
*/
|
|
37
|
-
getSchemaSync
|
|
37
|
+
getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
+
* Base interface for types that allow location of items inside a schema
|
|
40
41
|
* @beta
|
|
41
42
|
*/
|
|
42
43
|
export interface ISchemaItemLocater {
|
|
43
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
|
|
46
|
+
* Will await a partially loaded schema then look in it for the requested item.
|
|
47
|
+
* @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
|
|
48
|
+
* @returns The requested schema item.
|
|
49
|
+
*/
|
|
50
|
+
getSchemaItem(schemaItemKey: SchemaItemKey): Promise<SchemaItem | undefined>;
|
|
51
|
+
getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T> | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
|
|
54
|
+
* Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.
|
|
55
|
+
* @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
|
|
56
|
+
* @param itemConstructor The constructor of the item to return.
|
|
57
|
+
* @returns The requested schema item.
|
|
58
|
+
*/
|
|
59
|
+
getSchemaItemSync(schemaItemKey: SchemaItemKey): SchemaItem | undefined;
|
|
60
|
+
getSchemaItemSync<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): InstanceType<T> | undefined;
|
|
44
61
|
}
|
|
45
62
|
/**
|
|
46
63
|
* @internal
|
|
@@ -58,7 +75,7 @@ export declare class SchemaCache implements ISchemaLocater {
|
|
|
58
75
|
* Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.
|
|
59
76
|
* @param schemaKey The key to search for.
|
|
60
77
|
*/
|
|
61
|
-
schemaExists(schemaKey:
|
|
78
|
+
schemaExists(schemaKey: SchemaKey): boolean;
|
|
62
79
|
/**
|
|
63
80
|
* Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.
|
|
64
81
|
* When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache
|
|
@@ -71,30 +88,30 @@ export declare class SchemaCache implements ISchemaLocater {
|
|
|
71
88
|
* Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
|
|
72
89
|
* @param schema The schema to add to the cache.
|
|
73
90
|
*/
|
|
74
|
-
addSchema
|
|
91
|
+
addSchema(schema: Schema): Promise<void>;
|
|
75
92
|
/**
|
|
76
93
|
* Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
|
|
77
94
|
* @param schema The schema to add to the cache.
|
|
78
95
|
*/
|
|
79
|
-
addSchemaSync
|
|
96
|
+
addSchemaSync(schema: Schema): void;
|
|
80
97
|
/**
|
|
81
98
|
* Gets the schema which matches the provided SchemaKey.
|
|
82
99
|
* @param schemaKey The SchemaKey describing the schema to get from the cache.
|
|
83
100
|
* @param matchType The match type to use when locating the schema
|
|
84
101
|
*/
|
|
85
|
-
getSchema
|
|
102
|
+
getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined>;
|
|
86
103
|
/**
|
|
87
104
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
88
105
|
* @param schemaKey The SchemaKey describing the schema to get from the cache.
|
|
89
106
|
* @param matchType The match type to use when locating the schema
|
|
90
107
|
*/
|
|
91
|
-
getSchemaInfo(schemaKey:
|
|
108
|
+
getSchemaInfo(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<SchemaInfo | undefined>;
|
|
92
109
|
/**
|
|
93
110
|
* Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.
|
|
94
111
|
* @param schemaKey The SchemaKey describing the schema to get from the cache.
|
|
95
112
|
* @param matchType The match type to use when locating the schema
|
|
96
113
|
*/
|
|
97
|
-
getSchemaSync
|
|
114
|
+
getSchemaSync(schemaKey: SchemaKey, matchType?: SchemaMatchType): Schema | undefined;
|
|
98
115
|
/**
|
|
99
116
|
* Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.
|
|
100
117
|
* Does not include schema items from schemas that are not completely loaded yet.
|
|
@@ -118,8 +135,27 @@ export declare class SchemaCache implements ISchemaLocater {
|
|
|
118
135
|
export declare class SchemaContext implements ISchemaItemLocater {
|
|
119
136
|
private _locaters;
|
|
120
137
|
private _knownSchemas;
|
|
138
|
+
private _fallbackLocaterDefined;
|
|
121
139
|
constructor();
|
|
140
|
+
get locaters(): ISchemaLocater[];
|
|
141
|
+
/**
|
|
142
|
+
* Adds a locater to the context.
|
|
143
|
+
*
|
|
144
|
+
* If no locaters are defined or a fallback locater is not defined, the new locater is added at the end of the locaters array.
|
|
145
|
+
* If a fallback locater is already defined, the new locater is inserted before the fallback locater.
|
|
146
|
+
*
|
|
147
|
+
* @param locater - The locater to be added.
|
|
148
|
+
*/
|
|
122
149
|
addLocater(locater: ISchemaLocater): void;
|
|
150
|
+
/**
|
|
151
|
+
* Adds a fallback locater to the context.
|
|
152
|
+
*
|
|
153
|
+
* If a fallback locater is already defined, it replaces the existing one.
|
|
154
|
+
* Otherwise, it adds the new locater to the end of the locaters array and marks the fallback locater as defined.
|
|
155
|
+
*
|
|
156
|
+
* @param locater - The locater to be added as a fallback.
|
|
157
|
+
*/
|
|
158
|
+
addFallbackLocater(locater: ISchemaLocater): void;
|
|
123
159
|
/**
|
|
124
160
|
* Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.
|
|
125
161
|
* @param schema The schema to add to this context
|
|
@@ -140,7 +176,7 @@ export declare class SchemaContext implements ISchemaItemLocater {
|
|
|
140
176
|
* Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.
|
|
141
177
|
* @param schemaKey
|
|
142
178
|
*/
|
|
143
|
-
schemaExists(schemaKey:
|
|
179
|
+
schemaExists(schemaKey: SchemaKey): boolean;
|
|
144
180
|
/**
|
|
145
181
|
* Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.
|
|
146
182
|
* When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.
|
|
@@ -155,21 +191,21 @@ export declare class SchemaContext implements ISchemaItemLocater {
|
|
|
155
191
|
* @param matchType Criteria by which to identify potentially matching schemas.
|
|
156
192
|
* @returns the schema matching the input criteria, or `undefined` if no such schema could be located.
|
|
157
193
|
*/
|
|
158
|
-
getSchema
|
|
194
|
+
getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined>;
|
|
159
195
|
/**
|
|
160
196
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
161
197
|
* The fully loaded schema can be gotten later from the context using [[getSchema]].
|
|
162
198
|
* @param schemaKey The SchemaKey describing the schema to get from the cache.
|
|
163
199
|
* @param matchType The match type to use when locating the schema
|
|
164
200
|
*/
|
|
165
|
-
getSchemaInfo(schemaKey:
|
|
201
|
+
getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType): Promise<SchemaInfo | undefined>;
|
|
166
202
|
/** Attempts to obtain a schema from this context that matches the specified criteria.
|
|
167
203
|
* Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.
|
|
168
204
|
* @param schemaKey Identifies the schema to obtain.
|
|
169
205
|
* @param matchType Criteria by which to identify potentially matching schemas.
|
|
170
206
|
* @returns the schema matching the input criteria, or `undefined` if no such schema could be located.
|
|
171
207
|
*/
|
|
172
|
-
getSchemaSync
|
|
208
|
+
getSchemaSync(schemaKey: SchemaKey, matchType?: SchemaMatchType): Schema | undefined;
|
|
173
209
|
/**
|
|
174
210
|
* Attempts to get a Schema from the context's cache.
|
|
175
211
|
* Will await a partially loaded schema then return when it is completely loaded.
|
|
@@ -177,7 +213,7 @@ export declare class SchemaContext implements ISchemaItemLocater {
|
|
|
177
213
|
* @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
|
|
178
214
|
* @internal
|
|
179
215
|
*/
|
|
180
|
-
getCachedSchema
|
|
216
|
+
getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined>;
|
|
181
217
|
/**
|
|
182
218
|
* Attempts to get a Schema from the context's cache.
|
|
183
219
|
* Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.
|
|
@@ -185,21 +221,25 @@ export declare class SchemaContext implements ISchemaItemLocater {
|
|
|
185
221
|
* @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
|
|
186
222
|
* @internal
|
|
187
223
|
*/
|
|
188
|
-
getCachedSchemaSync
|
|
224
|
+
getCachedSchemaSync(schemaKey: SchemaKey, matchType?: SchemaMatchType): Schema | undefined;
|
|
189
225
|
/**
|
|
190
226
|
* Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
|
|
191
227
|
* Will await a partially loaded schema then look in it for the requested item
|
|
192
228
|
* @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
|
|
229
|
+
* @param itemConstructor The constructor of the item to return.
|
|
193
230
|
* @returns The requested schema item
|
|
194
231
|
*/
|
|
195
|
-
getSchemaItem
|
|
232
|
+
getSchemaItem(schemaItemKey: SchemaItemKey): Promise<SchemaItem | undefined>;
|
|
233
|
+
getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T> | undefined>;
|
|
196
234
|
/**
|
|
197
235
|
* Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
|
|
198
|
-
* Will
|
|
199
|
-
* @param schemaItemKey The SchemaItemKey identifying the item to return.
|
|
236
|
+
* Will return undefined if the cached schema is partially loaded. Use [[getSchemaItem]] to await until the schema is completely loaded.
|
|
237
|
+
* @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
|
|
238
|
+
* @param itemConstructor The constructor of the item to return.
|
|
200
239
|
* @returns The requested schema item
|
|
201
240
|
*/
|
|
202
|
-
getSchemaItemSync
|
|
241
|
+
getSchemaItemSync(schemaItemKey: SchemaItemKey): SchemaItem | undefined;
|
|
242
|
+
getSchemaItemSync<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): InstanceType<T> | undefined;
|
|
203
243
|
/**
|
|
204
244
|
* Iterates through the items of each schema known to the context. This includes schemas added to the
|
|
205
245
|
* context using [[SchemaContext.addSchema]]. This does not include schemas that
|
package/lib/cjs/Context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAiB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO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e,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS;IAYpI;;;;;OAKG;IACI,cAAc,IAAI,gBAAgB,CAAC,UAAU,CAAC;IAIrD;;;;;;OAMG;IACI,eAAe,IAAI,MAAM,EAAE;CAGnC"}
|
package/lib/cjs/Context.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaContext = exports.SchemaCache = void 0;
|
|
2
4
|
/*---------------------------------------------------------------------------------------------
|
|
3
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
7
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SchemaContext = exports.SchemaCache = void 0;
|
|
8
8
|
const ECObjects_1 = require("./ECObjects");
|
|
9
9
|
const Exception_1 = require("./Exception");
|
|
10
10
|
/**
|
|
@@ -16,6 +16,7 @@ class SchemaMap extends Array {
|
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
class SchemaCache {
|
|
19
|
+
_schema;
|
|
19
20
|
constructor() {
|
|
20
21
|
this._schema = new SchemaMap();
|
|
21
22
|
}
|
|
@@ -164,13 +165,44 @@ exports.SchemaCache = SchemaCache;
|
|
|
164
165
|
* @beta
|
|
165
166
|
*/
|
|
166
167
|
class SchemaContext {
|
|
168
|
+
_locaters;
|
|
169
|
+
_knownSchemas;
|
|
170
|
+
_fallbackLocaterDefined;
|
|
167
171
|
constructor() {
|
|
168
172
|
this._locaters = [];
|
|
169
173
|
this._knownSchemas = new SchemaCache();
|
|
170
174
|
this._locaters.push(this._knownSchemas);
|
|
175
|
+
this._fallbackLocaterDefined = false;
|
|
171
176
|
}
|
|
177
|
+
get locaters() { return this._locaters; }
|
|
178
|
+
/**
|
|
179
|
+
* Adds a locater to the context.
|
|
180
|
+
*
|
|
181
|
+
* If no locaters are defined or a fallback locater is not defined, the new locater is added at the end of the locaters array.
|
|
182
|
+
* If a fallback locater is already defined, the new locater is inserted before the fallback locater.
|
|
183
|
+
*
|
|
184
|
+
* @param locater - The locater to be added.
|
|
185
|
+
*/
|
|
172
186
|
addLocater(locater) {
|
|
173
|
-
this._locaters.
|
|
187
|
+
const insertIndex = (this._locaters.length === 0 || !this._fallbackLocaterDefined) ? this._locaters.length : this._locaters.length - 1;
|
|
188
|
+
this._locaters.splice(insertIndex, 0, locater);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Adds a fallback locater to the context.
|
|
192
|
+
*
|
|
193
|
+
* If a fallback locater is already defined, it replaces the existing one.
|
|
194
|
+
* Otherwise, it adds the new locater to the end of the locaters array and marks the fallback locater as defined.
|
|
195
|
+
*
|
|
196
|
+
* @param locater - The locater to be added as a fallback.
|
|
197
|
+
*/
|
|
198
|
+
addFallbackLocater(locater) {
|
|
199
|
+
if (this._fallbackLocaterDefined) {
|
|
200
|
+
this._locaters[this._locaters.length - 1] = locater;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this._locaters.push(locater);
|
|
204
|
+
this._fallbackLocaterDefined = true;
|
|
205
|
+
}
|
|
174
206
|
}
|
|
175
207
|
/**
|
|
176
208
|
* Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.
|
|
@@ -278,29 +310,21 @@ class SchemaContext {
|
|
|
278
310
|
getCachedSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
|
|
279
311
|
return this._knownSchemas.getSchemaSync(schemaKey, matchType);
|
|
280
312
|
}
|
|
281
|
-
|
|
282
|
-
* Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
|
|
283
|
-
* Will await a partially loaded schema then look in it for the requested item
|
|
284
|
-
* @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
|
|
285
|
-
* @returns The requested schema item
|
|
286
|
-
*/
|
|
287
|
-
async getSchemaItem(schemaItemKey) {
|
|
313
|
+
async getSchemaItem(schemaItemKey, itemConstructor) {
|
|
288
314
|
const schema = await this.getSchema(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
|
|
289
315
|
if (undefined === schema)
|
|
290
316
|
return undefined;
|
|
291
|
-
|
|
317
|
+
if (undefined === itemConstructor)
|
|
318
|
+
return schema.getItem(schemaItemKey.name);
|
|
319
|
+
return schema.getItem(schemaItemKey.name, itemConstructor);
|
|
292
320
|
}
|
|
293
|
-
|
|
294
|
-
* Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
|
|
295
|
-
* Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.
|
|
296
|
-
* @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
|
|
297
|
-
* @returns The requested schema item
|
|
298
|
-
*/
|
|
299
|
-
getSchemaItemSync(schemaItemKey) {
|
|
321
|
+
getSchemaItemSync(schemaItemKey, itemConstructor) {
|
|
300
322
|
const schema = this.getSchemaSync(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
|
|
301
323
|
if (undefined === schema)
|
|
302
324
|
return undefined;
|
|
303
|
-
|
|
325
|
+
if (undefined === itemConstructor)
|
|
326
|
+
return schema.getItemSync(schemaItemKey.name);
|
|
327
|
+
return schema.getItemSync(schemaItemKey.name, itemConstructor);
|
|
304
328
|
}
|
|
305
329
|
/**
|
|
306
330
|
* Iterates through the items of each schema known to the context. This includes schemas added to the
|
package/lib/cjs/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAM9D;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAuD9C;;GAEG;AACH,MAAa,WAAW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CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAuB,aAA4B;QACzE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,WAAW,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;CACF;AAtLD,sCAsLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass SchemaMap extends Array<SchemaEntry> { }\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface SchemaEntry {\r\n schemaInfo: SchemaInfo;\r\n schema: Schema;\r\n schemaPromise?: Promise<Schema>;\r\n}\r\n\r\n/**\r\n * The interface defines what is needed to be an `ISchemaLocater`.\r\n * A Schema Locater loads the requested schema if it can or returns undefined.\r\n * Schema Locaters should always load the schema on each request and should not hold a cache of schemas.\r\n * Schema locaters should never be used directly to load a schema, they should be added to a `SchemaContext`\r\n * and the context should be used to load schemas. The `SchemaContext` caches schemas and manages schema life time.\r\n * @beta\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): T | undefined;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface ISchemaItemLocater {\r\n getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n private loadedSchemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && !entry.schemaPromise);\r\n }\r\n\r\n private schemaPromiseExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && undefined !== entry.schemaPromise);\r\n }\r\n\r\n private findEntry(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType): SchemaEntry | undefined {\r\n return this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));\r\n }\r\n\r\n private removeSchemaPromise(schemaKey: Readonly<SchemaKey>) {\r\n const entry = this.findEntry(schemaKey, SchemaMatchType.Latest);\r\n if (entry)\r\n entry.schemaPromise = undefined;\r\n }\r\n\r\n private removeEntry(schemaKey: Readonly<SchemaKey>) {\r\n this._schema = this._schema.filter((entry: SchemaEntry) => !entry.schemaInfo.schemaKey.matches(schemaKey));\r\n }\r\n\r\n /**\r\n * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.\r\n * @param schemaKey The key to search for.\r\n */\r\n public schemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n if (this.schemaExists(schemaInfo.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schemaInfo.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo, schema, schemaPromise });\r\n\r\n // This promise is cached and will be awaited when the user requests the full schema.\r\n // If the promise competes successfully before the user requests the schema it will be removed from the cache\r\n // If it fails it will remain in the cache until the user awaits it and handles the error\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n schemaPromise.then(() => {\r\n this.removeSchemaPromise(schemaInfo.schemaKey);\r\n });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema<T extends Schema>(schema: T) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync<T extends Schema>(schema: T) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (!entry)\r\n return undefined;\r\n\r\n if (entry.schemaPromise) {\r\n try {\r\n const schema = await entry.schemaPromise as T;\r\n return schema;\r\n } catch (e) {\r\n this.removeEntry(schemaKey);\r\n throw e;\r\n }\r\n }\r\n\r\n return entry.schema as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<SchemaInfo | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry)\r\n return entry.schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry) {\r\n if (entry.schemaPromise) {\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);\r\n }\r\n return entry.schema as T;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public * getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const entry of this._schema) {\r\n for (const schemaItem of entry.schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * Does not include schemas from schemas that are not completely loaded yet.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Schema[] {\r\n return this._schema.map((entry: SchemaEntry) => entry.schema);\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @beta\r\n */\r\nexport class SchemaContext implements ISchemaItemLocater {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n }\r\n\r\n public addLocater(locater: ISchemaLocater) {\r\n this._locaters.push(locater);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n * @deprecated in 4.0 use ecschema-editing package\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.\r\n * @param schemaKey\r\n */\r\n public schemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return this._knownSchemas.schemaExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.\r\n * Use this method over addSchema when asynchronously loading schemas\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using [[getSchema]].\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType): Promise<SchemaInfo | undefined> {\r\n for (const locater of this._locaters) {\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);\r\n if (undefined !== schemaInfo)\r\n return schemaInfo;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will await a partially loaded schema then return when it is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this._knownSchemas.getSchema<T>(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n return this._knownSchemas.getSchemaSync<T>(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item\r\n */\r\n public async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined> {\r\n const schema = await this.getSchema(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItem<T>(schemaItemKey.name);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item\r\n */\r\n public getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined {\r\n const schema = this.getSchemaSync(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItemSync<T>(schemaItemKey.name);\r\n }\r\n\r\n /**\r\n * Iterates through the items of each schema known to the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context. Does not\r\n * include schemas that are partially loaded.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Schema[] {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,2CAA8C;AAC9C,2CAA8D;AAM9D;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAyE9C;;GAEG;AACH,MAAa,WAAW;IACd,OAAO,CAAY;IAE3B;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1C,kBAAkB,CAAC,SAAoB;QAC7C,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,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CACF;AAlOD,sCAkOC","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\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass SchemaMap extends Array<SchemaEntry> { }\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface SchemaEntry {\r\n schemaInfo: SchemaInfo;\r\n schema: Schema;\r\n schemaPromise?: Promise<Schema>;\r\n}\r\n\r\n/**\r\n * The interface defines what is needed to be an `ISchemaLocater`.\r\n * A Schema Locater loads the requested schema if it can or returns undefined.\r\n * Schema Locaters should always load the schema on each request and should not hold a cache of schemas.\r\n * Schema locaters should never be used directly to load a schema, they should be added to a `SchemaContext`\r\n * and the context should be used to load schemas. The `SchemaContext` caches schemas and manages schema life time.\r\n * @beta\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;\r\n}\r\n\r\n/**\r\n * Base interface for types that allow location of items inside a schema\r\n * @beta\r\n */\r\nexport interface ISchemaItemLocater {\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item.\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item.\r\n */\r\n getSchemaItem(schemaItemKey: SchemaItemKey): Promise<SchemaItem | undefined>;\r\n getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T> | undefined>;\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @param itemConstructor The constructor of the item to return.\r\n * @returns The requested schema item.\r\n */\r\n getSchemaItemSync(schemaItemKey: SchemaItemKey): SchemaItem | undefined;\r\n getSchemaItemSync<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): InstanceType<T> | undefined;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n private loadedSchemaExists(schemaKey: SchemaKey): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && !entry.schemaPromise);\r\n }\r\n\r\n private schemaPromiseExists(schemaKey: SchemaKey): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && undefined !== entry.schemaPromise);\r\n }\r\n\r\n private findEntry(schemaKey: SchemaKey, matchType: SchemaMatchType): SchemaEntry | undefined {\r\n return this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));\r\n }\r\n\r\n private removeSchemaPromise(schemaKey: SchemaKey) {\r\n const entry = this.findEntry(schemaKey, SchemaMatchType.Latest);\r\n if (entry)\r\n entry.schemaPromise = undefined;\r\n }\r\n\r\n private removeEntry(schemaKey: SchemaKey) {\r\n this._schema = this._schema.filter((entry: SchemaEntry) => !entry.schemaInfo.schemaKey.matches(schemaKey));\r\n }\r\n\r\n /**\r\n * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.\r\n * @param schemaKey The key to search for.\r\n */\r\n public schemaExists(schemaKey: SchemaKey): boolean {\r\n return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n if (this.schemaExists(schemaInfo.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schemaInfo.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo, schema, schemaPromise });\r\n\r\n // This promise is cached and will be awaited when the user requests the full schema.\r\n // If the promise competes successfully before the user requests the schema it will be removed from the cache\r\n // If it fails it will remain in the cache until the user awaits it and handles the error\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n schemaPromise.then(() => {\r\n this.removeSchemaPromise(schemaInfo.schemaKey);\r\n });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema(schema: Schema) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (!entry)\r\n return undefined;\r\n\r\n if (entry.schemaPromise) {\r\n try {\r\n const schema = await entry.schemaPromise;\r\n return schema;\r\n } catch (e) {\r\n this.removeEntry(schemaKey);\r\n throw e;\r\n }\r\n }\r\n\r\n return entry.schema;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<SchemaInfo | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry)\r\n return entry.schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry) {\r\n if (entry.schemaPromise) {\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);\r\n }\r\n return entry.schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public * getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const entry of this._schema) {\r\n for (const schemaItem of entry.schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * Does not include schemas from schemas that are not completely loaded yet.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Schema[] {\r\n return this._schema.map((entry: SchemaEntry) => entry.schema);\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @beta\r\n */\r\nexport class SchemaContext implements ISchemaItemLocater {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n private _fallbackLocaterDefined: boolean;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n this._fallbackLocaterDefined = false;\r\n }\r\n\r\n public get locaters(): ISchemaLocater[] { return this._locaters; }\r\n\r\n /**\r\n * Adds a locater to the context.\r\n *\r\n * If no locaters are defined or a fallback locater is not defined, the new locater is added at the end of the locaters array.\r\n * If a fallback locater is already defined, the new locater is inserted before the fallback locater.\r\n *\r\n * @param locater - The locater to be added.\r\n */\r\n public addLocater(locater: ISchemaLocater) {\r\n const insertIndex = (this._locaters.length === 0 || !this._fallbackLocaterDefined) ? this._locaters.length : this._locaters.length - 1;\r\n this._locaters.splice(insertIndex, 0, locater);\r\n }\r\n\r\n /**\r\n * Adds a fallback locater to the context.\r\n *\r\n * If a fallback locater is already defined, it replaces the existing one.\r\n * Otherwise, it adds the new locater to the end of the locaters array and marks the fallback locater as defined.\r\n *\r\n * @param locater - The locater to be added as a fallback.\r\n */\r\n public addFallbackLocater(locater: ISchemaLocater) {\r\n if (this._fallbackLocaterDefined) {\r\n this._locaters[this._locaters.length - 1] = locater;\r\n } else {\r\n this._locaters.push(locater);\r\n this._fallbackLocaterDefined = true;\r\n }\r\n }\r\n\r\n /**\r\n * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n * @deprecated in 4.0 use ecschema-editing package\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.\r\n * @param schemaKey\r\n */\r\n public schemaExists(schemaKey: SchemaKey): boolean {\r\n return this._knownSchemas.schemaExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.\r\n * Use this method over addSchema when asynchronously loading schemas\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using [[getSchema]].\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType): Promise<SchemaInfo | undefined> {\r\n for (const locater of this._locaters) {\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);\r\n if (undefined !== schemaInfo)\r\n return schemaInfo;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will await a partially loaded schema then return when it is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<Schema | undefined> {\r\n return this._knownSchemas.getSchema(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n return this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @param itemConstructor The constructor of the item to return.\r\n * @returns The requested schema item\r\n */\r\n public async getSchemaItem(schemaItemKey: SchemaItemKey): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n const schema = await this.getSchema(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n\r\n if(undefined === itemConstructor)\r\n return schema.getItem(schemaItemKey.name);\r\n\r\n return schema.getItem(schemaItemKey.name, itemConstructor);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will return undefined if the cached schema is partially loaded. Use [[getSchemaItem]] to await until the schema is completely loaded.\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @param itemConstructor The constructor of the item to return.\r\n * @returns The requested schema item\r\n */\r\n public getSchemaItemSync(schemaItemKey: SchemaItemKey): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaItemKey: SchemaItemKey, itemConstructor?: T): SchemaItem | InstanceType<T> | undefined {\r\n const schema = this.getSchemaSync(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n\r\n if(undefined === itemConstructor)\r\n return schema.getItemSync(schemaItemKey.name);\r\n\r\n return schema.getItemSync(schemaItemKey.name, itemConstructor);\r\n }\r\n\r\n /**\r\n * Iterates through the items of each schema known to the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context. Does not\r\n * include schemas that are partially loaded.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Schema[] {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Utils
|
|
8
8
|
*/
|
|
9
|
-
var _a;
|
|
10
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
10
|
exports.DelayedPromiseWithProps = exports.DelayedPromise = void 0;
|
|
12
11
|
/**
|
|
@@ -36,14 +35,18 @@ class DelayedPromise {
|
|
|
36
35
|
* @param startCallback The asynchronous callback to execute when this DelayedPromise should be "started".
|
|
37
36
|
*/
|
|
38
37
|
constructor(startCallback) {
|
|
39
|
-
// We need this in order to fulfill the Promise interface defined in lib.es2015.symbol.wellknown.d.ts
|
|
40
|
-
this[_a] = "Promise";
|
|
41
38
|
let pending;
|
|
42
39
|
this.start = async () => {
|
|
43
40
|
pending = pending || startCallback();
|
|
44
41
|
return pending;
|
|
45
42
|
};
|
|
46
43
|
}
|
|
44
|
+
// We need this in order to fulfill the Promise interface defined in lib.es2015.symbol.wellknown.d.ts
|
|
45
|
+
[Symbol.toStringTag] = "Promise";
|
|
46
|
+
/**
|
|
47
|
+
* Explicitly starts the asynchronous operation behind this DelayedPromise (if it hasn't started already).
|
|
48
|
+
*/
|
|
49
|
+
start;
|
|
47
50
|
/**
|
|
48
51
|
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
49
52
|
* @param onfulfilled The callback to execute when the Promise is resolved.
|
|
@@ -71,7 +74,6 @@ class DelayedPromise {
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
exports.DelayedPromise = DelayedPromise;
|
|
74
|
-
_a = Symbol.toStringTag;
|
|
75
77
|
// Because the property getters that wrap `props` are dynamically added, TypeScript isn't aware of them.
|
|
76
78
|
// So by defining this as a class _expression_, we can cast the constructed type to Readonly<TProps> & DelayedPromise<TPayload>
|
|
77
79
|
/**
|