@itwin/ecschema-metadata 5.0.0-dev.99 → 5.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.d.ts +3 -3
- package/lib/cjs/Context.d.ts.map +1 -1
- package/lib/cjs/Context.js +6 -6
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/DelayedPromise.d.ts +9 -8
- package/lib/cjs/DelayedPromise.d.ts.map +1 -1
- package/lib/cjs/DelayedPromise.js +2 -2
- package/lib/cjs/DelayedPromise.js.map +1 -1
- package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
- package/lib/cjs/Deserialization/Helper.js +27 -26
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js +150 -150
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +34 -34
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js +3 -3
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js +49 -49
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +6 -11
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.d.ts +2 -2
- package/lib/cjs/ECName.js +4 -4
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.d.ts +23 -11
- package/lib/cjs/ECObjects.d.ts.map +1 -1
- package/lib/cjs/ECObjects.js +47 -24
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.d.ts +4 -4
- package/lib/cjs/Exception.d.ts.map +1 -1
- package/lib/cjs/Exception.js +60 -60
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +30 -34
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/cjs/Metadata/Class.d.ts +107 -19
- package/lib/cjs/Metadata/Class.d.ts.map +1 -1
- package/lib/cjs/Metadata/Class.js +127 -47
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.d.ts +12 -9
- package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
- package/lib/cjs/Metadata/Constant.js +12 -9
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts +5 -3
- package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/CustomAttributeClass.js +7 -5
- package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.d.ts +20 -3
- package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +32 -14
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.d.ts +16 -9
- package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js +20 -13
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.d.ts +32 -24
- package/lib/cjs/Metadata/Format.d.ts.map +1 -1
- package/lib/cjs/Metadata/Format.js +47 -27
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.d.ts +11 -7
- package/lib/cjs/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js +16 -10
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts +24 -15
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +54 -29
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.d.ts +16 -3
- package/lib/cjs/Metadata/Mixin.d.ts.map +1 -1
- package/lib/cjs/Metadata/Mixin.js +20 -7
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js +27 -19
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.d.ts +10 -2
- package/lib/cjs/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/cjs/Metadata/Phenomenon.js +11 -3
- package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
- package/lib/cjs/Metadata/Property.d.ts +46 -28
- package/lib/cjs/Metadata/Property.d.ts.map +1 -1
- package/lib/cjs/Metadata/Property.js +46 -22
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.d.ts +6 -3
- package/lib/cjs/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Metadata/PropertyCategory.js +12 -5
- package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts +48 -25
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +54 -34
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +50 -28
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +64 -42
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.d.ts +10 -19
- package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js +12 -20
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.d.ts +17 -21
- package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
- package/lib/cjs/Metadata/Unit.js +20 -22
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts +3 -1
- package/lib/cjs/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/cjs/Metadata/UnitSystem.js +4 -2
- package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts +11 -11
- package/lib/cjs/PropertyTypes.d.ts.map +1 -1
- package/lib/cjs/PropertyTypes.js +28 -20
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaFormatsProvider.d.ts +39 -0
- package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/SchemaFormatsProvider.js +146 -0
- package/lib/cjs/SchemaFormatsProvider.js.map +1 -0
- package/lib/cjs/SchemaJsonLocater.d.ts +5 -5
- package/lib/cjs/SchemaJsonLocater.js +4 -4
- package/lib/cjs/SchemaJsonLocater.js.map +1 -1
- package/lib/cjs/SchemaKey.d.ts +6 -6
- package/lib/cjs/SchemaKey.d.ts.map +1 -1
- package/lib/cjs/SchemaKey.js +9 -9
- package/lib/cjs/SchemaKey.js.map +1 -1
- package/lib/cjs/SchemaLoader.d.ts +3 -3
- package/lib/cjs/SchemaLoader.js +4 -4
- package/lib/cjs/SchemaLoader.js.map +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/cjs/SchemaPartVisitorDelegate.js +1 -1
- package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/cjs/UnitConversion/Graph.js.map +1 -1
- package/lib/cjs/UnitConversion/Parser.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
- package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +2 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +1 -0
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/cjs/utils/SchemaGraph.js +3 -3
- package/lib/cjs/utils/SchemaGraph.js.map +1 -1
- package/lib/esm/Constants.js.map +1 -1
- package/lib/esm/Context.d.ts +3 -3
- package/lib/esm/Context.d.ts.map +1 -1
- package/lib/esm/Context.js +7 -7
- package/lib/esm/Context.js.map +1 -1
- package/lib/esm/DelayedPromise.d.ts +9 -8
- package/lib/esm/DelayedPromise.d.ts.map +1 -1
- package/lib/esm/DelayedPromise.js +2 -2
- package/lib/esm/DelayedPromise.js.map +1 -1
- package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
- package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
- package/lib/esm/Deserialization/Helper.js +28 -27
- package/lib/esm/Deserialization/Helper.js.map +1 -1
- package/lib/esm/Deserialization/JsonParser.js +151 -151
- package/lib/esm/Deserialization/JsonParser.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +34 -34
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js +3 -3
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/esm/Deserialization/XmlParser.js +50 -50
- package/lib/esm/Deserialization/XmlParser.js.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +0 -5
- package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
- package/lib/esm/Deserialization/XmlSerializationUtils.js +7 -12
- package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/esm/ECName.d.ts +2 -2
- package/lib/esm/ECName.js +5 -5
- package/lib/esm/ECName.js.map +1 -1
- package/lib/esm/ECObjects.d.ts +23 -11
- package/lib/esm/ECObjects.d.ts.map +1 -1
- package/lib/esm/ECObjects.js +48 -25
- package/lib/esm/ECObjects.js.map +1 -1
- package/lib/esm/Exception.d.ts +4 -4
- package/lib/esm/Exception.d.ts.map +1 -1
- package/lib/esm/Exception.js +58 -58
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +30 -34
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/lib/esm/Metadata/Class.d.ts +107 -19
- package/lib/esm/Metadata/Class.d.ts.map +1 -1
- package/lib/esm/Metadata/Class.js +128 -48
- package/lib/esm/Metadata/Class.js.map +1 -1
- package/lib/esm/Metadata/Constant.d.ts +12 -9
- package/lib/esm/Metadata/Constant.d.ts.map +1 -1
- package/lib/esm/Metadata/Constant.js +13 -10
- package/lib/esm/Metadata/Constant.js.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.d.ts +2 -2
- package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.d.ts +5 -3
- package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -1
- package/lib/esm/Metadata/CustomAttributeClass.js +8 -6
- package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.d.ts +20 -3
- package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +33 -15
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/Enumeration.d.ts +16 -9
- package/lib/esm/Metadata/Enumeration.d.ts.map +1 -1
- package/lib/esm/Metadata/Enumeration.js +21 -14
- package/lib/esm/Metadata/Enumeration.js.map +1 -1
- package/lib/esm/Metadata/Format.d.ts +32 -24
- package/lib/esm/Metadata/Format.d.ts.map +1 -1
- package/lib/esm/Metadata/Format.js +48 -28
- package/lib/esm/Metadata/Format.js.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.d.ts +11 -7
- package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -1
- package/lib/esm/Metadata/InvertedUnit.js +17 -11
- package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts +24 -15
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +55 -30
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Mixin.d.ts +16 -3
- package/lib/esm/Metadata/Mixin.d.ts.map +1 -1
- package/lib/esm/Metadata/Mixin.js +21 -8
- package/lib/esm/Metadata/Mixin.js.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.d.ts +12 -12
- package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -1
- package/lib/esm/Metadata/OverrideFormat.js +28 -20
- package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
- package/lib/esm/Metadata/Phenomenon.d.ts +10 -2
- package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -1
- package/lib/esm/Metadata/Phenomenon.js +12 -4
- package/lib/esm/Metadata/Phenomenon.js.map +1 -1
- package/lib/esm/Metadata/Property.d.ts +46 -28
- package/lib/esm/Metadata/Property.d.ts.map +1 -1
- package/lib/esm/Metadata/Property.js +47 -23
- package/lib/esm/Metadata/Property.js.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.d.ts +6 -3
- package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -1
- package/lib/esm/Metadata/PropertyCategory.js +13 -6
- package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.d.ts +48 -25
- package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/esm/Metadata/RelationshipClass.js +55 -35
- package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +50 -28
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +65 -43
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/Metadata/SchemaItem.d.ts +10 -19
- package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
- package/lib/esm/Metadata/SchemaItem.js +13 -21
- package/lib/esm/Metadata/SchemaItem.js.map +1 -1
- package/lib/esm/Metadata/Unit.d.ts +17 -21
- package/lib/esm/Metadata/Unit.d.ts.map +1 -1
- package/lib/esm/Metadata/Unit.js +21 -23
- package/lib/esm/Metadata/Unit.js.map +1 -1
- package/lib/esm/Metadata/UnitSystem.d.ts +3 -1
- package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -1
- package/lib/esm/Metadata/UnitSystem.js +5 -3
- package/lib/esm/Metadata/UnitSystem.js.map +1 -1
- package/lib/esm/PropertyTypes.d.ts +11 -11
- package/lib/esm/PropertyTypes.d.ts.map +1 -1
- package/lib/esm/PropertyTypes.js +29 -21
- package/lib/esm/PropertyTypes.js.map +1 -1
- package/lib/esm/SchemaFormatsProvider.d.ts +39 -0
- package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/esm/SchemaFormatsProvider.js +142 -0
- package/lib/esm/SchemaFormatsProvider.js.map +1 -0
- package/lib/esm/SchemaJsonLocater.d.ts +5 -5
- package/lib/esm/SchemaJsonLocater.js +4 -4
- package/lib/esm/SchemaJsonLocater.js.map +1 -1
- package/lib/esm/SchemaKey.d.ts +6 -6
- package/lib/esm/SchemaKey.d.ts.map +1 -1
- package/lib/esm/SchemaKey.js +10 -10
- package/lib/esm/SchemaKey.js.map +1 -1
- package/lib/esm/SchemaLoader.d.ts +3 -3
- package/lib/esm/SchemaLoader.js +5 -5
- package/lib/esm/SchemaLoader.js.map +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.d.ts +2 -2
- package/lib/esm/SchemaPartVisitorDelegate.js +1 -1
- package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
- package/lib/esm/UnitConversion/Graph.js.map +1 -1
- package/lib/esm/UnitConversion/Parser.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
- package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
- package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +2 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +1 -0
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/lib/esm/utils/SchemaGraph.js +4 -4
- package/lib/esm/utils/SchemaGraph.js.map +1 -1
- package/package.json +8 -6
package/lib/esm/Context.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { SchemaMatchType } from "./ECObjects";
|
|
6
|
-
import {
|
|
6
|
+
import { ECSchemaError, ECSchemaStatus } from "./Exception";
|
|
7
7
|
import { SchemaItem } from "./Metadata/SchemaItem";
|
|
8
8
|
import { SchemaKey } from "./SchemaKey";
|
|
9
9
|
/**
|
|
@@ -53,7 +53,7 @@ export class SchemaCache {
|
|
|
53
53
|
*/
|
|
54
54
|
async addSchemaPromise(schemaInfo, schema, schemaPromise) {
|
|
55
55
|
if (this.schemaExists(schemaInfo.schemaKey))
|
|
56
|
-
throw new
|
|
56
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schemaInfo.schemaKey.toString()}, already exists within this cache.`);
|
|
57
57
|
this._schema.push({ schemaInfo, schema, schemaPromise });
|
|
58
58
|
// This promise is cached and will be awaited when the user requests the full schema.
|
|
59
59
|
// If the promise competes successfully before the user requests the schema it will be removed from the cache
|
|
@@ -69,7 +69,7 @@ export class SchemaCache {
|
|
|
69
69
|
*/
|
|
70
70
|
async addSchema(schema) {
|
|
71
71
|
if (this.schemaExists(schema.schemaKey))
|
|
72
|
-
throw new
|
|
72
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
|
|
73
73
|
this._schema.push({ schemaInfo: schema, schema });
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -78,7 +78,7 @@ export class SchemaCache {
|
|
|
78
78
|
*/
|
|
79
79
|
addSchemaSync(schema) {
|
|
80
80
|
if (this.schemaExists(schema.schemaKey))
|
|
81
|
-
throw new
|
|
81
|
+
throw new ECSchemaError(ECSchemaStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
|
|
82
82
|
this._schema.push({ schemaInfo: schema, schema });
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -128,7 +128,7 @@ export class SchemaCache {
|
|
|
128
128
|
const entry = this.findEntry(schemaKey, matchType);
|
|
129
129
|
if (entry) {
|
|
130
130
|
if (entry.schemaPromise) {
|
|
131
|
-
throw new
|
|
131
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);
|
|
132
132
|
}
|
|
133
133
|
return entry.schema;
|
|
134
134
|
}
|
|
@@ -160,7 +160,7 @@ export class SchemaCache {
|
|
|
160
160
|
* 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.
|
|
161
161
|
*
|
|
162
162
|
* The context is made up of a group of Schema Locators.
|
|
163
|
-
* @
|
|
163
|
+
* @public @preview
|
|
164
164
|
*/
|
|
165
165
|
export class SchemaContext {
|
|
166
166
|
_locaters;
|
|
@@ -224,7 +224,7 @@ export class SchemaContext {
|
|
|
224
224
|
async addSchemaItem(schemaItem) {
|
|
225
225
|
const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);
|
|
226
226
|
if (!schema)
|
|
227
|
-
throw new
|
|
227
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);
|
|
228
228
|
schema.addItem(schemaItem);
|
|
229
229
|
}
|
|
230
230
|
/**
|
package/lib/esm/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAiB,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAgD9C;;GAEG;AACH,MAAM,OAAO,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,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS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AAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC5H,CAAC;IAEH;;;;;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","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 * @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(): Iterable<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(): Iterable<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 {\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 *\r\n * @param schemaNameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param itemNameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param itemConstructor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @examples\r\n * ```typescript\r\n * const schemaItem = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = await this.getSchema(schemaKey, SchemaMatchType.Latest);\r\n\r\n if (!schema)\r\n return undefined;\r\n\r\n if (typeof itemNameOrCtor === \"string\") // Separate schema and item name arguments with/without an itemConstructor\r\n return itemConstructor ? schema.getItem(itemNameOrCtor, itemConstructor) : schema.getItem(itemNameOrCtor);\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItem(schemaNameOrKey, itemNameOrCtor) : schema.lookupItem(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItem(schemaNameOrKey.name, itemNameOrCtor) : schema.getItem(schemaNameOrKey.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 return undefined if the cached schema is partially loaded. Use [[getSchemaItem]] to await until the schema is completely loaded.\r\n *\r\n * @param nameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param nameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param ctor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @example\r\n * ```typescript\r\n * const schemaItem = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): SchemaItem | InstanceType<T> | undefined {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = this.getSchemaSync(schemaKey, SchemaMatchType.Latest);\r\n if (!schema)\r\n return undefined;\r\n\r\n // Separate schema and item name arguments with/without an itemConstructor\r\n if (typeof itemNameOrCtor === \"string\") {\r\n return itemConstructor ? schema.getItemSync(itemNameOrCtor, itemConstructor) : schema.getItemSync(itemNameOrCtor);\r\n }\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItemSync(schemaNameOrKey, itemNameOrCtor) : schema.lookupItemSync(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItemSync(schemaNameOrKey.name, itemNameOrCtor) : schema.getItemSync(schemaNameOrKey.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(): Iterable<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(): Iterable<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,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAiB,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAgD9C;;GAEG;AACH,MAAM,OAAO,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,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAChK,CAAC;IAEO,mBAAmB,C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AAO,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","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 { ECSchemaError, ECSchemaStatus } 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 * @public @preview\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 * @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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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 ECSchemaError(ECSchemaStatus.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(): Iterable<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(): Iterable<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 * @public @preview\r\n */\r\nexport class SchemaContext {\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(): ReadonlyArray<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 ECSchemaError(ECSchemaStatus.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 *\r\n * @param schemaNameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param itemNameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param itemConstructor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @examples\r\n * ```typescript\r\n * const schemaItem = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = await schemaContext.getSchemaItem(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = await schemaContext.getSchemaItem(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = await schemaContext.getSchemaItem(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<InstanceType<T> | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): Promise<SchemaItem | undefined>\r\n public async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = await this.getSchema(schemaKey, SchemaMatchType.Latest);\r\n\r\n if (!schema)\r\n return undefined;\r\n\r\n if (typeof itemNameOrCtor === \"string\") // Separate schema and item name arguments with/without an itemConstructor\r\n return itemConstructor ? schema.getItem(itemNameOrCtor, itemConstructor) : schema.getItem(itemNameOrCtor);\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItem(schemaNameOrKey, itemNameOrCtor) : schema.lookupItem(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItem(schemaNameOrKey.name, itemNameOrCtor) : schema.getItem(schemaNameOrKey.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 return undefined if the cached schema is partially loaded. Use [[getSchemaItem]] to await until the schema is completely loaded.\r\n *\r\n * @param nameOrKey - The SchemaItemKey identifying the item to return or the name of the schema or the schema item full name.\r\n * @param nameOrCtor - The name of the item to return or the constructor of the item to return.\r\n * @param ctor - The constructor of the item to return.\r\n * @returns The requested schema item, or `undefined` if the item could not be found.\r\n *\r\n * @example\r\n * ```typescript\r\n * const schemaItem = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")));\r\n * const schemaItemWithCtor = schemaContext.getSchemaItemSync(new SchemaItemKey(\"TestElement\", new SchemaKey(\"TestSchema\")), EntityClass);\r\n * const schemaItemByName = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\");\r\n * const schemaItemByNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema\", \"TestElement\", EntityClass);\r\n * const schemaItemFullName = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameWithCtor = schemaContext.getSchemaItemSync(\"TestSchema:TestElement\", EntityClass);\r\n * const schemaItemFullNameSep = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * const schemaItemFullNameSepWithCtor = schemaContext.getSchemaItemSync(\"TestSchema.TestElement\", EntityClass);\r\n * ```\r\n */\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): InstanceType<T> | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: string, itemNameOrCtor: string, itemConstructor?: T): SchemaItem | undefined\r\n public getSchemaItemSync<T extends typeof SchemaItem>(schemaNameOrKey: SchemaItemKey | string, itemNameOrCtor?: T | string, itemConstructor?: T): SchemaItem | InstanceType<T> | undefined {\r\n let schemaKey: SchemaKey;\r\n if (typeof schemaNameOrKey === \"string\") {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(schemaNameOrKey);\r\n schemaKey = (!schemaName) ? new SchemaKey(itemName) : new SchemaKey(schemaName);\r\n } else {\r\n schemaKey = schemaNameOrKey.schemaKey;\r\n }\r\n\r\n const schema = this.getSchemaSync(schemaKey, SchemaMatchType.Latest);\r\n if (!schema)\r\n return undefined;\r\n\r\n // Separate schema and item name arguments with/without an itemConstructor\r\n if (typeof itemNameOrCtor === \"string\") {\r\n return itemConstructor ? schema.getItemSync(itemNameOrCtor, itemConstructor) : schema.getItemSync(itemNameOrCtor);\r\n }\r\n\r\n if (typeof schemaNameOrKey === \"string\") // Single schema item full name argument with/without an itemConstructor\r\n return itemNameOrCtor ? schema.lookupItemSync(schemaNameOrKey, itemNameOrCtor) : schema.lookupItemSync(schemaNameOrKey);\r\n\r\n // Schema Item Key with/without an itemConstructor\r\n return itemNameOrCtor ? schema.getItemSync(schemaNameOrKey.name, itemNameOrCtor) : schema.getItemSync(schemaNameOrKey.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(): Iterable<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(): Iterable<Schema> {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* additional (non-lazily-loaded) "nested" properties can be added.
|
|
21
21
|
*
|
|
22
22
|
* [!alert text="*Remember:* Unlike regular Promises in JavaScript, DelayedPromises represent processes that **may not** already be happening." kind="warning"]
|
|
23
|
-
* @
|
|
23
|
+
* @internal
|
|
24
24
|
*/
|
|
25
25
|
export declare class DelayedPromise<T> implements Promise<T> {
|
|
26
26
|
/**
|
|
@@ -54,7 +54,7 @@ export declare class DelayedPromise<T> implements Promise<T> {
|
|
|
54
54
|
finally(onFinally?: (() => void) | undefined | null): Promise<T>;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* @
|
|
57
|
+
* @internal
|
|
58
58
|
*/
|
|
59
59
|
export interface NoDelayedPromiseMethods {
|
|
60
60
|
[propName: string]: any;
|
|
@@ -63,7 +63,7 @@ export interface NoDelayedPromiseMethods {
|
|
|
63
63
|
catch?: never;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* @
|
|
66
|
+
* @internal
|
|
67
67
|
*/
|
|
68
68
|
export interface DelayedPromiseWithPropsConstructor {
|
|
69
69
|
/**
|
|
@@ -76,14 +76,15 @@ export interface DelayedPromiseWithPropsConstructor {
|
|
|
76
76
|
* as if they were readonly properties of the DelayedPromiseWithProps object being constructed.
|
|
77
77
|
* @param startCallback The asynchronous callback to execute when as soon as this DelayedPromise should be "started".
|
|
78
78
|
*/
|
|
79
|
-
new <TProps extends NoDelayedPromiseMethods, TPayload>(props: TProps, startCallback: () => Promise<TPayload>):
|
|
79
|
+
new <TProps extends NoDelayedPromiseMethods, TPayload>(props: TProps, startCallback: () => Promise<TPayload>): TProps & DelayedPromise<TPayload>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* @
|
|
82
|
+
* @internal
|
|
83
83
|
*/
|
|
84
84
|
export declare const DelayedPromiseWithProps: DelayedPromiseWithPropsConstructor;
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
85
|
+
/**
|
|
86
|
+
* Define the type of a DelayedPromiseWithProps instance
|
|
87
|
+
* @internal
|
|
87
88
|
*/
|
|
88
|
-
export type DelayedPromiseWithProps<TProps, TPayload> =
|
|
89
|
+
export type DelayedPromiseWithProps<TProps, TPayload> = TProps & DelayedPromise<TPayload>;
|
|
89
90
|
//# sourceMappingURL=DelayedPromise.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DelayedPromise.d.ts","sourceRoot":"","sources":["../../src/DelayedPromise.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IAElD;;;OAGG;gBACS,aAAa,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;IAS3C,SAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,YAAsB;IAE1D;;OAEG;IACI,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/B;;;;;OAKG;IACU,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CA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BAAuB,CAAC,MAAM,EAAE,QAAQ,IAAI,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* additional (non-lazily-loaded) "nested" properties can be added.
|
|
25
25
|
*
|
|
26
26
|
* [!alert text="*Remember:* Unlike regular Promises in JavaScript, DelayedPromises represent processes that **may not** already be happening." kind="warning"]
|
|
27
|
-
* @
|
|
27
|
+
* @internal
|
|
28
28
|
*/
|
|
29
29
|
export class DelayedPromise {
|
|
30
30
|
/**
|
|
@@ -73,7 +73,7 @@ export class DelayedPromise {
|
|
|
73
73
|
// Because the property getters that wrap `props` are dynamically added, TypeScript isn't aware of them.
|
|
74
74
|
// So by defining this as a class _expression_, we can cast the constructed type to Readonly<TProps> & DelayedPromise<TPayload>
|
|
75
75
|
/**
|
|
76
|
-
* @
|
|
76
|
+
* @internal
|
|
77
77
|
*/
|
|
78
78
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
79
79
|
export const DelayedPromiseWithProps = (class extends DelayedPromise {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DelayedPromise.js","sourceRoot":"","sources":["../../src/DelayedPromise.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,cAAc;IAEzB;;;OAGG;IACH,YAAY,aAA+B;QACzC,IAAI,OAA+B,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE;YACtB,OAAO,GAAG,OAAO,IAAI,aAAa,EAAE,CAAC;YACrC,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;IAED,qGAAqG;IACrF,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,SAAkB,CAAC;IAE1D;;OAEG;IACI,KAAK,CAAmB;IAE/B;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAiC,WAAiF,EAAE,UAAmF;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C;IAED,qGAAqG;IACrF,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,SAAkB,CAAC;IAE1D;;OAEG;IACI,KAAK,CAAmB;IAE/B;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAiC,WAAiF,EAAE,UAAmF;QACtN,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,KAAK,CAAkB,UAAiF;QACnH,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAAC,SAA2C;QAC9D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF;AAgCD,wGAAwG;AACxG,+HAA+H;AAC/H;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAyD,SAAQ,cAAwB;IAC/H,YAAY,KAAa,EAAE,EAA2B;QACpD,KAAK,CAAC,EAAE,CAAC,CAAC;QAEV,MAAM,OAAO,GAAG;YACd,GAAG,EAAE,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;gBACpC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAoB,CAAC,CAAC;YAClF,CAAC;SACF,CAAC;QAEF,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,CAAsC,CAAC;IACxE,CAAC;CACF,CAAuC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utils\r\n */\r\n\r\n/**\r\n * Similar to a normal Promise, a DelayedPromise represents the eventual completion (or failure)\r\n * and resulting value of an asynchronous operation ***that has not yet started***.\r\n *\r\n * The asynchronous operation behind a DelayedPromise will start when any of the following occurs:\r\n * - The DelayedPromise is `await`ed.\r\n * - A callback is attached via `.then()` or `.catch(() => { })`.\r\n * - The asynchronous operation is explicitly started via `.start()`\r\n *\r\n * Just as normal Promises will never return to their pending state once fulfilled or rejected,\r\n * a DelayedPromise will never re-execute its asynchronous operation more than **once**.\r\n *\r\n * Ultimately, a DelayedPromise is nothing more than some syntactic sugar that allows you to\r\n * represent an (asynchronously) lazily-loaded value as an instance property instead of a method.\r\n * You could also accomplish something similar by defining an async function as a property getter.\r\n * However, since a property defined as a DelayedPromise will not start simply by being accessed,\r\n * additional (non-lazily-loaded) \"nested\" properties can be added.\r\n *\r\n * [!alert text=\"*Remember:* Unlike regular Promises in JavaScript, DelayedPromises represent processes that **may not** already be happening.\" kind=\"warning\"]\r\n * @internal\r\n */\r\nexport class DelayedPromise<T> implements Promise<T> {\r\n\r\n /**\r\n * Constructs a DelayedPromise object.\r\n * @param startCallback The asynchronous callback to execute when this DelayedPromise should be \"started\".\r\n */\r\n constructor(startCallback: () => Promise<T>) {\r\n let pending: Promise<T> | undefined;\r\n this.start = async () => {\r\n pending = pending || startCallback();\r\n return pending;\r\n };\r\n }\r\n\r\n // We need this in order to fulfill the Promise interface defined in lib.es2015.symbol.wellknown.d.ts\r\n public readonly [Symbol.toStringTag] = \"Promise\" as const;\r\n\r\n /**\r\n * Explicitly starts the asynchronous operation behind this DelayedPromise (if it hasn't started already).\r\n */\r\n public start: () => Promise<T>;\r\n\r\n /**\r\n * Attaches callbacks for the resolution and/or rejection of the Promise.\r\n * @param onfulfilled The callback to execute when the Promise is resolved.\r\n * @param onrejected The callback to execute when the Promise is rejected.\r\n * @return A Promise for the completion of which ever callback is executed.\r\n */\r\n public async then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2> {\r\n return this.start().then(onfulfilled, onrejected);\r\n }\r\n\r\n /**\r\n * Attaches a callback for only the rejection of the Promise.\r\n * @param onrejected The callback to execute when the Promise is rejected.\r\n * @return A Promise for the completion of the callback.\r\n */\r\n public async catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult> {\r\n return this.start().catch(onrejected);\r\n }\r\n\r\n /**\r\n * Attaches a callback for only the finally clause of the Promise.\r\n * @param onrejected The callback to execute when the Promise is finalized.\r\n * @return A Promise for the completion of the callback.\r\n */\r\n public async finally(onFinally?: (() => void) | undefined | null): Promise<T> {\r\n return this.start().finally(onFinally);\r\n }\r\n}\r\n\r\n// This keeps us from accidentally overriding one of DelayedPromise's methods in the DelayedPromiseWithProps constructor\r\n/**\r\n * @internal\r\n */\r\nexport interface NoDelayedPromiseMethods {\r\n [propName: string]: any;\r\n start?: never;\r\n then?: never;\r\n catch?: never;\r\n}\r\n\r\n// See definition of DelayedPromiseWithProps below\r\n/**\r\n * @internal\r\n */\r\nexport interface DelayedPromiseWithPropsConstructor {\r\n\r\n /**\r\n * Constructs a DelayedPromiseWithProps object, which is at once both:\r\n * - A DelayedPromise object representing the eventual completion (or failure)\r\n * of an asynchronous operation returning a value of type `TPayload`\r\n * - _and_ a readonly \"wrapper\" around an instance of type `TProps`\r\n *\r\n * @param props An object with properties and methods that will be accessible\r\n * as if they were readonly properties of the DelayedPromiseWithProps object being constructed.\r\n * @param startCallback The asynchronous callback to execute when as soon as this DelayedPromise should be \"started\".\r\n */\r\n new <TProps extends NoDelayedPromiseMethods, TPayload>(props: TProps, startCallback: () => Promise<TPayload>): TProps & DelayedPromise<TPayload>; // eslint-disable-line @typescript-eslint/prefer-function-type\r\n}\r\n\r\n// Because the property getters that wrap `props` are dynamically added, TypeScript isn't aware of them.\r\n// So by defining this as a class _expression_, we can cast the constructed type to Readonly<TProps> & DelayedPromise<TPayload>\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const DelayedPromiseWithProps = (class <TProps extends NoDelayedPromiseMethods, TPayload> extends DelayedPromise<TPayload> {\r\n constructor(props: TProps, cb: () => Promise<TPayload>) {\r\n super(cb);\r\n\r\n const handler = {\r\n get: (target: TProps, name: string) => {\r\n return (name in this) ? this[name as keyof this] : target[name as keyof TProps];\r\n },\r\n };\r\n\r\n return new Proxy(props, handler) as TProps & DelayedPromise<TPayload>;\r\n }\r\n}) as DelayedPromiseWithPropsConstructor;\r\n\r\n/* eslint-disable @typescript-eslint/no-redeclare */\r\n\r\n/**\r\n * Define the type of a DelayedPromiseWithProps instance\r\n * @internal\r\n */\r\nexport type DelayedPromiseWithProps<TProps, TPayload> = TProps & DelayedPromise<TPayload>;\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractParser.js","sourceRoot":"","sources":["../../../src/Deserialization/AbstractParser.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAoB/F,gBAAgB;AAChB,MAAM,OAAgB,cAAc;IACxB,cAAc,CAAiB;CAmC1C","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 {\n ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\n NavigationPropertyProps, PhenomenonProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PropertyCategoryProps, RelationshipClassProps,\n SchemaItemFormatProps, SchemaItemUnitProps, SchemaProps, SchemaReferenceProps, StructArrayPropertyProps, StructClassProps, StructPropertyProps, UnitSystemProps,\n} from \"../Deserialization/JsonProps\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\nimport { ECSpecVersion } from \"./Helper\";\n\ntype SchemaItemTuple<T> = Readonly<[string /** Name */, string /** SchemaItemType */, Readonly<T>]>;\ntype PropertyTuple<T> = Readonly<[string /** Name */, string /** Property */, Readonly<T>]>;\n\n/** @internal */\nexport type CustomAttributeProvider = (caClass: CustomAttributeClass) => CustomAttribute;\n\n/** @internal */\nexport type CAProviderTuple = Readonly<[string /** Full Name */, CustomAttributeProvider]>;\n\n/** @internal */\nexport abstract class AbstractParser<TItem = any, TProperty = TItem> {\n protected _ecSpecVersion?: ECSpecVersion;\n\n public abstract parseSchema(): SchemaProps;\n public abstract getReferences(): Iterable<SchemaReferenceProps>;\n\n public abstract getItems(): Iterable<SchemaItemTuple<TItem>>;\n public abstract findItem(itemName: string): SchemaItemTuple<TItem> | undefined;\n\n public abstract parseEntityClass(data: Readonly<TItem>): EntityClassProps;\n public abstract parseMixin(data: Readonly<TItem>): MixinProps;\n public abstract parseStructClass(data: Readonly<TItem>): StructClassProps;\n public abstract parseCustomAttributeClass(data: Readonly<TItem>): CustomAttributeClassProps;\n public abstract parseRelationshipClass(data: Readonly<TItem>): RelationshipClassProps;\n public abstract parseEnumeration(data: Readonly<TItem>): EnumerationProps;\n public abstract parseKindOfQuantity(data: Readonly<TItem>): KindOfQuantityProps;\n public abstract parsePropertyCategory(data: Readonly<TItem>): PropertyCategoryProps;\n public abstract parseUnit(data: Readonly<TItem>): SchemaItemUnitProps;\n public abstract parseInvertedUnit(data: Readonly<TItem>): InvertedUnitProps;\n public abstract parseConstant(data: Readonly<TItem>): ConstantProps;\n public abstract parsePhenomenon(data: Readonly<TItem>): PhenomenonProps;\n public abstract parseFormat(data: Readonly<TItem>): SchemaItemFormatProps;\n public abstract parseUnitSystem(data: Readonly<TItem>): UnitSystemProps;\n\n public abstract getProperties(data: Readonly<TItem>, itemName: string): Iterable<PropertyTuple<TProperty>>;\n public abstract parsePrimitiveProperty(data: Readonly<TProperty>): PrimitivePropertyProps;\n public abstract parseStructProperty(data: Readonly<TProperty>): StructPropertyProps;\n public abstract parsePrimitiveArrayProperty(data: Readonly<TProperty>): PrimitiveArrayPropertyProps;\n public abstract parseStructArrayProperty(data: Readonly<TProperty>): StructArrayPropertyProps;\n public abstract parseNavigationProperty(data: Readonly<TProperty>): NavigationPropertyProps;\n\n public abstract getSchemaCustomAttributeProviders(): Iterable<CAProviderTuple>;\n public abstract getClassCustomAttributeProviders(data: Readonly<TItem>): Iterable<CAProviderTuple>;\n public abstract getPropertyCustomAttributeProviders(data: Readonly<TProperty>): Iterable<CAProviderTuple>;\n public abstract getRelationshipConstraintCustomAttributeProviders(data: Readonly<TItem>): [Iterable<CAProviderTuple> /* source */, Iterable<CAProviderTuple> /* target */];\n public abstract get getECSpecVersion(): ECSpecVersion | undefined;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/prefer-function-type\nexport interface AbstractParserConstructor<TSchema, TItem = any, TProperty = TItem> { new(obj: Readonly<TSchema>): AbstractParser<TItem, TProperty> }\n"]}
|
|
1
|
+
{"version":3,"file":"AbstractParser.js","sourceRoot":"","sources":["../../../src/Deserialization/AbstractParser.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAoB/F,gBAAgB;AAChB,MAAM,OAAgB,cAAc;IACxB,cAAc,CAAiB;CAmC1C","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 {\r\n ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\r\n NavigationPropertyProps, PhenomenonProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PropertyCategoryProps, RelationshipClassProps,\r\n SchemaItemFormatProps, SchemaItemUnitProps, SchemaProps, SchemaReferenceProps, StructArrayPropertyProps, StructClassProps, StructPropertyProps, UnitSystemProps,\r\n} from \"../Deserialization/JsonProps\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { ECSpecVersion } from \"./Helper\";\r\n\r\ntype SchemaItemTuple<T> = Readonly<[string /** Name */, string /** SchemaItemType */, Readonly<T>]>;\r\ntype PropertyTuple<T> = Readonly<[string /** Name */, string /** Property */, Readonly<T>]>;\r\n\r\n/** @internal */\r\nexport type CustomAttributeProvider = (caClass: CustomAttributeClass) => CustomAttribute;\r\n\r\n/** @internal */\r\nexport type CAProviderTuple = Readonly<[string /** Full Name */, CustomAttributeProvider]>;\r\n\r\n/** @internal */\r\nexport abstract class AbstractParser<TItem = any, TProperty = TItem> {\r\n protected _ecSpecVersion?: ECSpecVersion;\r\n\r\n public abstract parseSchema(): SchemaProps;\r\n public abstract getReferences(): Iterable<SchemaReferenceProps>;\r\n\r\n public abstract getItems(): Iterable<SchemaItemTuple<TItem>>;\r\n public abstract findItem(itemName: string): SchemaItemTuple<TItem> | undefined;\r\n\r\n public abstract parseEntityClass(data: Readonly<TItem>): EntityClassProps;\r\n public abstract parseMixin(data: Readonly<TItem>): MixinProps;\r\n public abstract parseStructClass(data: Readonly<TItem>): StructClassProps;\r\n public abstract parseCustomAttributeClass(data: Readonly<TItem>): CustomAttributeClassProps;\r\n public abstract parseRelationshipClass(data: Readonly<TItem>): RelationshipClassProps;\r\n public abstract parseEnumeration(data: Readonly<TItem>): EnumerationProps;\r\n public abstract parseKindOfQuantity(data: Readonly<TItem>): KindOfQuantityProps;\r\n public abstract parsePropertyCategory(data: Readonly<TItem>): PropertyCategoryProps;\r\n public abstract parseUnit(data: Readonly<TItem>): SchemaItemUnitProps;\r\n public abstract parseInvertedUnit(data: Readonly<TItem>): InvertedUnitProps;\r\n public abstract parseConstant(data: Readonly<TItem>): ConstantProps;\r\n public abstract parsePhenomenon(data: Readonly<TItem>): PhenomenonProps;\r\n public abstract parseFormat(data: Readonly<TItem>): SchemaItemFormatProps;\r\n public abstract parseUnitSystem(data: Readonly<TItem>): UnitSystemProps;\r\n\r\n public abstract getProperties(data: Readonly<TItem>, itemName: string): Iterable<PropertyTuple<TProperty>>;\r\n public abstract parsePrimitiveProperty(data: Readonly<TProperty>): PrimitivePropertyProps;\r\n public abstract parseStructProperty(data: Readonly<TProperty>): StructPropertyProps;\r\n public abstract parsePrimitiveArrayProperty(data: Readonly<TProperty>): PrimitiveArrayPropertyProps;\r\n public abstract parseStructArrayProperty(data: Readonly<TProperty>): StructArrayPropertyProps;\r\n public abstract parseNavigationProperty(data: Readonly<TProperty>): NavigationPropertyProps;\r\n\r\n public abstract getSchemaCustomAttributeProviders(): Iterable<CAProviderTuple>;\r\n public abstract getClassCustomAttributeProviders(data: Readonly<TItem>): Iterable<CAProviderTuple>;\r\n public abstract getPropertyCustomAttributeProviders(data: Readonly<TProperty>): Iterable<CAProviderTuple>;\r\n public abstract getRelationshipConstraintCustomAttributeProviders(data: Readonly<TItem>): [Iterable<CAProviderTuple> /* source */, Iterable<CAProviderTuple> /* target */];\r\n public abstract get getECSpecVersion(): ECSpecVersion | undefined;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/prefer-function-type\r\nexport interface AbstractParserConstructor<TSchema, TItem = any, TProperty = TItem> { new(obj: Readonly<TSchema>): AbstractParser<TItem, TProperty> }\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["../../../src/Deserialization/Helper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAA2B,UAAU,
|
|
1
|
+
{"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["../../../src/Deserialization/Helper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAA2B,UAAU,EAAiB,MAAM,eAAe,CA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OG;YACW,cAAc;IAmC5B;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IA+B1B;;;;OAIG;YACW,QAAQ;IAStB;;;;OAIG;IACH,OAAO,CAAC,YAAY;IASpB;;;;OAIG;YACW,kBAAkB;IAehC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;;;OAIG;YACW,YAAY;IAO1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;;OAIG;YACW,gBAAgB;IAS9B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAS5B;;;;OAIG;YACW,UAAU;IAYxB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAatB;;;;;OAKG;YACW,SAAS;IAsBvB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAsBrB;;;;OAIG;YACW,eAAe;IAY7B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;;OAIG;YACW,SAAS;IAavB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAarB;;;;OAIG;YACW,qBAAqB;IAWnC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAWjC;;;;OAIG;YACW,0BAA0B;IAYxC;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;IAatC;;;;;;OAMG;YACW,iBAAiB;IAmD/B;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAkD7B;;;;;OAKG;YACW,YAAY;IAa1B;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;;OAKG;YACW,oBAAoB;IAmBlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;WAYlB,oBAAoB,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO;CAM3E"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { SchemaContext } from "../Context";
|
|
6
6
|
import { parsePrimitiveType, parseSchemaItemType, SchemaItemType, SchemaMatchType } from "../ECObjects";
|
|
7
|
-
import {
|
|
7
|
+
import { ECSchemaError, ECSchemaStatus } from "../Exception";
|
|
8
8
|
import { Schema } from "../Metadata/Schema";
|
|
9
9
|
import { SchemaItem } from "../Metadata/SchemaItem";
|
|
10
10
|
import { ECVersion, SchemaItemKey, SchemaKey } from "../SchemaKey";
|
|
@@ -41,7 +41,7 @@ export class SchemaReadHelper {
|
|
|
41
41
|
// Ensure context matches schema context
|
|
42
42
|
if (schema.context) {
|
|
43
43
|
if (this._context !== schema.context)
|
|
44
|
-
throw new
|
|
44
|
+
throw new ECSchemaError(ECSchemaStatus.DifferentSchemaContexts, "The SchemaContext of the schema must be the same SchemaContext held by the SchemaReadHelper.");
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
schema.setContext(this._context);
|
|
@@ -50,10 +50,11 @@ export class SchemaReadHelper {
|
|
|
50
50
|
// Loads all of the properties on the Schema object
|
|
51
51
|
await schema.fromJSON(this._parser.parseSchema());
|
|
52
52
|
this._schema = schema;
|
|
53
|
-
const
|
|
53
|
+
const schemaInfoReferences = [];
|
|
54
|
+
const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaInfoReferences };
|
|
54
55
|
for (const reference of this._parser.getReferences()) {
|
|
55
56
|
const refKey = new SchemaKey(reference.name, ECVersion.fromString(reference.version));
|
|
56
|
-
|
|
57
|
+
schemaInfoReferences.push({ schemaKey: refKey });
|
|
57
58
|
}
|
|
58
59
|
this._schemaInfo = schemaInfo;
|
|
59
60
|
// Need to add this schema to the context to be able to locate schemaItems within the context.
|
|
@@ -73,7 +74,7 @@ export class SchemaReadHelper {
|
|
|
73
74
|
}
|
|
74
75
|
const cachedSchema = await this._context.getCachedSchema(this._schemaInfo.schemaKey, SchemaMatchType.Latest);
|
|
75
76
|
if (undefined === cachedSchema)
|
|
76
|
-
throw new
|
|
77
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
|
|
77
78
|
return cachedSchema;
|
|
78
79
|
}
|
|
79
80
|
/* Finish loading the rest of the schema */
|
|
@@ -144,7 +145,7 @@ export class SchemaReadHelper {
|
|
|
144
145
|
async loadSchemaReference(schemaInfo, refKey) {
|
|
145
146
|
const refSchema = await this._context.getSchema(refKey, SchemaMatchType.LatestWriteCompatible);
|
|
146
147
|
if (undefined === refSchema)
|
|
147
|
-
throw new
|
|
148
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refKey.name}.${refKey.version.toString()}, of ${schemaInfo.schemaKey.name}`);
|
|
148
149
|
await this._schema.addReference(refSchema);
|
|
149
150
|
const results = this.validateSchemaReferences(this._schema);
|
|
150
151
|
let errorMessage = "";
|
|
@@ -152,7 +153,7 @@ export class SchemaReadHelper {
|
|
|
152
153
|
errorMessage += `${result}\r\n`;
|
|
153
154
|
}
|
|
154
155
|
if (errorMessage) {
|
|
155
|
-
throw new
|
|
156
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `${errorMessage}`);
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
/**
|
|
@@ -163,7 +164,7 @@ export class SchemaReadHelper {
|
|
|
163
164
|
const schemaKey = new SchemaKey(ref.name, ECVersion.fromString(ref.version));
|
|
164
165
|
const refSchema = this._context.getSchemaSync(schemaKey, SchemaMatchType.LatestWriteCompatible);
|
|
165
166
|
if (!refSchema)
|
|
166
|
-
throw new
|
|
167
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${this._schema.schemaKey.name}`);
|
|
167
168
|
this._schema.addReferenceSync(refSchema);
|
|
168
169
|
SchemaGraph.generateGraphSync(this._schema).throwIfCycles();
|
|
169
170
|
const results = this.validateSchemaReferences(this._schema);
|
|
@@ -172,7 +173,7 @@ export class SchemaReadHelper {
|
|
|
172
173
|
errorMessage += `${result}\r\n`;
|
|
173
174
|
}
|
|
174
175
|
if (errorMessage) {
|
|
175
|
-
throw new
|
|
176
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `${errorMessage}`);
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
/**
|
|
@@ -358,7 +359,7 @@ export class SchemaReadHelper {
|
|
|
358
359
|
if (undefined !== schema && -1 !== fullOrQualifiedName.indexOf(":")) {
|
|
359
360
|
const refName = schema.getReferenceNameByAlias(schemaName);
|
|
360
361
|
if (undefined === refName)
|
|
361
|
-
throw new
|
|
362
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not resolve schema alias '${schemaName}' for schema item '${itemName}.`);
|
|
362
363
|
return [refName, itemName];
|
|
363
364
|
}
|
|
364
365
|
return [schemaName, itemName];
|
|
@@ -377,7 +378,7 @@ export class SchemaReadHelper {
|
|
|
377
378
|
const [schemaName, itemName] = SchemaReadHelper.resolveSchemaAndItemName(name, this._schema);
|
|
378
379
|
const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());
|
|
379
380
|
if (undefined === schemaName || 0 === schemaName.length)
|
|
380
|
-
throw new
|
|
381
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);
|
|
381
382
|
if (isInThisSchema) {
|
|
382
383
|
schemaItem = await this._schema.getItem(itemName);
|
|
383
384
|
if (schemaItem)
|
|
@@ -392,11 +393,11 @@ export class SchemaReadHelper {
|
|
|
392
393
|
loadCallBack(schemaItem);
|
|
393
394
|
return schemaItem;
|
|
394
395
|
}
|
|
395
|
-
throw new
|
|
396
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);
|
|
396
397
|
}
|
|
397
398
|
schemaItem = await this._context.getSchemaItem(new SchemaItemKey(itemName, new SchemaKey(schemaName)));
|
|
398
399
|
if (undefined === schemaItem)
|
|
399
|
-
throw new
|
|
400
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);
|
|
400
401
|
return schemaItem;
|
|
401
402
|
}
|
|
402
403
|
/**
|
|
@@ -413,7 +414,7 @@ export class SchemaReadHelper {
|
|
|
413
414
|
const [schemaName, itemName] = SchemaReadHelper.resolveSchemaAndItemName(name, this._schema);
|
|
414
415
|
const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());
|
|
415
416
|
if (undefined === schemaName || schemaName.length === 0)
|
|
416
|
-
throw new
|
|
417
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);
|
|
417
418
|
if (isInThisSchema && undefined === this._schema.getItemSync(itemName)) {
|
|
418
419
|
const foundItem = this._parser.findItem(itemName);
|
|
419
420
|
if (foundItem) {
|
|
@@ -425,11 +426,11 @@ export class SchemaReadHelper {
|
|
|
425
426
|
loadCallBack(schemaItem);
|
|
426
427
|
return schemaItem;
|
|
427
428
|
}
|
|
428
|
-
throw new
|
|
429
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);
|
|
429
430
|
}
|
|
430
431
|
schemaItem = this._context.getSchemaItemSync(new SchemaItemKey(itemName, new SchemaKey(schemaName)));
|
|
431
432
|
if (undefined === schemaItem)
|
|
432
|
-
throw new
|
|
433
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);
|
|
433
434
|
return schemaItem;
|
|
434
435
|
}
|
|
435
436
|
/**
|
|
@@ -733,16 +734,16 @@ export class SchemaReadHelper {
|
|
|
733
734
|
const loadTypeName = async (typeName) => {
|
|
734
735
|
if (undefined === parsePrimitiveType(typeName)) {
|
|
735
736
|
if (SchemaReadHelper.isECSpecVersionNewer(this._parser.getECSpecVersion))
|
|
736
|
-
return
|
|
737
|
+
return ECSchemaStatus.NewerECSpecVersion;
|
|
737
738
|
await this.findSchemaItem(typeName);
|
|
738
739
|
}
|
|
739
|
-
return
|
|
740
|
+
return ECSchemaStatus.Success;
|
|
740
741
|
};
|
|
741
742
|
const lowerCasePropType = propType.toLowerCase();
|
|
742
743
|
switch (lowerCasePropType) {
|
|
743
744
|
case "primitiveproperty":
|
|
744
745
|
const primPropertyProps = this._parser.parsePrimitiveProperty(rawProperty);
|
|
745
|
-
if (await loadTypeName(primPropertyProps.typeName) ===
|
|
746
|
+
if (await loadTypeName(primPropertyProps.typeName) === ECSchemaStatus.NewerECSpecVersion)
|
|
746
747
|
primPropertyProps.typeName = "string";
|
|
747
748
|
const primProp = await classObj.createPrimitiveProperty(propName, primPropertyProps.typeName);
|
|
748
749
|
return this.loadProperty(primProp, primPropertyProps, rawProperty);
|
|
@@ -753,7 +754,7 @@ export class SchemaReadHelper {
|
|
|
753
754
|
return this.loadProperty(structProp, structPropertyProps, rawProperty);
|
|
754
755
|
case "primitivearrayproperty":
|
|
755
756
|
const primArrPropertyProps = this._parser.parsePrimitiveArrayProperty(rawProperty);
|
|
756
|
-
if (await loadTypeName(primArrPropertyProps.typeName) ===
|
|
757
|
+
if (await loadTypeName(primArrPropertyProps.typeName) === ECSchemaStatus.NewerECSpecVersion)
|
|
757
758
|
primArrPropertyProps.typeName = "string";
|
|
758
759
|
const primArrProp = await classObj.createPrimitiveArrayProperty(propName, primArrPropertyProps.typeName);
|
|
759
760
|
return this.loadProperty(primArrProp, primArrPropertyProps, rawProperty);
|
|
@@ -764,7 +765,7 @@ export class SchemaReadHelper {
|
|
|
764
765
|
return this.loadProperty(structArrProp, structArrPropertyProps, rawProperty);
|
|
765
766
|
case "navigationproperty":
|
|
766
767
|
if (classObj.schemaItemType !== SchemaItemType.EntityClass && classObj.schemaItemType !== SchemaItemType.RelationshipClass && classObj.schemaItemType !== SchemaItemType.Mixin)
|
|
767
|
-
throw new
|
|
768
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Navigation Property ${classObj.name}.${propName} is invalid, because only EntityClasses, Mixins, and RelationshipClasses can have NavigationProperties.`);
|
|
768
769
|
const navPropertyProps = this._parser.parseNavigationProperty(rawProperty);
|
|
769
770
|
await this.findSchemaItem(navPropertyProps.relationshipName);
|
|
770
771
|
const navProp = await classObj.createNavigationProperty(propName, navPropertyProps.relationshipName, navPropertyProps.direction);
|
|
@@ -782,16 +783,16 @@ export class SchemaReadHelper {
|
|
|
782
783
|
const loadTypeName = (typeName) => {
|
|
783
784
|
if (undefined === parsePrimitiveType(typeName)) {
|
|
784
785
|
if (SchemaReadHelper.isECSpecVersionNewer(this._parser.getECSpecVersion))
|
|
785
|
-
return
|
|
786
|
+
return ECSchemaStatus.NewerECSpecVersion;
|
|
786
787
|
this.findSchemaItemSync(typeName);
|
|
787
788
|
}
|
|
788
|
-
return
|
|
789
|
+
return ECSchemaStatus.Success;
|
|
789
790
|
};
|
|
790
791
|
const lowerCasePropType = propType.toLowerCase();
|
|
791
792
|
switch (lowerCasePropType) {
|
|
792
793
|
case "primitiveproperty":
|
|
793
794
|
const primPropertyProps = this._parser.parsePrimitiveProperty(rawProperty);
|
|
794
|
-
if (loadTypeName(primPropertyProps.typeName) ===
|
|
795
|
+
if (loadTypeName(primPropertyProps.typeName) === ECSchemaStatus.NewerECSpecVersion)
|
|
795
796
|
primPropertyProps.typeName = "string";
|
|
796
797
|
const primProp = classObj.createPrimitivePropertySync(propName, primPropertyProps.typeName);
|
|
797
798
|
return this.loadPropertySync(primProp, primPropertyProps, rawProperty);
|
|
@@ -802,7 +803,7 @@ export class SchemaReadHelper {
|
|
|
802
803
|
return this.loadPropertySync(structProp, structPropertyProps, rawProperty);
|
|
803
804
|
case "primitivearrayproperty":
|
|
804
805
|
const primArrPropertyProps = this._parser.parsePrimitiveArrayProperty(rawProperty);
|
|
805
|
-
if (loadTypeName(primArrPropertyProps.typeName) ===
|
|
806
|
+
if (loadTypeName(primArrPropertyProps.typeName) === ECSchemaStatus.NewerECSpecVersion)
|
|
806
807
|
primArrPropertyProps.typeName = "string";
|
|
807
808
|
const primArrProp = classObj.createPrimitiveArrayPropertySync(propName, primArrPropertyProps.typeName);
|
|
808
809
|
return this.loadPropertySync(primArrProp, primArrPropertyProps, rawProperty);
|
|
@@ -813,7 +814,7 @@ export class SchemaReadHelper {
|
|
|
813
814
|
return this.loadPropertySync(structArrProp, structArrPropertyProps, rawProperty);
|
|
814
815
|
case "navigationproperty":
|
|
815
816
|
if (classObj.schemaItemType !== SchemaItemType.EntityClass && classObj.schemaItemType !== SchemaItemType.RelationshipClass && classObj.schemaItemType !== SchemaItemType.Mixin)
|
|
816
|
-
throw new
|
|
817
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Navigation Property ${classObj.name}.${propName} is invalid, because only EntityClasses, Mixins, and RelationshipClasses can have NavigationProperties.`);
|
|
817
818
|
const navPropertyProps = this._parser.parseNavigationProperty(rawProperty);
|
|
818
819
|
this.findSchemaItemSync(navPropertyProps.relationshipName);
|
|
819
820
|
const navProp = classObj.createNavigationPropertySync(propName, navPropertyProps.relationshipName, navPropertyProps.direction);
|
|
@@ -865,7 +866,7 @@ export class SchemaReadHelper {
|
|
|
865
866
|
// If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema
|
|
866
867
|
if (caClass && caClass.key.schemaName !== container.schema.name &&
|
|
867
868
|
!container.schema.getReferenceSync(caClass.key.schemaName)) {
|
|
868
|
-
throw new
|
|
869
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to load custom attribute ${caClass.fullName} from container ${container.fullName}, ${caClass.key.schemaName} reference not defined`);
|
|
869
870
|
}
|
|
870
871
|
// Second tuple entry ia a function that provides the CA instance.
|
|
871
872
|
const provider = providerTuple[1];
|