@itwin/ecschema-metadata 4.6.0-dev.21 → 4.6.0-dev.23
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/lib/cjs/Constants.js +1 -1
- package/lib/cjs/Constants.js.map +1 -1
- package/lib/cjs/Context.js +1 -1
- package/lib/cjs/Context.js.map +1 -1
- package/lib/cjs/Deserialization/Helper.js.map +1 -1
- package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
- package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
- package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
- package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
- package/lib/cjs/ECName.js.map +1 -1
- package/lib/cjs/ECObjects.js +8 -8
- package/lib/cjs/ECObjects.js.map +1 -1
- package/lib/cjs/Exception.js +1 -1
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Metadata/Class.js.map +1 -1
- package/lib/cjs/Metadata/Constant.js.map +1 -1
- package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +2 -2
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/Enumeration.js.map +1 -1
- package/lib/cjs/Metadata/Format.js.map +1 -1
- package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Mixin.js.map +1 -1
- package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
- package/lib/cjs/Metadata/Property.js.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Metadata/RelationshipClass.js +2 -1
- package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
- package/lib/cjs/Metadata/Unit.js.map +1 -1
- package/lib/cjs/PropertyTypes.d.ts +26 -26
- package/lib/cjs/PropertyTypes.d.ts.map +1 -1
- package/lib/cjs/PropertyTypes.js +2 -2
- package/lib/cjs/PropertyTypes.js.map +1 -1
- package/lib/cjs/SchemaKey.js.map +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 +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/utils/SchemaGraph.js.map +1 -1
- package/package.json +8 -8
package/lib/cjs/Constants.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.ECStringConstants = void 0;
|
|
|
10
10
|
*/
|
|
11
11
|
class ECStringConstants {
|
|
12
12
|
}
|
|
13
|
+
exports.ECStringConstants = ECStringConstants;
|
|
13
14
|
// Relationship End
|
|
14
15
|
ECStringConstants.RELATIONSHIP_END_SOURCE = "Source";
|
|
15
16
|
ECStringConstants.RELATIONSHIP_END_TARGET = "Target";
|
|
@@ -30,5 +31,4 @@ ECStringConstants.CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT = "SourceRelationsh
|
|
|
30
31
|
ECStringConstants.CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT = "TargetRelationshipConstraint";
|
|
31
32
|
ECStringConstants.CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT = "AnyRelationshipConstraint";
|
|
32
33
|
ECStringConstants.CONTAINERTYPE_ANY = "Any";
|
|
33
|
-
exports.ECStringConstants = ECStringConstants;
|
|
34
34
|
//# sourceMappingURL=Constants.js.map
|
package/lib/cjs/Constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,MAAa,iBAAiB;;
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,MAAa,iBAAiB;;AAA9B,8CAyBC;AAxBC,mBAAmB;AACI,yCAAuB,GAAW,QAAQ,CAAC;AAC3C,yCAAuB,GAAW,QAAQ,CAAC;AAElE,iBAAiB;AACM,sCAAoB,GAAW,QAAQ,CAAC;AACxC,2CAAyB,GAAW,aAAa,CAAC;AAClD,oDAAkC,GAAW,sBAAsB,CAAC;AACpE,2CAAyB,GAAW,aAAa,CAAC;AAClD,iDAA+B,GAAW,mBAAmB,CAAC;AAC9D,wCAAsB,GAAW,UAAU,CAAC;AAE5C,iDAA+B,GAAW,mBAAmB,CAAC;AAC9D,8CAA4B,GAAW,gBAAgB,CAAC;AACxD,sDAAoC,GAAW,eAAe,CAAC;AAC/D,mDAAiC,GAAW,qBAAqB,CAAC;AAClE,kDAAgC,GAAW,oBAAoB,CAAC;AAChE,2CAAyB,GAAW,aAAa,CAAC;AAElD,4DAA0C,GAAW,8BAA8B,CAAC;AACpF,4DAA0C,GAAW,8BAA8B,CAAC;AACpF,yDAAuC,GAAW,2BAA2B,CAAC;AAE9E,mCAAiB,GAAW,KAAK,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\r\n/**\r\n * @internal\r\n */\r\nexport class ECStringConstants {\r\n // Relationship End\r\n public static readonly RELATIONSHIP_END_SOURCE: string = \"Source\";\r\n public static readonly RELATIONSHIP_END_TARGET: string = \"Target\";\r\n\r\n // Container Type\r\n public static readonly CONTAINERTYPE_SCHEMA: string = \"Schema\";\r\n public static readonly CONTAINERTYPE_ENTITYCLASS: string = \"EntityClass\";\r\n public static readonly CONTAINERTYPE_CUSTOMATTRIBUTECLASS: string = \"CustomAttributeClass\";\r\n public static readonly CONTAINERTYPE_STRUCTCLASS: string = \"StructClass\";\r\n public static readonly CONTAINERTYPE_RELATIONSHIPCLASS: string = \"RelationshipClass\";\r\n public static readonly CONTAINERTYPE_ANYCLASS: string = \"AnyClass\";\r\n\r\n public static readonly CONTAINERTYPE_PRIMITIVEPROPERTY: string = \"PrimitiveProperty\";\r\n public static readonly CONTAINERTYPE_STRUCTPROPERTY: string = \"StructProperty\";\r\n public static readonly CONTAINERTYPE_PRIMITIVEARRAYPROPERTY: string = \"ArrayProperty\";\r\n public static readonly CONTAINERTYPE_STRUCTARRAYPROPERTY: string = \"StructArrayProperty\";\r\n public static readonly CONTAINERTYPE_NAVIGATIONPROPERTY: string = \"NavigationProperty\";\r\n public static readonly CONTAINERTYPE_ANYPROPERTY: string = \"AnyProperty\";\r\n\r\n public static readonly CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT: string = \"SourceRelationshipConstraint\";\r\n public static readonly CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT: string = \"TargetRelationshipConstraint\";\r\n public static readonly CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT: string = \"AnyRelationshipConstraint\";\r\n\r\n public static readonly CONTAINERTYPE_ANY: string = \"Any\";\r\n}\r\n"]}
|
package/lib/cjs/Context.js
CHANGED
|
@@ -53,7 +53,7 @@ class SchemaCache {
|
|
|
53
53
|
*/
|
|
54
54
|
async addSchemaPromise(schemaInfo, schema, schemaPromise) {
|
|
55
55
|
if (this.schemaExists(schemaInfo.schemaKey))
|
|
56
|
-
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${
|
|
56
|
+
throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.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
|
package/lib/cjs/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAM9D;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB;CAAI;AAuD9C;;GAEG;AACH,MAAa,WAAW;IAGtB;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,SAA8B;QACvD,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAChK,CAAC;IAEO,mBAAmB,CAAC,SAA8B;QACxD,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,IAAI,SAAS,KAAK,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7K,CAAC;IAEO,SAAS,CAAC,SAA8B,EAAE,SAA0B;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAkB,EAA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C,aAAa,CAAI,SAAS,EAAE,SAAS,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAuB,aAA4B;QAC3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACrF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,OAAO,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAuB,aAA4B;QACzE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,WAAW,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;CACF;AAtLD,sCAsLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass SchemaMap extends Array<SchemaEntry> { }\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface SchemaEntry {\r\n schemaInfo: SchemaInfo;\r\n schema: Schema;\r\n schemaPromise?: Promise<Schema>;\r\n}\r\n\r\n/**\r\n * The interface defines what is needed to be an `ISchemaLocater`.\r\n * A Schema Locater loads the requested schema if it can or returns undefined.\r\n * Schema Locaters should always load the schema on each request and should not hold a cache of schemas.\r\n * Schema locaters should never be used directly to load a schema, they should be added to a `SchemaContext`\r\n * and the context should be used to load schemas. The `SchemaContext` caches schemas and manages schema life time.\r\n * @beta\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): T | undefined;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface ISchemaItemLocater {\r\n getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n private loadedSchemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && !entry.schemaPromise);\r\n }\r\n\r\n private schemaPromiseExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && undefined !== entry.schemaPromise);\r\n }\r\n\r\n private findEntry(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType): SchemaEntry | undefined {\r\n return this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));\r\n }\r\n\r\n private removeSchemaPromise(schemaKey: Readonly<SchemaKey>) {\r\n const entry = this.findEntry(schemaKey, SchemaMatchType.Latest);\r\n if (entry)\r\n entry.schemaPromise = undefined;\r\n }\r\n\r\n private removeEntry(schemaKey: Readonly<SchemaKey>) {\r\n this._schema = this._schema.filter((entry: SchemaEntry) => !entry.schemaInfo.schemaKey.matches(schemaKey));\r\n }\r\n\r\n /**\r\n * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.\r\n * @param schemaKey The key to search for.\r\n */\r\n public schemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n if (this.schemaExists(schemaInfo.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schemaPromise.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo, schema, schemaPromise });\r\n\r\n // This promise is cached and will be awaited when the user requests the full schema.\r\n // If the promise competes successfully before the user requests the schema it will be removed from the cache\r\n // If it fails it will remain in the cache until the user awaits it and handles the error\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n schemaPromise.then(() => {\r\n this.removeSchemaPromise(schemaInfo.schemaKey);\r\n });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema<T extends Schema>(schema: T) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync<T extends Schema>(schema: T) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (!entry)\r\n return undefined;\r\n\r\n if (entry.schemaPromise) {\r\n try {\r\n const schema = await entry.schemaPromise as T;\r\n return schema;\r\n } catch (e) {\r\n this.removeEntry(schemaKey);\r\n throw e;\r\n }\r\n }\r\n\r\n return entry.schema as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<SchemaInfo | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry)\r\n return entry.schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry) {\r\n if (entry.schemaPromise) {\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);\r\n }\r\n return entry.schema as T;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public * getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const entry of this._schema) {\r\n for (const schemaItem of entry.schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * Does not include schemas from schemas that are not completely loaded yet.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Schema[] {\r\n return this._schema.map((entry: SchemaEntry) => entry.schema);\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @beta\r\n */\r\nexport class SchemaContext implements ISchemaItemLocater {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n }\r\n\r\n public addLocater(locater: ISchemaLocater) {\r\n this._locaters.push(locater);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n * @deprecated in 4.0 use ecschema-editing package\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.\r\n * @param schemaKey\r\n */\r\n public schemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return this._knownSchemas.schemaExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.\r\n * Use this method over addSchema when asynchronously loading schemas\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using [[getSchema]].\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType): Promise<SchemaInfo | undefined> {\r\n for (const locater of this._locaters) {\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);\r\n if (undefined !== schemaInfo)\r\n return schemaInfo;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will await a partially loaded schema then return when it is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this._knownSchemas.getSchema<T>(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n return this._knownSchemas.getSchemaSync<T>(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item\r\n */\r\n public async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined> {\r\n const schema = await this.getSchema(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItem<T>(schemaItemKey.name);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item\r\n */\r\n public getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined {\r\n const schema = this.getSchemaSync(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItemSync<T>(schemaItemKey.name);\r\n }\r\n\r\n /**\r\n * Iterates through the items of each schema known to the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context. Does not\r\n * include schemas that are partially loaded.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Schema[] {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAM9D;;GAEG;AACH,MAAM,SAAU,SAAQ,KAAkB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B,OAAO,MAAM,CAAC,OAAO,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAuB,aAA4B;QACzE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,WAAW,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;CACF;AAtLD,sCAsLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass SchemaMap extends Array<SchemaEntry> { }\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface SchemaEntry {\r\n schemaInfo: SchemaInfo;\r\n schema: Schema;\r\n schemaPromise?: Promise<Schema>;\r\n}\r\n\r\n/**\r\n * The interface defines what is needed to be an `ISchemaLocater`.\r\n * A Schema Locater loads the requested schema if it can or returns undefined.\r\n * Schema Locaters should always load the schema on each request and should not hold a cache of schemas.\r\n * Schema locaters should never be used directly to load a schema, they should be added to a `SchemaContext`\r\n * and the context should be used to load schemas. The `SchemaContext` caches schemas and manages schema life time.\r\n * @beta\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * May return the entire Schema so long as it is completely loaded as it satisfies the SchemaInfo interface.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): T | undefined;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface ISchemaItemLocater {\r\n getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n private loadedSchemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && !entry.schemaPromise);\r\n }\r\n\r\n private schemaPromiseExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return undefined !== this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, SchemaMatchType.Latest) && undefined !== entry.schemaPromise);\r\n }\r\n\r\n private findEntry(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType): SchemaEntry | undefined {\r\n return this._schema.find((entry: SchemaEntry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));\r\n }\r\n\r\n private removeSchemaPromise(schemaKey: Readonly<SchemaKey>) {\r\n const entry = this.findEntry(schemaKey, SchemaMatchType.Latest);\r\n if (entry)\r\n entry.schemaPromise = undefined;\r\n }\r\n\r\n private removeEntry(schemaKey: Readonly<SchemaKey>) {\r\n this._schema = this._schema.filter((entry: SchemaEntry) => !entry.schemaInfo.schemaKey.matches(schemaKey));\r\n }\r\n\r\n /**\r\n * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.\r\n * @param schemaKey The key to search for.\r\n */\r\n public schemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n if (this.schemaExists(schemaInfo.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schemaInfo.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo, schema, schemaPromise });\r\n\r\n // This promise is cached and will be awaited when the user requests the full schema.\r\n // If the promise competes successfully before the user requests the schema it will be removed from the cache\r\n // If it fails it will remain in the cache until the user awaits it and handles the error\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n schemaPromise.then(() => {\r\n this.removeSchemaPromise(schemaInfo.schemaKey);\r\n });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema<T extends Schema>(schema: T) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync<T extends Schema>(schema: T) {\r\n if (this.schemaExists(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push({ schemaInfo: schema, schema });\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (!entry)\r\n return undefined;\r\n\r\n if (entry.schemaPromise) {\r\n try {\r\n const schema = await entry.schemaPromise as T;\r\n return schema;\r\n } catch (e) {\r\n this.removeEntry(schemaKey);\r\n throw e;\r\n }\r\n }\r\n\r\n return entry.schema as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<SchemaInfo | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry)\r\n return entry.schemaInfo;\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const entry = this.findEntry(schemaKey, matchType);\r\n if (entry) {\r\n if (entry.schemaPromise) {\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);\r\n }\r\n return entry.schema as T;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public * getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const entry of this._schema) {\r\n for (const schemaItem of entry.schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * Does not include schemas from schemas that are not completely loaded yet.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Schema[] {\r\n return this._schema.map((entry: SchemaEntry) => entry.schema);\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @beta\r\n */\r\nexport class SchemaContext implements ISchemaItemLocater {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n }\r\n\r\n public addLocater(locater: ISchemaLocater) {\r\n this._locaters.push(locater);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n * @deprecated in 4.0 use ecschema-editing package\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.\r\n * @param schemaKey\r\n */\r\n public schemaExists(schemaKey: Readonly<SchemaKey>): boolean {\r\n return this._knownSchemas.schemaExists(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.\r\n * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.\r\n * Use this method over addSchema when asynchronously loading schemas\r\n * @param schemaInfo An object with the schema key for the schema being loaded and it's references\r\n * @param schema The partially loaded schema that the promise will fulfill\r\n * @param schemaPromise The schema promise to add to the cache.\r\n */\r\n public async addSchemaPromise(schemaInfo: SchemaInfo, schema: Schema, schemaPromise: Promise<Schema>) {\r\n return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using [[getSchema]].\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType): Promise<SchemaInfo | undefined> {\r\n for (const locater of this._locaters) {\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);\r\n if (undefined !== schemaInfo)\r\n return schemaInfo;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Attempts to obtain a schema from this context that matches the specified criteria.\r\n * Will return undefined if the schema is partially loaded. Use [[getSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey Identifies the schema to obtain.\r\n * @param matchType Criteria by which to identify potentially matching schemas.\r\n * @returns the schema matching the input criteria, or `undefined` if no such schema could be located.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will await a partially loaded schema then return when it is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this._knownSchemas.getSchema<T>(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * Will return undefined if the cached schema is partially loaded. Use [[getCachedSchema]] to await until the schema is completely loaded.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n return this._knownSchemas.getSchemaSync<T>(schemaKey, matchType);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will await a partially loaded schema then look in it for the requested item\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item\r\n */\r\n public async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined> {\r\n const schema = await this.getSchema(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItem<T>(schemaItemKey.name);\r\n }\r\n\r\n /**\r\n * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].\r\n * Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.\r\n * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.\r\n * @returns The requested schema item\r\n */\r\n public getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined {\r\n const schema = this.getSchemaSync(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItemSync<T>(schemaItemKey.name);\r\n }\r\n\r\n /**\r\n * Iterates through the items of each schema known to the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * Does not include schema items from schemas that are not completely loaded yet.\r\n */\r\n public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context. Does not\r\n * include schemas that are partially loaded.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Schema[] {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helper.js","sourceRoot":"","sources":["../../../src/Deserialization/Helper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wCAA2C;AAC3C,4CAAwG;AACxG,4CAA+D;AAa/D,uDAAoD;AAEpD,4CAAmE;AACnE,4EAA6F;AAC7F,wDAAoE;AAGpE,sDAAmD;AAKnD;;;;GAIG;AACH,MAAa,gBAAgB;IAW3B,YAAY,UAAwC,EAAE,OAAuB,EAAE,OAA4B;QACzG,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI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AAC;aACtM;YAED,kEAAkE;YAClE,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,eAAe,GAAG,QAAQ,CAAC,OAA+B,CAAC,CAAC;YAEjE,SAAmC,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;SAC1E;IACH,CAAC;IAED;;;;OAIG;IACK,wBAAwB,CAAC,SAAyB,EAAE,WAAsC;QAChG,KAAK,MAAM,aAAa,IAAI,WAAW,EAAE;YACvC,0CAA0C;YAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAyB,CAAC;YAElF,kEAAkE;YAClE,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;YACzC,SAAmC,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;SAC1E;IACH,CAAC;CACF;AAh/BD,4CAg/BC","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 { SchemaContext } from \"../Context\";\r\nimport { parsePrimitiveType, parseSchemaItemType, SchemaItemType, SchemaMatchType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { AnyClass, AnySchemaItem, SchemaInfo } from \"../Interfaces\";\r\nimport { ECClass, MutableClass } from \"../Metadata/Class\";\r\nimport { Constant } from \"../Metadata/Constant\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { EntityClass, MutableEntityClass } from \"../Metadata/EntityClass\";\r\nimport { Format } from \"../Metadata/Format\";\r\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\r\nimport { KindOfQuantity } from \"../Metadata/KindOfQuantity\";\r\nimport { Mixin } from \"../Metadata/Mixin\";\r\nimport { MutableProperty, Property } from \"../Metadata/Property\";\r\nimport { MutableRelationshipConstraint, RelationshipClass, RelationshipConstraint } from \"../Metadata/RelationshipClass\";\r\nimport { MutableSchema, Schema } from \"../Metadata/Schema\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { ECVersion, SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { ISchemaPartVisitor, SchemaPartVisitorDelegate } from \"../SchemaPartVisitorDelegate\";\r\nimport { getItemNamesFromFormatString } from \"@itwin/core-quantity\";\r\nimport { AbstractParser, AbstractParserConstructor, CAProviderTuple } from \"./AbstractParser\";\r\nimport { ClassProps, PropertyProps, RelationshipConstraintProps, SchemaReferenceProps } from \"./JsonProps\";\r\nimport { SchemaGraph } from \"../utils/SchemaGraph\";\r\n\r\ntype AnyCAContainer = Schema | ECClass | Property | RelationshipConstraint;\r\ntype AnyMutableCAContainer = MutableSchema | MutableClass | MutableProperty | MutableRelationshipConstraint;\r\n\r\n/**\r\n * This class properly handles the order the deserialization of ECSchemas and SchemaItems from serialized formats.\r\n * For example, when deserializing an ECClass most times all base class should be de-serialized before the given class.\r\n * @internal\r\n */\r\nexport class SchemaReadHelper<T = unknown> {\r\n private _context: SchemaContext;\r\n private _visitorHelper?: SchemaPartVisitorDelegate;\r\n private _parserType: AbstractParserConstructor<T, unknown>;\r\n private _parser!: AbstractParser<unknown>;\r\n\r\n // Cache of the schema currently being loaded. This schema is in the _context but to\r\n // avoid going back to the context every time, the cache is used.\r\n private _schema?: Schema;\r\n private _schemaInfo?: SchemaInfo;\r\n\r\n constructor(parserType: AbstractParserConstructor<T>, context?: SchemaContext, visitor?: ISchemaPartVisitor) {\r\n this._context = (undefined !== context) ? context : new SchemaContext();\r\n this._visitorHelper = visitor ? new SchemaPartVisitorDelegate(visitor) : undefined;\r\n this._parserType = parserType;\r\n }\r\n\r\n /**\r\n * Creates a complete SchemaInfo and starts parsing the schema from a serialized representation.\r\n * The info and schema promise will be registered with the SchemaContext. The complete schema can be retrieved by\r\n * calling getCachedSchema on the context.\r\n * @param schema The Schema to populate\r\n * @param rawSchema The serialized data to use to populate the Schema.\r\n */\r\n public async readSchemaInfo<U extends Schema>(schema: U, rawSchema: T): Promise<SchemaInfo> {\r\n // Ensure context matches schema context\r\n if (schema.context) {\r\n if (this._context !== schema.context)\r\n throw new ECObjectsError(ECObjectsStatus.DifferentSchemaContexts, \"The SchemaContext of the schema must be the same SchemaContext held by the SchemaReadHelper.\");\r\n } else {\r\n (schema as Schema as MutableSchema).setContext(this._context);\r\n }\r\n\r\n this._parser = new this._parserType(rawSchema);\r\n\r\n // Loads all of the properties on the Schema object\r\n await schema.fromJSON(this._parser.parseSchema());\r\n\r\n this._schema = schema;\r\n\r\n const schemaInfo: SchemaInfo = { schemaKey: schema.schemaKey, references: [] };\r\n for (const reference of this._parser.getReferences()) {\r\n const refKey = new SchemaKey(reference.name, ECVersion.fromString(reference.version));\r\n schemaInfo.references.push({ schemaKey: refKey });\r\n }\r\n\r\n this._schemaInfo = schemaInfo;\r\n\r\n // Need to add this schema to the context to be able to locate schemaItems within the context.\r\n if (!this._context.schemaExists(schema.schemaKey)) {\r\n await this._context.addSchemaPromise(schemaInfo, schema, this.loadSchema(schemaInfo, schema));\r\n }\r\n return schemaInfo;\r\n }\r\n\r\n /**\r\n * Populates the given Schema from a serialized representation.\r\n * @param schema The Schema to populate\r\n * @param rawSchema The serialized data to use to populate the Schema.\r\n */\r\n public async readSchema<U extends Schema>(schema: U, rawSchema: T): Promise<U> {\r\n if (!this._schemaInfo) {\r\n await this.readSchemaInfo(schema, rawSchema);\r\n }\r\n\r\n const cachedSchema = await this._context.getCachedSchema<U>(this._schemaInfo!.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === cachedSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);\r\n\r\n return cachedSchema;\r\n }\r\n\r\n /* Finish loading the rest of the schema */\r\n private async loadSchema<U extends Schema>(schemaInfo: SchemaInfo, schema: U): Promise<U> {\r\n // Verify that there are no schema reference cycles, this will start schema loading by loading their headers\r\n (await SchemaGraph.generateGraph(schemaInfo, this._context)).throwIfCycles();\r\n\r\n for (const reference of schemaInfo.references) {\r\n await this.loadSchemaReference(schemaInfo, reference.schemaKey);\r\n }\r\n\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchema(schema, false);\r\n\r\n // Load all schema items\r\n for (const [itemName, itemType, rawItem] of this._parser.getItems()) {\r\n // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,\r\n // which would be found when adding to the context.\r\n if (await schema.getItem(itemName) !== undefined)\r\n continue;\r\n\r\n const loadedItem = await this.loadSchemaItem(schema, itemName, itemType, rawItem);\r\n if (loadedItem && this._visitorHelper) {\r\n await this._visitorHelper.visitSchemaPart(loadedItem);\r\n }\r\n }\r\n\r\n await this.loadCustomAttributes(schema, this._parser.getSchemaCustomAttributeProviders());\r\n\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchema(schema);\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Populates the given Schema from a serialized representation.\r\n * @param schema The Schema to populate\r\n * @param rawSchema The serialized data to use to populate the Schema.\r\n */\r\n public readSchemaSync<U extends Schema>(schema: U, rawSchema: T): U {\r\n this._parser = new this._parserType(rawSchema);\r\n\r\n // Loads all of the properties on the Schema object\r\n schema.fromJSONSync(this._parser.parseSchema());\r\n\r\n this._schema = schema;\r\n\r\n // Need to add this schema to the context to be able to locate schemaItems within the context.\r\n if (!this._context.schemaExists(schema.schemaKey))\r\n this._context.addSchemaSync(schema);\r\n\r\n // Load schema references first\r\n // Need to figure out if other schemas are present.\r\n for (const reference of this._parser.getReferences()) {\r\n this.loadSchemaReferenceSync(reference);\r\n }\r\n\r\n if (this._visitorHelper)\r\n this._visitorHelper.visitSchemaSync(schema, false);\r\n\r\n // Load all schema items\r\n for (const [itemName, itemType, rawItem] of this._parser.getItems()) {\r\n // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,\r\n // which would be found when adding to the context.\r\n if (schema.getItemSync(itemName) !== undefined)\r\n continue;\r\n\r\n const loadedItem = this.loadSchemaItemSync(schema, itemName, itemType, rawItem);\r\n if (loadedItem && this._visitorHelper) {\r\n this._visitorHelper.visitSchemaPartSync(loadedItem);\r\n }\r\n }\r\n\r\n this.loadCustomAttributesSync(schema, this._parser.getSchemaCustomAttributeProviders());\r\n\r\n if (this._visitorHelper)\r\n this._visitorHelper.visitSchemaSync(schema);\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Ensures that the schema references can be located and adds them to the schema.\r\n * @param ref The object to read the SchemaReference's props from.\r\n */\r\n private async loadSchemaReference(schemaInfo: SchemaInfo, refKey: Readonly<SchemaKey>): Promise<void> {\r\n const refSchema = await this._context.getSchema(refKey, SchemaMatchType.LatestWriteCompatible);\r\n if (undefined === refSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refKey.name}.${refKey.version.toString()}, of ${schemaInfo.schemaKey.name}`);\r\n\r\n await (this._schema as MutableSchema).addReference(refSchema);\r\n const results = this.validateSchemaReferences(this._schema!);\r\n\r\n let errorMessage: string = \"\";\r\n for (const result of results) {\r\n errorMessage += `${result}\\r\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `${errorMessage}`);\r\n }\r\n }\r\n\r\n /**\r\n * Ensures that the schema references can be located and adds them to the schema.\r\n * @param ref The object to read the SchemaReference's props from.\r\n */\r\n private loadSchemaReferenceSync(ref: SchemaReferenceProps): void {\r\n const schemaKey = new SchemaKey(ref.name, ECVersion.fromString(ref.version));\r\n const refSchema = this._context.getSchemaSync(schemaKey, SchemaMatchType.LatestWriteCompatible);\r\n if (!refSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${this._schema!.schemaKey.name}`);\r\n\r\n (this._schema as MutableSchema).addReferenceSync(refSchema);\r\n\r\n SchemaGraph.generateGraphSync(this._schema!).throwIfCycles();\r\n const results = this.validateSchemaReferences(this._schema!);\r\n\r\n let errorMessage: string = \"\";\r\n for (const result of results) {\r\n errorMessage += `${result}\\r\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `${errorMessage}`);\r\n }\r\n }\r\n\r\n /**\r\n * Validates schema references against multiple EC rules.\r\n * @param schema The schema to validate.\r\n */\r\n private *validateSchemaReferences(schema: Schema): Iterable<string> {\r\n const aliases = new Map();\r\n for (const schemaRef of schema.references) {\r\n if (schemaRef.customAttributes && schemaRef.customAttributes.has(\"CoreCustomAttributes.SupplementalSchema\"))\r\n yield `Referenced schema '${schemaRef.name}' of schema '${schema.name}' is a supplemental schema. Supplemental schemas are not allowed to be referenced.`;\r\n\r\n if (schema.schemaKey.matches(schemaRef.schemaKey))\r\n yield `Schema '${schema.name}' has reference cycles: '${schema.name} --> ${schemaRef.name}'`;\r\n\r\n if (aliases.has(schemaRef.alias)) {\r\n const currentRef = aliases.get(schemaRef.alias);\r\n yield `Schema '${schema.name}' has multiple schema references (${currentRef.name}, $schemaRef.name}) with the same alias '${schemaRef.alias}', which is not allowed.`;\r\n } else {\r\n aliases.set(schemaRef.alias, schemaRef);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.\r\n * @param schema The Schema the SchemaItem to.\r\n * @param name The name of the schema item to be loaded.\r\n * @param itemType The SchemaItemType of the item to load.\r\n * @param schemaItemObject The Object to populate the SchemaItem with.\r\n */\r\n private async loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): Promise<SchemaItem | undefined> {\r\n let schemaItem: AnySchemaItem | undefined;\r\n\r\n switch (parseSchemaItemType(itemType)) {\r\n case SchemaItemType.EntityClass:\r\n schemaItem = await (schema as MutableSchema).createEntityClass(name);\r\n await this.loadEntityClass(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.StructClass:\r\n schemaItem = await (schema as MutableSchema).createStructClass(name);\r\n const structProps = this._parser.parseStructClass(schemaItemObject);\r\n await this.loadClass(schemaItem, structProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.Mixin:\r\n schemaItem = await (schema as MutableSchema).createMixinClass(name);\r\n await this.loadMixin(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.CustomAttributeClass:\r\n schemaItem = await (schema as MutableSchema).createCustomAttributeClass(name);\r\n const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);\r\n await this.loadClass(schemaItem, caClassProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n schemaItem = await (schema as MutableSchema).createRelationshipClass(name);\r\n await this.loadRelationshipClass(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n schemaItem = await (schema as MutableSchema).createKindOfQuantity(name);\r\n await this.loadKindOfQuantity(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Unit:\r\n schemaItem = await (schema as MutableSchema).createUnit(name);\r\n await this.loadUnit(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Constant:\r\n schemaItem = await (schema as MutableSchema).createConstant(name);\r\n await this.loadConstant(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n schemaItem = await (schema as MutableSchema).createInvertedUnit(name);\r\n await this.loadInvertedUnit(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Format:\r\n schemaItem = await (schema as MutableSchema).createFormat(name);\r\n await this.loadFormat(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n schemaItem = await (schema as MutableSchema).createPhenomenon(name);\r\n const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);\r\n await schemaItem.fromJSON(phenomenonProps);\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n schemaItem = await (schema as MutableSchema).createUnitSystem(name);\r\n await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n schemaItem = await (schema as MutableSchema).createPropertyCategory(name);\r\n const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);\r\n await schemaItem.fromJSON(propertyCategoryProps);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n schemaItem = await (schema as MutableSchema).createEnumeration(name);\r\n const enumerationProps = this._parser.parseEnumeration(schemaItemObject);\r\n await schemaItem.fromJSON(enumerationProps);\r\n break;\r\n // NOTE: we are being permissive here and allowing unknown types to silently fail. Not sure if we want to hard fail or just do a basic deserialization\r\n }\r\n\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.\r\n * @param schema The Schema the SchemaItem to.\r\n * @param name The name of the schema item to be loaded.\r\n * @param itemType The SchemaItemType of the item to load.\r\n * @param schemaItemObject The Object to populate the SchemaItem with.\r\n */\r\n private loadSchemaItemSync(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): SchemaItem | undefined {\r\n let schemaItem: AnySchemaItem | undefined;\r\n\r\n switch (parseSchemaItemType(itemType)) {\r\n case SchemaItemType.EntityClass:\r\n schemaItem = (schema as MutableSchema).createEntityClassSync(name);\r\n this.loadEntityClassSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.StructClass:\r\n schemaItem = (schema as MutableSchema).createStructClassSync(name);\r\n const structProps = this._parser.parseStructClass(schemaItemObject);\r\n this.loadClassSync(schemaItem, structProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.Mixin:\r\n schemaItem = (schema as MutableSchema).createMixinClassSync(name);\r\n this.loadMixinSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.CustomAttributeClass:\r\n schemaItem = (schema as MutableSchema).createCustomAttributeClassSync(name);\r\n const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);\r\n this.loadClassSync(schemaItem, caClassProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n schemaItem = (schema as MutableSchema).createRelationshipClassSync(name);\r\n this.loadRelationshipClassSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n schemaItem = (schema as MutableSchema).createKindOfQuantitySync(name);\r\n this.loadKindOfQuantitySync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Unit:\r\n schemaItem = (schema as MutableSchema).createUnitSync(name);\r\n this.loadUnitSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Constant:\r\n schemaItem = (schema as MutableSchema).createConstantSync(name);\r\n this.loadConstantSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n schemaItem = (schema as MutableSchema).createInvertedUnitSync(name);\r\n this.loadInvertedUnitSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Format:\r\n schemaItem = (schema as MutableSchema).createFormatSync(name);\r\n this.loadFormatSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n schemaItem = (schema as MutableSchema).createPhenomenonSync(name);\r\n const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);\r\n schemaItem.fromJSONSync(phenomenonProps);\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n schemaItem = (schema as MutableSchema).createUnitSystemSync(name);\r\n schemaItem.fromJSONSync(this._parser.parseUnitSystem(schemaItemObject));\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n schemaItem = (schema as MutableSchema).createPropertyCategorySync(name);\r\n const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);\r\n schemaItem.fromJSONSync(propertyCategoryProps);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n schemaItem = (schema as MutableSchema).createEnumerationSync(name);\r\n const enumerationProps = this._parser.parseEnumeration(schemaItemObject);\r\n schemaItem.fromJSONSync(enumerationProps);\r\n break;\r\n // NOTE: we are being permissive here and allowing unknown types to silently fail. Not sure if we want to hard fail or just do a basic deserialization\r\n }\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Given the full (Schema.ItemName) or qualified (alias:ItemName) item name, returns\r\n * a tuple of strings in the format [\"SchemaName\", \"ItemName\"]. The schema name may be\r\n * empty if the item comes from the schema being parsed.\r\n * @param fullOrQualifiedName The full or qualified name of the schema item.\r\n * @param schema The schema that will be used to lookup the schema name by alias, if necessary.\r\n */\r\n private static resolveSchemaAndItemName(fullOrQualifiedName: string, schema?: Schema): [string, string] {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(fullOrQualifiedName);\r\n\r\n // If a schema is provided we attempt to resolve the alias by looking at the reference schemas.\r\n if (undefined !== schema && -1 !== fullOrQualifiedName.indexOf(\":\")) {\r\n const refName = schema.getReferenceNameByAlias(schemaName);\r\n if (undefined === refName)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not resolve schema alias '${schemaName}' for schema item '${itemName}.`);\r\n return [refName, itemName];\r\n }\r\n\r\n return [schemaName, itemName];\r\n }\r\n\r\n /**\r\n * Finds the a SchemaItem matching the name first by checking the schema that is being deserialized. If it does\r\n * not exist within the schema, the SchemaContext will be searched.\r\n * @param name The full (Schema.ItemName) or qualified (alias:ItemName) name of the SchemaItem to search for.\r\n * @param skipVisitor Used to break Mixin -appliesTo-> Entity -extends-> Mixin cycle.\r\n * @param loadCallBack Only called if the SchemaItem had to be loaded.\r\n * @return The SchemaItem if it had to be loaded, otherwise undefined.\r\n */\r\n private async findSchemaItem(name: string, skipVisitor = false, loadCallBack?: (item: SchemaItem) => void): Promise<SchemaItem | undefined> {\r\n let schemaItem: SchemaItem | undefined;\r\n // TODO: A better solution should be investigated for handling both an alias and the schema name.\r\n const [schemaName, itemName] = SchemaReadHelper.resolveSchemaAndItemName(name, this._schema);\r\n const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());\r\n\r\n if (undefined === schemaName || 0 === schemaName.length)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);\r\n\r\n if (isInThisSchema) {\r\n schemaItem = await this._schema!.getItem(itemName);\r\n if (schemaItem)\r\n return schemaItem;\r\n\r\n const foundItem = this._parser.findItem(itemName);\r\n if (foundItem) {\r\n schemaItem = await this.loadSchemaItem(this._schema!, ...foundItem);\r\n if (!skipVisitor && schemaItem && this._visitorHelper) {\r\n await this._visitorHelper.visitSchemaPart(schemaItem);\r\n }\r\n if (loadCallBack && schemaItem)\r\n loadCallBack(schemaItem);\r\n\r\n return schemaItem;\r\n }\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n }\r\n\r\n schemaItem = await this._context.getSchemaItem(new SchemaItemKey(itemName, new SchemaKey(schemaName)));\r\n if (undefined === schemaItem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Finds the a SchemaItem matching the name first by checking the schema that is being deserialized. If it does\r\n * not exist within the schema, the SchemaContext will be searched.\r\n * @param name The full (Schema.ItemName) or qualified (alias:ItemName) name of the SchemaItem to search for.\r\n * @param skipVisitor Used to break Mixin -appliesTo-> Entity -extends-> Mixin cycle.\r\n * @param loadCallBack Only called if the SchemaItem had to be loaded.\r\n * @return The SchemaItem if it had to be loaded, otherwise undefined.\r\n */\r\n private findSchemaItemSync(name: string, skipVisitor = false, loadCallBack?: (item: SchemaItem) => void): SchemaItem | undefined {\r\n let schemaItem: SchemaItem | undefined;\r\n // TODO: A better solution should be investigated for handling both an alias and the schema name.\r\n const [schemaName, itemName] = SchemaReadHelper.resolveSchemaAndItemName(name, this._schema);\r\n const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());\r\n\r\n if (undefined === schemaName || schemaName.length === 0)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);\r\n\r\n if (isInThisSchema && undefined === this._schema!.getItemSync(itemName)) {\r\n const foundItem = this._parser.findItem(itemName);\r\n if (foundItem) {\r\n schemaItem = this.loadSchemaItemSync(this._schema!, ...foundItem);\r\n if (!skipVisitor && schemaItem && this._visitorHelper) {\r\n this._visitorHelper.visitSchemaPartSync(schemaItem);\r\n }\r\n if (loadCallBack && schemaItem)\r\n loadCallBack(schemaItem);\r\n\r\n return schemaItem;\r\n }\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n }\r\n\r\n schemaItem = this._context.getSchemaItemSync(new SchemaItemKey(itemName, new SchemaKey(schemaName)));\r\n if (undefined === schemaItem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Load dependencies on phenomenon and unitSystem for a Unit object and load the Unit from its serialized format.\r\n * @param unit The Unit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawUnit The serialized unit data\r\n */\r\n private async loadUnit(unit: Unit, rawUnit: Readonly<unknown>): Promise<void> {\r\n const unitProps = this._parser.parseUnit(rawUnit);\r\n\r\n await this.findSchemaItem(unitProps.phenomenon, true);\r\n await this.findSchemaItem(unitProps.unitSystem, true);\r\n\r\n await unit.fromJSON(unitProps);\r\n }\r\n\r\n /**\r\n * Load dependencies on phenomenon and unitSystem for a Unit object and load the Unit from its serialized format.\r\n * @param unit The Unit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawUnit The serialized unit data\r\n */\r\n private loadUnitSync(unit: Unit, rawUnit: Readonly<unknown>) {\r\n const unitProps = this._parser.parseUnit(rawUnit);\r\n\r\n this.findSchemaItemSync(unitProps.phenomenon, true);\r\n this.findSchemaItemSync(unitProps.unitSystem, true);\r\n\r\n unit.fromJSONSync(unitProps);\r\n }\r\n\r\n /**\r\n * Load the persistence unit and presentation unit dependencies for a KindOfQuantity object and load the KoQ from its serialized format.\r\n * @param koq The KindOfQuantity object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawKoQ The serialized kind of quantity data\r\n */\r\n private async loadKindOfQuantity(koq: KindOfQuantity, rawKoQ: Readonly<unknown>): Promise<void> {\r\n const koqProps = this._parser.parseKindOfQuantity(rawKoQ);\r\n await this.findSchemaItem(koqProps.persistenceUnit);\r\n\r\n if (undefined !== koqProps.presentationUnits) {\r\n for (const formatString of koqProps.presentationUnits) {\r\n for (const name of getItemNamesFromFormatString(formatString)) {\r\n await this.findSchemaItem(name);\r\n }\r\n }\r\n }\r\n\r\n await koq.fromJSON(koqProps);\r\n }\r\n\r\n /**\r\n * Load the persistence unit and presentation unit dependencies for a KindOfQuantity object and load the KoQ from its serialized format.\r\n * @param koq The KindOfQuantity object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawKoQ The serialized kind of quantity data\r\n */\r\n private loadKindOfQuantitySync(koq: KindOfQuantity, rawKoQ: Readonly<unknown>) {\r\n const koqProps = this._parser.parseKindOfQuantity(rawKoQ);\r\n this.findSchemaItemSync(koqProps.persistenceUnit);\r\n\r\n if (undefined !== koqProps.presentationUnits) {\r\n for (const formatString of koqProps.presentationUnits) {\r\n for (const name of getItemNamesFromFormatString(formatString)) {\r\n this.findSchemaItemSync(name);\r\n }\r\n }\r\n }\r\n koq.fromJSONSync(koqProps);\r\n }\r\n\r\n /**\r\n * Load the phenomenon dependency for a Constant object and load the Constant from its serialized format.\r\n * @param constant The Constant object that we are loading the phenomenon dependency for\r\n * @param rawConstant The serialized constant data\r\n */\r\n private async loadConstant(constant: Constant, rawConstant: Readonly<unknown>): Promise<void> {\r\n const constantProps = this._parser.parseConstant(rawConstant);\r\n\r\n await this.findSchemaItem(constantProps.phenomenon, true);\r\n await constant.fromJSON(constantProps);\r\n }\r\n\r\n /**\r\n * Load the phenomenon dependency for a Constant object and load the Constant from its serialized format.\r\n * @param constant The Constant object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawConstant The serialized constant data\r\n */\r\n private loadConstantSync(constant: Constant, rawConstant: Readonly<unknown>) {\r\n const constantProps = this._parser.parseConstant(rawConstant);\r\n\r\n this.findSchemaItemSync(constantProps.phenomenon, true);\r\n constant.fromJSONSync(constantProps);\r\n }\r\n\r\n /**\r\n * Load the unit system and invertsUnit dependencies for an Inverted Unit object and load the Inverted Unit from its serialized format.\r\n * @param invertedUnit The InvertedUnit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawInvertedUnit The serialized inverted unit data.\r\n */\r\n private async loadInvertedUnit(invertedUnit: InvertedUnit, rawInvertedUnit: Readonly<unknown>): Promise<void> {\r\n const invertedUnitProps = this._parser.parseInvertedUnit(rawInvertedUnit);\r\n\r\n await this.findSchemaItem(invertedUnitProps.invertsUnit, true);\r\n await this.findSchemaItem(invertedUnitProps.unitSystem, true);\r\n\r\n await invertedUnit.fromJSON(invertedUnitProps);\r\n }\r\n\r\n /**\r\n * Load the unit system and invertsUnit dependencies for an Inverted Unit object and load the Inverted Unit from its serialized format.\r\n * @param invertedUnit The InvertedUnit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawInvertedUnit The serialized inverted unit data.\r\n */\r\n private loadInvertedUnitSync(invertedUnit: InvertedUnit, rawInvertedUnit: Readonly<unknown>) {\r\n const invertedUnitProps = this._parser.parseInvertedUnit(rawInvertedUnit);\r\n\r\n this.findSchemaItemSync(invertedUnitProps.invertsUnit, true);\r\n this.findSchemaItemSync(invertedUnitProps.unitSystem, true);\r\n\r\n invertedUnit.fromJSONSync(invertedUnitProps);\r\n }\r\n\r\n /**\r\n * Load the unit dependencies for a Format object and load the Format from its serialized format.\r\n * @param format The Format object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawFormat The serialized format data.\r\n */\r\n private async loadFormat(format: Format, rawFormat: Readonly<unknown>): Promise<void> {\r\n const formatProps = this._parser.parseFormat(rawFormat);\r\n\r\n if (undefined !== formatProps.composite) {\r\n const formatUnits = formatProps.composite.units;\r\n for (const unit of formatUnits) {\r\n await this.findSchemaItem(unit.name, true);\r\n }\r\n }\r\n await format.fromJSON(formatProps);\r\n }\r\n\r\n /**\r\n * Load the unit dependencies for a Format object and load the Format from its serialized format.\r\n * @param format The Format object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawFormat The serialized format data.\r\n */\r\n private loadFormatSync(format: Format, rawFormat: Readonly<unknown>) {\r\n const formatProps = this._parser.parseFormat(rawFormat);\r\n\r\n if (undefined !== formatProps.composite) {\r\n const formatUnits = formatProps.composite.units;\r\n for (const unit of formatUnits) {\r\n this.findSchemaItemSync(unit.name, true);\r\n }\r\n }\r\n\r\n format.fromJSONSync(formatProps);\r\n }\r\n\r\n /**\r\n * Load the base class and property type dependencies for an ECClass object and load the ECClass (and its properties) from its serialized format.\r\n * @param classObj The ECClass object that we are loading dependencies for and \"deserializing into\".\r\n * @param classProps The parsed class props object.\r\n * @param rawClass The serialized class data.\r\n */\r\n private async loadClass(classObj: AnyClass, classProps: ClassProps, rawClass: Readonly<unknown>): Promise<void> {\r\n const baseClassLoaded = async (baseClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchemaPart(baseClass);\r\n };\r\n\r\n // Load base class first\r\n if (undefined !== classProps.baseClass) {\r\n await this.findSchemaItem(classProps.baseClass, true, baseClassLoaded);\r\n }\r\n\r\n // Now deserialize the class itself, *before* any properties\r\n // (We need to do this to break Entity -navProp-> Relationship -constraint-> Entity cycle.)\r\n await (classObj as ECClass).fromJSON(classProps);\r\n\r\n for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass, classObj.fullName)) {\r\n await this.loadPropertyTypes(classObj, propName, propType, rawProp);\r\n }\r\n\r\n await this.loadCustomAttributes(classObj, this._parser.getClassCustomAttributeProviders(rawClass));\r\n }\r\n\r\n /**\r\n * Load the base class and property type dependencies for an ECClass object and load the ECClass (and its properties) from its serialized format.\r\n * @param classObj The ECClass object that we are loading dependencies for and \"deserializing into\".\r\n * @param classProps The parsed class props object.\r\n * @param rawClass The serialized class data.\r\n */\r\n private loadClassSync(classObj: AnyClass, classProps: ClassProps, rawClass: Readonly<unknown>): void {\r\n const baseClassLoaded = async (baseClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n this._visitorHelper.visitSchemaPartSync(baseClass);\r\n };\r\n\r\n // Load base class first\r\n if (undefined !== classProps.baseClass) {\r\n this.findSchemaItemSync(classProps.baseClass, true, baseClassLoaded);\r\n }\r\n\r\n // Now deserialize the class itself, *before* any properties\r\n // (We need to do this to break Entity -navProp-> Relationship -constraint-> Entity cycle.)\r\n (classObj as ECClass).fromJSONSync(classProps);\r\n\r\n for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass, classObj.fullName)) {\r\n this.loadPropertyTypesSync(classObj, propName, propType, rawProp);\r\n }\r\n\r\n this.loadCustomAttributesSync(classObj, this._parser.getClassCustomAttributeProviders(rawClass));\r\n }\r\n\r\n /**\r\n * Load the mixin, base class, and property type dependencies for an EntityClass object and load the EntityClass (and properties) from its serialized format.\r\n * @param entity The EntityClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawEntity The serialized entity class data.\r\n */\r\n private async loadEntityClass(entity: EntityClass, rawEntity: Readonly<unknown>): Promise<void> {\r\n const entityClassProps = this._parser.parseEntityClass(rawEntity);\r\n\r\n // Load Mixin classes first\r\n if (undefined !== entityClassProps.mixins) {\r\n for (const mixinName of entityClassProps.mixins)\r\n await this.findSchemaItem(mixinName);\r\n }\r\n\r\n await this.loadClass(entity, entityClassProps, rawEntity);\r\n }\r\n\r\n /**\r\n * Load the mixin, base class, and property type dependencies for an EntityClass object and load the EntityClass (and properties) from its serialized format.\r\n * @param entity The EntityClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawEntity The serialized entity class data.\r\n */\r\n private loadEntityClassSync(entity: EntityClass, rawEntity: Readonly<unknown>): void {\r\n const entityClassProps = this._parser.parseEntityClass(rawEntity);\r\n\r\n // Load Mixin classes first\r\n if (undefined !== entityClassProps.mixins) {\r\n for (const mixinName of entityClassProps.mixins)\r\n this.findSchemaItemSync(mixinName);\r\n }\r\n\r\n this.loadClassSync(entity, entityClassProps, rawEntity);\r\n }\r\n\r\n /**\r\n * Load the appliesTo class, base class, and property type dependencies for a Mixin object and load the Mixin (and properties) from its serialized format.\r\n * @param mixin The Mixin that we are loading dependencies for and \"deserializing into\".\r\n * @param rawMixin The serialized mixin data.\r\n */\r\n private async loadMixin(mixin: Mixin, rawMixin: Readonly<unknown>): Promise<void> {\r\n const mixinProps = this._parser.parseMixin(rawMixin);\r\n\r\n const appliesToLoaded = async (appliesToClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchemaPart(appliesToClass);\r\n };\r\n\r\n await this.findSchemaItem(mixinProps.appliesTo, true, appliesToLoaded);\r\n\r\n await this.loadClass(mixin, mixinProps, rawMixin);\r\n }\r\n\r\n /**\r\n * Load the appliesTo class, base class, and property type dependencies for a Mixin object and load the Mixin (and properties) from its serialized format.\r\n * @param mixin The Mixin that we are loading dependencies for and \"deserializing into\".\r\n * @param rawMixin The serialized mixin data.\r\n */\r\n private loadMixinSync(mixin: Mixin, rawMixin: Readonly<unknown>): void {\r\n const mixinProps = this._parser.parseMixin(rawMixin);\r\n\r\n const appliesToLoaded = async (appliesToClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchemaPart(appliesToClass);\r\n };\r\n\r\n this.findSchemaItemSync(mixinProps.appliesTo, true, appliesToLoaded);\r\n\r\n this.loadClassSync(mixin, mixinProps, rawMixin);\r\n }\r\n\r\n /**\r\n * Load the relationship constraint, base class, and property type dependencies for a RelationshipClass object and load the RelationshipClass (and properties) from its serialized format.\r\n * @param rel The RelationshipClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawRel The serialized relationship class data.\r\n */\r\n private async loadRelationshipClass(rel: RelationshipClass, rawRel: Readonly<unknown>): Promise<void> {\r\n const relationshipClassProps = this._parser.parseRelationshipClass(rawRel);\r\n await this.loadClass(rel, relationshipClassProps, rawRel);\r\n await this.loadRelationshipConstraint(rel.source, relationshipClassProps.source);\r\n await this.loadRelationshipConstraint(rel.target, relationshipClassProps.target);\r\n\r\n const [sourceCustomAttributes, targetCustomAttributes] = this._parser.getRelationshipConstraintCustomAttributeProviders(rawRel);\r\n await this.loadCustomAttributes(rel.source, sourceCustomAttributes);\r\n await this.loadCustomAttributes(rel.target, targetCustomAttributes);\r\n }\r\n\r\n /**\r\n * Load the relationship constraint, base class, and property type dependencies for a RelationshipClass object and load the RelationshipClass (and properties) from its serialized format.\r\n * @param rel The RelationshipClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawRel The serialized relationship class data.\r\n */\r\n private loadRelationshipClassSync(rel: RelationshipClass, rawRel: Readonly<unknown>): void {\r\n const relationshipClassProps = this._parser.parseRelationshipClass(rawRel);\r\n this.loadClassSync(rel, relationshipClassProps, rawRel);\r\n this.loadRelationshipConstraintSync(rel.source, relationshipClassProps.source);\r\n this.loadRelationshipConstraintSync(rel.target, relationshipClassProps.target);\r\n\r\n const [sourceCustomAttributes, targetCustomAttributes] = this._parser.getRelationshipConstraintCustomAttributeProviders(rawRel);\r\n this.loadCustomAttributesSync(rel.source, sourceCustomAttributes);\r\n this.loadCustomAttributesSync(rel.target, targetCustomAttributes);\r\n }\r\n\r\n /**\r\n * Load the abstract constraint and constraint class dependencies for a RelationshipConstraint object and load the RelationshipConstraint from its parsed props.\r\n * @param relConstraint The RelationshipConstraint that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed relationship constraint props.\r\n */\r\n private async loadRelationshipConstraint(relConstraint: RelationshipConstraint, props: RelationshipConstraintProps): Promise<void> {\r\n if (undefined !== props.abstractConstraint) {\r\n await this.findSchemaItem(props.abstractConstraint);\r\n }\r\n if (undefined !== props.constraintClasses) { // TODO: this should be required\r\n for (const constraintClass of props.constraintClasses) {\r\n await this.findSchemaItem(constraintClass);\r\n }\r\n }\r\n await relConstraint.fromJSON(props);\r\n }\r\n\r\n /**\r\n * Load the abstract constraint and constraint class dependencies for a RelationshipConstraint object and load the RelationshipConstraint from its parsed props.\r\n * @param relConstraint The RelationshipConstraint that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed relationship constraint props.\r\n */\r\n private loadRelationshipConstraintSync(relConstraint: RelationshipConstraint, props: RelationshipConstraintProps): void {\r\n if (undefined !== props.abstractConstraint) {\r\n this.findSchemaItemSync(props.abstractConstraint);\r\n }\r\n if (undefined !== props.constraintClasses) {\r\n for (const constraintClass of props.constraintClasses) {\r\n this.findSchemaItemSync(constraintClass);\r\n }\r\n }\r\n\r\n relConstraint.fromJSONSync(props);\r\n }\r\n\r\n /**\r\n * Load the type dependencies for a serialized property, then creates and deserialized the Property object in the given ECClass.\r\n * @param classObj The ECClass that the Property should be created in.\r\n * @param propName The name of the Property.\r\n * @param propType The (serialized string) kind of property to create.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private async loadPropertyTypes(classObj: AnyClass, propName: string, propType: string, rawProperty: Readonly<unknown>): Promise<void> {\r\n\r\n const loadTypeName = async (typeName: string) => {\r\n if (undefined === parsePrimitiveType(typeName))\r\n await this.findSchemaItem(typeName);\r\n };\r\n\r\n const lowerCasePropType = propType.toLowerCase();\r\n\r\n switch (lowerCasePropType) {\r\n case \"primitiveproperty\":\r\n const primPropertyProps = this._parser.parsePrimitiveProperty(rawProperty);\r\n await loadTypeName(primPropertyProps.typeName);\r\n const primProp = await (classObj as MutableClass).createPrimitiveProperty(propName, primPropertyProps.typeName);\r\n return this.loadProperty(primProp, primPropertyProps, rawProperty);\r\n\r\n case \"structproperty\":\r\n const structPropertyProps = this._parser.parseStructProperty(rawProperty);\r\n await loadTypeName(structPropertyProps.typeName);\r\n const structProp = await (classObj as MutableClass).createStructProperty(propName, structPropertyProps.typeName);\r\n return this.loadProperty(structProp, structPropertyProps, rawProperty);\r\n\r\n case \"primitivearrayproperty\":\r\n const primArrPropertyProps = this._parser.parsePrimitiveArrayProperty(rawProperty);\r\n await loadTypeName(primArrPropertyProps.typeName);\r\n const primArrProp = await (classObj as MutableClass).createPrimitiveArrayProperty(propName, primArrPropertyProps.typeName);\r\n return this.loadProperty(primArrProp, primArrPropertyProps, rawProperty);\r\n\r\n case \"structarrayproperty\":\r\n const structArrPropertyProps = this._parser.parseStructArrayProperty(rawProperty);\r\n await loadTypeName(structArrPropertyProps.typeName);\r\n const structArrProp = await (classObj as MutableClass).createStructArrayProperty(propName, structArrPropertyProps.typeName);\r\n return this.loadProperty(structArrProp, structArrPropertyProps, rawProperty);\r\n\r\n case \"navigationproperty\":\r\n if (classObj.schemaItemType !== SchemaItemType.EntityClass && classObj.schemaItemType !== SchemaItemType.RelationshipClass && classObj.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Navigation Property ${classObj.name}.${propName} is invalid, because only EntityClasses, Mixins, and RelationshipClasses can have NavigationProperties.`);\r\n\r\n const navPropertyProps = this._parser.parseNavigationProperty(rawProperty);\r\n await this.findSchemaItem(navPropertyProps.relationshipName);\r\n const navProp = await (classObj as MutableEntityClass).createNavigationProperty(propName, navPropertyProps.relationshipName, navPropertyProps.direction);\r\n return this.loadProperty(navProp, navPropertyProps, rawProperty);\r\n }\r\n }\r\n\r\n /**\r\n * Load the type dependencies for a serialized property, then creates and deserialized the Property object in the given ECClass.\r\n * @param classObj The ECClass that the Property should be created in.\r\n * @param propName The name of the Property.\r\n * @param propType The (serialized string) kind of property to create.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private loadPropertyTypesSync(classObj: AnyClass, propName: string, propType: string, rawProperty: Readonly<unknown>): void {\r\n const loadTypeName = (typeName: string) => {\r\n if (undefined === parsePrimitiveType(typeName))\r\n this.findSchemaItemSync(typeName);\r\n };\r\n\r\n const lowerCasePropType = propType.toLowerCase();\r\n\r\n switch (lowerCasePropType) {\r\n case \"primitiveproperty\":\r\n const primPropertyProps = this._parser.parsePrimitiveProperty(rawProperty);\r\n loadTypeName(primPropertyProps.typeName);\r\n const primProp = (classObj as MutableClass).createPrimitivePropertySync(propName, primPropertyProps.typeName);\r\n return this.loadPropertySync(primProp, primPropertyProps, rawProperty);\r\n\r\n case \"structproperty\":\r\n const structPropertyProps = this._parser.parseStructProperty(rawProperty);\r\n loadTypeName(structPropertyProps.typeName);\r\n const structProp = (classObj as MutableClass).createStructPropertySync(propName, structPropertyProps.typeName);\r\n return this.loadPropertySync(structProp, structPropertyProps, rawProperty);\r\n\r\n case \"primitivearrayproperty\":\r\n const primArrPropertyProps = this._parser.parsePrimitiveArrayProperty(rawProperty);\r\n loadTypeName(primArrPropertyProps.typeName);\r\n const primArrProp = (classObj as MutableClass).createPrimitiveArrayPropertySync(propName, primArrPropertyProps.typeName);\r\n return this.loadPropertySync(primArrProp, primArrPropertyProps, rawProperty);\r\n\r\n case \"structarrayproperty\":\r\n const structArrPropertyProps = this._parser.parseStructArrayProperty(rawProperty);\r\n loadTypeName(structArrPropertyProps.typeName);\r\n const structArrProp = (classObj as MutableClass).createStructArrayPropertySync(propName, structArrPropertyProps.typeName);\r\n return this.loadPropertySync(structArrProp, structArrPropertyProps, rawProperty);\r\n\r\n case \"navigationproperty\":\r\n if (classObj.schemaItemType !== SchemaItemType.EntityClass && classObj.schemaItemType !== SchemaItemType.RelationshipClass && classObj.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Navigation Property ${classObj.name}.${propName} is invalid, because only EntityClasses, Mixins, and RelationshipClasses can have NavigationProperties.`);\r\n\r\n const navPropertyProps = this._parser.parseNavigationProperty(rawProperty);\r\n this.findSchemaItemSync(navPropertyProps.relationshipName);\r\n const navProp = (classObj as MutableEntityClass).createNavigationPropertySync(propName, navPropertyProps.relationshipName, navPropertyProps.direction);\r\n return this.loadPropertySync(navProp, navPropertyProps, rawProperty);\r\n }\r\n }\r\n\r\n /**\r\n * Load the propertyCategory, kindOfQuantity, and customAttribute dependencies for a Property object and load the Property from its parsed props.\r\n * @param propertyObj The Property that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed property props.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private async loadProperty<U extends Property>(propertyObj: U, props: PropertyProps, rawProperty: Readonly<unknown>): Promise<void> {\r\n if (undefined !== props.category) {\r\n await this.findSchemaItem(props.category);\r\n }\r\n\r\n if (undefined !== props.kindOfQuantity) {\r\n await this.findSchemaItem(props.kindOfQuantity);\r\n }\r\n\r\n await propertyObj.fromJSON(props);\r\n await this.loadCustomAttributes(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));\r\n }\r\n\r\n /**\r\n * Load the propertyCategory, kindOfQuantity, and customAttribute dependencies for a Property object and load the Property from its parsed props.\r\n * @param propertyObj The Property that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed property props.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private loadPropertySync<U extends Property>(propertyObj: U, props: PropertyProps, rawProperty: Readonly<unknown>): void {\r\n if (undefined !== props.category) {\r\n this.findSchemaItemSync(props.category);\r\n }\r\n\r\n if (undefined !== props.kindOfQuantity) {\r\n this.findSchemaItemSync(props.kindOfQuantity);\r\n }\r\n\r\n propertyObj.fromJSONSync(props);\r\n this.loadCustomAttributesSync(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));\r\n }\r\n\r\n /**\r\n * Load the customAttribute class dependencies for a set of CustomAttribute objects and add\r\n * them to a given custom attribute container.\r\n * @param container The CustomAttributeContainer that each CustomAttribute will be added to.\r\n * @param customAttributes An iterable set of parsed CustomAttribute objects.\r\n */\r\n private async loadCustomAttributes(container: AnyCAContainer, caProviders: Iterable<CAProviderTuple>): Promise<void> {\r\n for (const providerTuple of caProviders) {\r\n // First tuple entry is the CA class name.\r\n const caClass = await this.findSchemaItem(providerTuple[0]);\r\n\r\n // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema\r\n if (caClass && caClass.key.schemaName !== container.schema.name &&\r\n !container.schema.getReferenceSync(caClass.key.schemaName)) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to load custom attribute ${caClass.fullName} from container ${container.fullName}, ${caClass.key.schemaName} reference not defined`);\r\n }\r\n\r\n // Second tuple entry ia a function that provides the CA instance.\r\n const provider = providerTuple[1];\r\n const customAttribute = provider(caClass as CustomAttributeClass);\r\n\r\n (container as AnyMutableCAContainer).addCustomAttribute(customAttribute);\r\n }\r\n }\r\n\r\n /**\r\n * Load the customAttribute class dependencies for a set of CustomAttribute objects and add them to a given custom attribute container.\r\n * @param container The CustomAttributeContainer that each CustomAttribute will be added to.\r\n * @param customAttributes An iterable set of parsed CustomAttribute objects.\r\n */\r\n private loadCustomAttributesSync(container: AnyCAContainer, caProviders: Iterable<CAProviderTuple>): void {\r\n for (const providerTuple of caProviders) {\r\n // First tuple entry is the CA class name.\r\n const caClass = this.findSchemaItemSync(providerTuple[0]) as CustomAttributeClass;\r\n\r\n // Second tuple entry ia a function that provides the CA instance.\r\n const provider = providerTuple[1];\r\n const customAttribute = provider(caClass);\r\n (container as AnyMutableCAContainer).addCustomAttribute(customAttribute);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Helper.js","sourceRoot":"","sources":["../../../src/Deserialization/Helper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wCAA2C;AAC3C,4CAAwG;AACxG,4CAA+D;AAa/D,uDAAoD;AAEpD,4CAAmE;AACnE,4EAA6F;AAC7F,wDAAoE;AAGpE,sDAAmD;AAKnD;;;;GAIG;AACH,MAAa,gBAAgB;IAW3B,YAAY,UAAwC,EAAE,OAAuB,EAAE,OAA4B;QACzG,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,uBAAa,EAAE,CAAC;QACxE,IAAI,CAAC,cAAc,GAAG,OA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E,CAAC;IACH,CAAC;CACF;AAh/BD,4CAg/BC","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 { SchemaContext } from \"../Context\";\r\nimport { parsePrimitiveType, parseSchemaItemType, SchemaItemType, SchemaMatchType } from \"../ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"../Exception\";\r\nimport { AnyClass, AnySchemaItem, SchemaInfo } from \"../Interfaces\";\r\nimport { ECClass, MutableClass } from \"../Metadata/Class\";\r\nimport { Constant } from \"../Metadata/Constant\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\nimport { EntityClass, MutableEntityClass } from \"../Metadata/EntityClass\";\r\nimport { Format } from \"../Metadata/Format\";\r\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\r\nimport { KindOfQuantity } from \"../Metadata/KindOfQuantity\";\r\nimport { Mixin } from \"../Metadata/Mixin\";\r\nimport { MutableProperty, Property } from \"../Metadata/Property\";\r\nimport { MutableRelationshipConstraint, RelationshipClass, RelationshipConstraint } from \"../Metadata/RelationshipClass\";\r\nimport { MutableSchema, Schema } from \"../Metadata/Schema\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { Unit } from \"../Metadata/Unit\";\r\nimport { ECVersion, SchemaItemKey, SchemaKey } from \"../SchemaKey\";\r\nimport { ISchemaPartVisitor, SchemaPartVisitorDelegate } from \"../SchemaPartVisitorDelegate\";\r\nimport { getItemNamesFromFormatString } from \"@itwin/core-quantity\";\r\nimport { AbstractParser, AbstractParserConstructor, CAProviderTuple } from \"./AbstractParser\";\r\nimport { ClassProps, PropertyProps, RelationshipConstraintProps, SchemaReferenceProps } from \"./JsonProps\";\r\nimport { SchemaGraph } from \"../utils/SchemaGraph\";\r\n\r\ntype AnyCAContainer = Schema | ECClass | Property | RelationshipConstraint;\r\ntype AnyMutableCAContainer = MutableSchema | MutableClass | MutableProperty | MutableRelationshipConstraint;\r\n\r\n/**\r\n * This class properly handles the order the deserialization of ECSchemas and SchemaItems from serialized formats.\r\n * For example, when deserializing an ECClass most times all base class should be de-serialized before the given class.\r\n * @internal\r\n */\r\nexport class SchemaReadHelper<T = unknown> {\r\n private _context: SchemaContext;\r\n private _visitorHelper?: SchemaPartVisitorDelegate;\r\n private _parserType: AbstractParserConstructor<T, unknown>;\r\n private _parser!: AbstractParser<unknown>;\r\n\r\n // Cache of the schema currently being loaded. This schema is in the _context but to\r\n // avoid going back to the context every time, the cache is used.\r\n private _schema?: Schema;\r\n private _schemaInfo?: SchemaInfo;\r\n\r\n constructor(parserType: AbstractParserConstructor<T>, context?: SchemaContext, visitor?: ISchemaPartVisitor) {\r\n this._context = (undefined !== context) ? context : new SchemaContext();\r\n this._visitorHelper = visitor ? new SchemaPartVisitorDelegate(visitor) : undefined;\r\n this._parserType = parserType;\r\n }\r\n\r\n /**\r\n * Creates a complete SchemaInfo and starts parsing the schema from a serialized representation.\r\n * The info and schema promise will be registered with the SchemaContext. The complete schema can be retrieved by\r\n * calling getCachedSchema on the context.\r\n * @param schema The Schema to populate\r\n * @param rawSchema The serialized data to use to populate the Schema.\r\n */\r\n public async readSchemaInfo<U extends Schema>(schema: U, rawSchema: T): Promise<SchemaInfo> {\r\n // Ensure context matches schema context\r\n if (schema.context) {\r\n if (this._context !== schema.context)\r\n throw new ECObjectsError(ECObjectsStatus.DifferentSchemaContexts, \"The SchemaContext of the schema must be the same SchemaContext held by the SchemaReadHelper.\");\r\n } else {\r\n (schema as Schema as MutableSchema).setContext(this._context);\r\n }\r\n\r\n this._parser = new this._parserType(rawSchema);\r\n\r\n // Loads all of the properties on the Schema object\r\n await schema.fromJSON(this._parser.parseSchema());\r\n\r\n this._schema = schema;\r\n\r\n const schemaInfo: SchemaInfo = { schemaKey: schema.schemaKey, references: [] };\r\n for (const reference of this._parser.getReferences()) {\r\n const refKey = new SchemaKey(reference.name, ECVersion.fromString(reference.version));\r\n schemaInfo.references.push({ schemaKey: refKey });\r\n }\r\n\r\n this._schemaInfo = schemaInfo;\r\n\r\n // Need to add this schema to the context to be able to locate schemaItems within the context.\r\n if (!this._context.schemaExists(schema.schemaKey)) {\r\n await this._context.addSchemaPromise(schemaInfo, schema, this.loadSchema(schemaInfo, schema));\r\n }\r\n return schemaInfo;\r\n }\r\n\r\n /**\r\n * Populates the given Schema from a serialized representation.\r\n * @param schema The Schema to populate\r\n * @param rawSchema The serialized data to use to populate the Schema.\r\n */\r\n public async readSchema<U extends Schema>(schema: U, rawSchema: T): Promise<U> {\r\n if (!this._schemaInfo) {\r\n await this.readSchemaInfo(schema, rawSchema);\r\n }\r\n\r\n const cachedSchema = await this._context.getCachedSchema<U>(this._schemaInfo!.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === cachedSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);\r\n\r\n return cachedSchema;\r\n }\r\n\r\n /* Finish loading the rest of the schema */\r\n private async loadSchema<U extends Schema>(schemaInfo: SchemaInfo, schema: U): Promise<U> {\r\n // Verify that there are no schema reference cycles, this will start schema loading by loading their headers\r\n (await SchemaGraph.generateGraph(schemaInfo, this._context)).throwIfCycles();\r\n\r\n for (const reference of schemaInfo.references) {\r\n await this.loadSchemaReference(schemaInfo, reference.schemaKey);\r\n }\r\n\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchema(schema, false);\r\n\r\n // Load all schema items\r\n for (const [itemName, itemType, rawItem] of this._parser.getItems()) {\r\n // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,\r\n // which would be found when adding to the context.\r\n if (await schema.getItem(itemName) !== undefined)\r\n continue;\r\n\r\n const loadedItem = await this.loadSchemaItem(schema, itemName, itemType, rawItem);\r\n if (loadedItem && this._visitorHelper) {\r\n await this._visitorHelper.visitSchemaPart(loadedItem);\r\n }\r\n }\r\n\r\n await this.loadCustomAttributes(schema, this._parser.getSchemaCustomAttributeProviders());\r\n\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchema(schema);\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Populates the given Schema from a serialized representation.\r\n * @param schema The Schema to populate\r\n * @param rawSchema The serialized data to use to populate the Schema.\r\n */\r\n public readSchemaSync<U extends Schema>(schema: U, rawSchema: T): U {\r\n this._parser = new this._parserType(rawSchema);\r\n\r\n // Loads all of the properties on the Schema object\r\n schema.fromJSONSync(this._parser.parseSchema());\r\n\r\n this._schema = schema;\r\n\r\n // Need to add this schema to the context to be able to locate schemaItems within the context.\r\n if (!this._context.schemaExists(schema.schemaKey))\r\n this._context.addSchemaSync(schema);\r\n\r\n // Load schema references first\r\n // Need to figure out if other schemas are present.\r\n for (const reference of this._parser.getReferences()) {\r\n this.loadSchemaReferenceSync(reference);\r\n }\r\n\r\n if (this._visitorHelper)\r\n this._visitorHelper.visitSchemaSync(schema, false);\r\n\r\n // Load all schema items\r\n for (const [itemName, itemType, rawItem] of this._parser.getItems()) {\r\n // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,\r\n // which would be found when adding to the context.\r\n if (schema.getItemSync(itemName) !== undefined)\r\n continue;\r\n\r\n const loadedItem = this.loadSchemaItemSync(schema, itemName, itemType, rawItem);\r\n if (loadedItem && this._visitorHelper) {\r\n this._visitorHelper.visitSchemaPartSync(loadedItem);\r\n }\r\n }\r\n\r\n this.loadCustomAttributesSync(schema, this._parser.getSchemaCustomAttributeProviders());\r\n\r\n if (this._visitorHelper)\r\n this._visitorHelper.visitSchemaSync(schema);\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Ensures that the schema references can be located and adds them to the schema.\r\n * @param ref The object to read the SchemaReference's props from.\r\n */\r\n private async loadSchemaReference(schemaInfo: SchemaInfo, refKey: Readonly<SchemaKey>): Promise<void> {\r\n const refSchema = await this._context.getSchema(refKey, SchemaMatchType.LatestWriteCompatible);\r\n if (undefined === refSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refKey.name}.${refKey.version.toString()}, of ${schemaInfo.schemaKey.name}`);\r\n\r\n await (this._schema as MutableSchema).addReference(refSchema);\r\n const results = this.validateSchemaReferences(this._schema!);\r\n\r\n let errorMessage: string = \"\";\r\n for (const result of results) {\r\n errorMessage += `${result}\\r\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `${errorMessage}`);\r\n }\r\n }\r\n\r\n /**\r\n * Ensures that the schema references can be located and adds them to the schema.\r\n * @param ref The object to read the SchemaReference's props from.\r\n */\r\n private loadSchemaReferenceSync(ref: SchemaReferenceProps): void {\r\n const schemaKey = new SchemaKey(ref.name, ECVersion.fromString(ref.version));\r\n const refSchema = this._context.getSchemaSync(schemaKey, SchemaMatchType.LatestWriteCompatible);\r\n if (!refSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${this._schema!.schemaKey.name}`);\r\n\r\n (this._schema as MutableSchema).addReferenceSync(refSchema);\r\n\r\n SchemaGraph.generateGraphSync(this._schema!).throwIfCycles();\r\n const results = this.validateSchemaReferences(this._schema!);\r\n\r\n let errorMessage: string = \"\";\r\n for (const result of results) {\r\n errorMessage += `${result}\\r\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `${errorMessage}`);\r\n }\r\n }\r\n\r\n /**\r\n * Validates schema references against multiple EC rules.\r\n * @param schema The schema to validate.\r\n */\r\n private *validateSchemaReferences(schema: Schema): Iterable<string> {\r\n const aliases = new Map();\r\n for (const schemaRef of schema.references) {\r\n if (schemaRef.customAttributes && schemaRef.customAttributes.has(\"CoreCustomAttributes.SupplementalSchema\"))\r\n yield `Referenced schema '${schemaRef.name}' of schema '${schema.name}' is a supplemental schema. Supplemental schemas are not allowed to be referenced.`;\r\n\r\n if (schema.schemaKey.matches(schemaRef.schemaKey))\r\n yield `Schema '${schema.name}' has reference cycles: '${schema.name} --> ${schemaRef.name}'`;\r\n\r\n if (aliases.has(schemaRef.alias)) {\r\n const currentRef = aliases.get(schemaRef.alias);\r\n yield `Schema '${schema.name}' has multiple schema references (${currentRef.name}, $schemaRef.name}) with the same alias '${schemaRef.alias}', which is not allowed.`;\r\n } else {\r\n aliases.set(schemaRef.alias, schemaRef);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.\r\n * @param schema The Schema the SchemaItem to.\r\n * @param name The name of the schema item to be loaded.\r\n * @param itemType The SchemaItemType of the item to load.\r\n * @param schemaItemObject The Object to populate the SchemaItem with.\r\n */\r\n private async loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): Promise<SchemaItem | undefined> {\r\n let schemaItem: AnySchemaItem | undefined;\r\n\r\n switch (parseSchemaItemType(itemType)) {\r\n case SchemaItemType.EntityClass:\r\n schemaItem = await (schema as MutableSchema).createEntityClass(name);\r\n await this.loadEntityClass(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.StructClass:\r\n schemaItem = await (schema as MutableSchema).createStructClass(name);\r\n const structProps = this._parser.parseStructClass(schemaItemObject);\r\n await this.loadClass(schemaItem, structProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.Mixin:\r\n schemaItem = await (schema as MutableSchema).createMixinClass(name);\r\n await this.loadMixin(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.CustomAttributeClass:\r\n schemaItem = await (schema as MutableSchema).createCustomAttributeClass(name);\r\n const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);\r\n await this.loadClass(schemaItem, caClassProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n schemaItem = await (schema as MutableSchema).createRelationshipClass(name);\r\n await this.loadRelationshipClass(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n schemaItem = await (schema as MutableSchema).createKindOfQuantity(name);\r\n await this.loadKindOfQuantity(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Unit:\r\n schemaItem = await (schema as MutableSchema).createUnit(name);\r\n await this.loadUnit(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Constant:\r\n schemaItem = await (schema as MutableSchema).createConstant(name);\r\n await this.loadConstant(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n schemaItem = await (schema as MutableSchema).createInvertedUnit(name);\r\n await this.loadInvertedUnit(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Format:\r\n schemaItem = await (schema as MutableSchema).createFormat(name);\r\n await this.loadFormat(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n schemaItem = await (schema as MutableSchema).createPhenomenon(name);\r\n const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);\r\n await schemaItem.fromJSON(phenomenonProps);\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n schemaItem = await (schema as MutableSchema).createUnitSystem(name);\r\n await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n schemaItem = await (schema as MutableSchema).createPropertyCategory(name);\r\n const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);\r\n await schemaItem.fromJSON(propertyCategoryProps);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n schemaItem = await (schema as MutableSchema).createEnumeration(name);\r\n const enumerationProps = this._parser.parseEnumeration(schemaItemObject);\r\n await schemaItem.fromJSON(enumerationProps);\r\n break;\r\n // NOTE: we are being permissive here and allowing unknown types to silently fail. Not sure if we want to hard fail or just do a basic deserialization\r\n }\r\n\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.\r\n * @param schema The Schema the SchemaItem to.\r\n * @param name The name of the schema item to be loaded.\r\n * @param itemType The SchemaItemType of the item to load.\r\n * @param schemaItemObject The Object to populate the SchemaItem with.\r\n */\r\n private loadSchemaItemSync(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): SchemaItem | undefined {\r\n let schemaItem: AnySchemaItem | undefined;\r\n\r\n switch (parseSchemaItemType(itemType)) {\r\n case SchemaItemType.EntityClass:\r\n schemaItem = (schema as MutableSchema).createEntityClassSync(name);\r\n this.loadEntityClassSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.StructClass:\r\n schemaItem = (schema as MutableSchema).createStructClassSync(name);\r\n const structProps = this._parser.parseStructClass(schemaItemObject);\r\n this.loadClassSync(schemaItem, structProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.Mixin:\r\n schemaItem = (schema as MutableSchema).createMixinClassSync(name);\r\n this.loadMixinSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.CustomAttributeClass:\r\n schemaItem = (schema as MutableSchema).createCustomAttributeClassSync(name);\r\n const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);\r\n this.loadClassSync(schemaItem, caClassProps, schemaItemObject);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n schemaItem = (schema as MutableSchema).createRelationshipClassSync(name);\r\n this.loadRelationshipClassSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n schemaItem = (schema as MutableSchema).createKindOfQuantitySync(name);\r\n this.loadKindOfQuantitySync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Unit:\r\n schemaItem = (schema as MutableSchema).createUnitSync(name);\r\n this.loadUnitSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Constant:\r\n schemaItem = (schema as MutableSchema).createConstantSync(name);\r\n this.loadConstantSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n schemaItem = (schema as MutableSchema).createInvertedUnitSync(name);\r\n this.loadInvertedUnitSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Format:\r\n schemaItem = (schema as MutableSchema).createFormatSync(name);\r\n this.loadFormatSync(schemaItem, schemaItemObject);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n schemaItem = (schema as MutableSchema).createPhenomenonSync(name);\r\n const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);\r\n schemaItem.fromJSONSync(phenomenonProps);\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n schemaItem = (schema as MutableSchema).createUnitSystemSync(name);\r\n schemaItem.fromJSONSync(this._parser.parseUnitSystem(schemaItemObject));\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n schemaItem = (schema as MutableSchema).createPropertyCategorySync(name);\r\n const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);\r\n schemaItem.fromJSONSync(propertyCategoryProps);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n schemaItem = (schema as MutableSchema).createEnumerationSync(name);\r\n const enumerationProps = this._parser.parseEnumeration(schemaItemObject);\r\n schemaItem.fromJSONSync(enumerationProps);\r\n break;\r\n // NOTE: we are being permissive here and allowing unknown types to silently fail. Not sure if we want to hard fail or just do a basic deserialization\r\n }\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Given the full (Schema.ItemName) or qualified (alias:ItemName) item name, returns\r\n * a tuple of strings in the format [\"SchemaName\", \"ItemName\"]. The schema name may be\r\n * empty if the item comes from the schema being parsed.\r\n * @param fullOrQualifiedName The full or qualified name of the schema item.\r\n * @param schema The schema that will be used to lookup the schema name by alias, if necessary.\r\n */\r\n private static resolveSchemaAndItemName(fullOrQualifiedName: string, schema?: Schema): [string, string] {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(fullOrQualifiedName);\r\n\r\n // If a schema is provided we attempt to resolve the alias by looking at the reference schemas.\r\n if (undefined !== schema && -1 !== fullOrQualifiedName.indexOf(\":\")) {\r\n const refName = schema.getReferenceNameByAlias(schemaName);\r\n if (undefined === refName)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not resolve schema alias '${schemaName}' for schema item '${itemName}.`);\r\n return [refName, itemName];\r\n }\r\n\r\n return [schemaName, itemName];\r\n }\r\n\r\n /**\r\n * Finds the a SchemaItem matching the name first by checking the schema that is being deserialized. If it does\r\n * not exist within the schema, the SchemaContext will be searched.\r\n * @param name The full (Schema.ItemName) or qualified (alias:ItemName) name of the SchemaItem to search for.\r\n * @param skipVisitor Used to break Mixin -appliesTo-> Entity -extends-> Mixin cycle.\r\n * @param loadCallBack Only called if the SchemaItem had to be loaded.\r\n * @return The SchemaItem if it had to be loaded, otherwise undefined.\r\n */\r\n private async findSchemaItem(name: string, skipVisitor = false, loadCallBack?: (item: SchemaItem) => void): Promise<SchemaItem | undefined> {\r\n let schemaItem: SchemaItem | undefined;\r\n // TODO: A better solution should be investigated for handling both an alias and the schema name.\r\n const [schemaName, itemName] = SchemaReadHelper.resolveSchemaAndItemName(name, this._schema);\r\n const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());\r\n\r\n if (undefined === schemaName || 0 === schemaName.length)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);\r\n\r\n if (isInThisSchema) {\r\n schemaItem = await this._schema!.getItem(itemName);\r\n if (schemaItem)\r\n return schemaItem;\r\n\r\n const foundItem = this._parser.findItem(itemName);\r\n if (foundItem) {\r\n schemaItem = await this.loadSchemaItem(this._schema!, ...foundItem);\r\n if (!skipVisitor && schemaItem && this._visitorHelper) {\r\n await this._visitorHelper.visitSchemaPart(schemaItem);\r\n }\r\n if (loadCallBack && schemaItem)\r\n loadCallBack(schemaItem);\r\n\r\n return schemaItem;\r\n }\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n }\r\n\r\n schemaItem = await this._context.getSchemaItem(new SchemaItemKey(itemName, new SchemaKey(schemaName)));\r\n if (undefined === schemaItem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Finds the a SchemaItem matching the name first by checking the schema that is being deserialized. If it does\r\n * not exist within the schema, the SchemaContext will be searched.\r\n * @param name The full (Schema.ItemName) or qualified (alias:ItemName) name of the SchemaItem to search for.\r\n * @param skipVisitor Used to break Mixin -appliesTo-> Entity -extends-> Mixin cycle.\r\n * @param loadCallBack Only called if the SchemaItem had to be loaded.\r\n * @return The SchemaItem if it had to be loaded, otherwise undefined.\r\n */\r\n private findSchemaItemSync(name: string, skipVisitor = false, loadCallBack?: (item: SchemaItem) => void): SchemaItem | undefined {\r\n let schemaItem: SchemaItem | undefined;\r\n // TODO: A better solution should be investigated for handling both an alias and the schema name.\r\n const [schemaName, itemName] = SchemaReadHelper.resolveSchemaAndItemName(name, this._schema);\r\n const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());\r\n\r\n if (undefined === schemaName || schemaName.length === 0)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);\r\n\r\n if (isInThisSchema && undefined === this._schema!.getItemSync(itemName)) {\r\n const foundItem = this._parser.findItem(itemName);\r\n if (foundItem) {\r\n schemaItem = this.loadSchemaItemSync(this._schema!, ...foundItem);\r\n if (!skipVisitor && schemaItem && this._visitorHelper) {\r\n this._visitorHelper.visitSchemaPartSync(schemaItem);\r\n }\r\n if (loadCallBack && schemaItem)\r\n loadCallBack(schemaItem);\r\n\r\n return schemaItem;\r\n }\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n }\r\n\r\n schemaItem = this._context.getSchemaItemSync(new SchemaItemKey(itemName, new SchemaKey(schemaName)));\r\n if (undefined === schemaItem)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);\r\n\r\n return schemaItem;\r\n }\r\n\r\n /**\r\n * Load dependencies on phenomenon and unitSystem for a Unit object and load the Unit from its serialized format.\r\n * @param unit The Unit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawUnit The serialized unit data\r\n */\r\n private async loadUnit(unit: Unit, rawUnit: Readonly<unknown>): Promise<void> {\r\n const unitProps = this._parser.parseUnit(rawUnit);\r\n\r\n await this.findSchemaItem(unitProps.phenomenon, true);\r\n await this.findSchemaItem(unitProps.unitSystem, true);\r\n\r\n await unit.fromJSON(unitProps);\r\n }\r\n\r\n /**\r\n * Load dependencies on phenomenon and unitSystem for a Unit object and load the Unit from its serialized format.\r\n * @param unit The Unit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawUnit The serialized unit data\r\n */\r\n private loadUnitSync(unit: Unit, rawUnit: Readonly<unknown>) {\r\n const unitProps = this._parser.parseUnit(rawUnit);\r\n\r\n this.findSchemaItemSync(unitProps.phenomenon, true);\r\n this.findSchemaItemSync(unitProps.unitSystem, true);\r\n\r\n unit.fromJSONSync(unitProps);\r\n }\r\n\r\n /**\r\n * Load the persistence unit and presentation unit dependencies for a KindOfQuantity object and load the KoQ from its serialized format.\r\n * @param koq The KindOfQuantity object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawKoQ The serialized kind of quantity data\r\n */\r\n private async loadKindOfQuantity(koq: KindOfQuantity, rawKoQ: Readonly<unknown>): Promise<void> {\r\n const koqProps = this._parser.parseKindOfQuantity(rawKoQ);\r\n await this.findSchemaItem(koqProps.persistenceUnit);\r\n\r\n if (undefined !== koqProps.presentationUnits) {\r\n for (const formatString of koqProps.presentationUnits) {\r\n for (const name of getItemNamesFromFormatString(formatString)) {\r\n await this.findSchemaItem(name);\r\n }\r\n }\r\n }\r\n\r\n await koq.fromJSON(koqProps);\r\n }\r\n\r\n /**\r\n * Load the persistence unit and presentation unit dependencies for a KindOfQuantity object and load the KoQ from its serialized format.\r\n * @param koq The KindOfQuantity object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawKoQ The serialized kind of quantity data\r\n */\r\n private loadKindOfQuantitySync(koq: KindOfQuantity, rawKoQ: Readonly<unknown>) {\r\n const koqProps = this._parser.parseKindOfQuantity(rawKoQ);\r\n this.findSchemaItemSync(koqProps.persistenceUnit);\r\n\r\n if (undefined !== koqProps.presentationUnits) {\r\n for (const formatString of koqProps.presentationUnits) {\r\n for (const name of getItemNamesFromFormatString(formatString)) {\r\n this.findSchemaItemSync(name);\r\n }\r\n }\r\n }\r\n koq.fromJSONSync(koqProps);\r\n }\r\n\r\n /**\r\n * Load the phenomenon dependency for a Constant object and load the Constant from its serialized format.\r\n * @param constant The Constant object that we are loading the phenomenon dependency for\r\n * @param rawConstant The serialized constant data\r\n */\r\n private async loadConstant(constant: Constant, rawConstant: Readonly<unknown>): Promise<void> {\r\n const constantProps = this._parser.parseConstant(rawConstant);\r\n\r\n await this.findSchemaItem(constantProps.phenomenon, true);\r\n await constant.fromJSON(constantProps);\r\n }\r\n\r\n /**\r\n * Load the phenomenon dependency for a Constant object and load the Constant from its serialized format.\r\n * @param constant The Constant object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawConstant The serialized constant data\r\n */\r\n private loadConstantSync(constant: Constant, rawConstant: Readonly<unknown>) {\r\n const constantProps = this._parser.parseConstant(rawConstant);\r\n\r\n this.findSchemaItemSync(constantProps.phenomenon, true);\r\n constant.fromJSONSync(constantProps);\r\n }\r\n\r\n /**\r\n * Load the unit system and invertsUnit dependencies for an Inverted Unit object and load the Inverted Unit from its serialized format.\r\n * @param invertedUnit The InvertedUnit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawInvertedUnit The serialized inverted unit data.\r\n */\r\n private async loadInvertedUnit(invertedUnit: InvertedUnit, rawInvertedUnit: Readonly<unknown>): Promise<void> {\r\n const invertedUnitProps = this._parser.parseInvertedUnit(rawInvertedUnit);\r\n\r\n await this.findSchemaItem(invertedUnitProps.invertsUnit, true);\r\n await this.findSchemaItem(invertedUnitProps.unitSystem, true);\r\n\r\n await invertedUnit.fromJSON(invertedUnitProps);\r\n }\r\n\r\n /**\r\n * Load the unit system and invertsUnit dependencies for an Inverted Unit object and load the Inverted Unit from its serialized format.\r\n * @param invertedUnit The InvertedUnit object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawInvertedUnit The serialized inverted unit data.\r\n */\r\n private loadInvertedUnitSync(invertedUnit: InvertedUnit, rawInvertedUnit: Readonly<unknown>) {\r\n const invertedUnitProps = this._parser.parseInvertedUnit(rawInvertedUnit);\r\n\r\n this.findSchemaItemSync(invertedUnitProps.invertsUnit, true);\r\n this.findSchemaItemSync(invertedUnitProps.unitSystem, true);\r\n\r\n invertedUnit.fromJSONSync(invertedUnitProps);\r\n }\r\n\r\n /**\r\n * Load the unit dependencies for a Format object and load the Format from its serialized format.\r\n * @param format The Format object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawFormat The serialized format data.\r\n */\r\n private async loadFormat(format: Format, rawFormat: Readonly<unknown>): Promise<void> {\r\n const formatProps = this._parser.parseFormat(rawFormat);\r\n\r\n if (undefined !== formatProps.composite) {\r\n const formatUnits = formatProps.composite.units;\r\n for (const unit of formatUnits) {\r\n await this.findSchemaItem(unit.name, true);\r\n }\r\n }\r\n await format.fromJSON(formatProps);\r\n }\r\n\r\n /**\r\n * Load the unit dependencies for a Format object and load the Format from its serialized format.\r\n * @param format The Format object that we are loading dependencies for and \"deserializing into\".\r\n * @param rawFormat The serialized format data.\r\n */\r\n private loadFormatSync(format: Format, rawFormat: Readonly<unknown>) {\r\n const formatProps = this._parser.parseFormat(rawFormat);\r\n\r\n if (undefined !== formatProps.composite) {\r\n const formatUnits = formatProps.composite.units;\r\n for (const unit of formatUnits) {\r\n this.findSchemaItemSync(unit.name, true);\r\n }\r\n }\r\n\r\n format.fromJSONSync(formatProps);\r\n }\r\n\r\n /**\r\n * Load the base class and property type dependencies for an ECClass object and load the ECClass (and its properties) from its serialized format.\r\n * @param classObj The ECClass object that we are loading dependencies for and \"deserializing into\".\r\n * @param classProps The parsed class props object.\r\n * @param rawClass The serialized class data.\r\n */\r\n private async loadClass(classObj: AnyClass, classProps: ClassProps, rawClass: Readonly<unknown>): Promise<void> {\r\n const baseClassLoaded = async (baseClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchemaPart(baseClass);\r\n };\r\n\r\n // Load base class first\r\n if (undefined !== classProps.baseClass) {\r\n await this.findSchemaItem(classProps.baseClass, true, baseClassLoaded);\r\n }\r\n\r\n // Now deserialize the class itself, *before* any properties\r\n // (We need to do this to break Entity -navProp-> Relationship -constraint-> Entity cycle.)\r\n await (classObj as ECClass).fromJSON(classProps);\r\n\r\n for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass, classObj.fullName)) {\r\n await this.loadPropertyTypes(classObj, propName, propType, rawProp);\r\n }\r\n\r\n await this.loadCustomAttributes(classObj, this._parser.getClassCustomAttributeProviders(rawClass));\r\n }\r\n\r\n /**\r\n * Load the base class and property type dependencies for an ECClass object and load the ECClass (and its properties) from its serialized format.\r\n * @param classObj The ECClass object that we are loading dependencies for and \"deserializing into\".\r\n * @param classProps The parsed class props object.\r\n * @param rawClass The serialized class data.\r\n */\r\n private loadClassSync(classObj: AnyClass, classProps: ClassProps, rawClass: Readonly<unknown>): void {\r\n const baseClassLoaded = async (baseClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n this._visitorHelper.visitSchemaPartSync(baseClass);\r\n };\r\n\r\n // Load base class first\r\n if (undefined !== classProps.baseClass) {\r\n this.findSchemaItemSync(classProps.baseClass, true, baseClassLoaded);\r\n }\r\n\r\n // Now deserialize the class itself, *before* any properties\r\n // (We need to do this to break Entity -navProp-> Relationship -constraint-> Entity cycle.)\r\n (classObj as ECClass).fromJSONSync(classProps);\r\n\r\n for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass, classObj.fullName)) {\r\n this.loadPropertyTypesSync(classObj, propName, propType, rawProp);\r\n }\r\n\r\n this.loadCustomAttributesSync(classObj, this._parser.getClassCustomAttributeProviders(rawClass));\r\n }\r\n\r\n /**\r\n * Load the mixin, base class, and property type dependencies for an EntityClass object and load the EntityClass (and properties) from its serialized format.\r\n * @param entity The EntityClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawEntity The serialized entity class data.\r\n */\r\n private async loadEntityClass(entity: EntityClass, rawEntity: Readonly<unknown>): Promise<void> {\r\n const entityClassProps = this._parser.parseEntityClass(rawEntity);\r\n\r\n // Load Mixin classes first\r\n if (undefined !== entityClassProps.mixins) {\r\n for (const mixinName of entityClassProps.mixins)\r\n await this.findSchemaItem(mixinName);\r\n }\r\n\r\n await this.loadClass(entity, entityClassProps, rawEntity);\r\n }\r\n\r\n /**\r\n * Load the mixin, base class, and property type dependencies for an EntityClass object and load the EntityClass (and properties) from its serialized format.\r\n * @param entity The EntityClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawEntity The serialized entity class data.\r\n */\r\n private loadEntityClassSync(entity: EntityClass, rawEntity: Readonly<unknown>): void {\r\n const entityClassProps = this._parser.parseEntityClass(rawEntity);\r\n\r\n // Load Mixin classes first\r\n if (undefined !== entityClassProps.mixins) {\r\n for (const mixinName of entityClassProps.mixins)\r\n this.findSchemaItemSync(mixinName);\r\n }\r\n\r\n this.loadClassSync(entity, entityClassProps, rawEntity);\r\n }\r\n\r\n /**\r\n * Load the appliesTo class, base class, and property type dependencies for a Mixin object and load the Mixin (and properties) from its serialized format.\r\n * @param mixin The Mixin that we are loading dependencies for and \"deserializing into\".\r\n * @param rawMixin The serialized mixin data.\r\n */\r\n private async loadMixin(mixin: Mixin, rawMixin: Readonly<unknown>): Promise<void> {\r\n const mixinProps = this._parser.parseMixin(rawMixin);\r\n\r\n const appliesToLoaded = async (appliesToClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchemaPart(appliesToClass);\r\n };\r\n\r\n await this.findSchemaItem(mixinProps.appliesTo, true, appliesToLoaded);\r\n\r\n await this.loadClass(mixin, mixinProps, rawMixin);\r\n }\r\n\r\n /**\r\n * Load the appliesTo class, base class, and property type dependencies for a Mixin object and load the Mixin (and properties) from its serialized format.\r\n * @param mixin The Mixin that we are loading dependencies for and \"deserializing into\".\r\n * @param rawMixin The serialized mixin data.\r\n */\r\n private loadMixinSync(mixin: Mixin, rawMixin: Readonly<unknown>): void {\r\n const mixinProps = this._parser.parseMixin(rawMixin);\r\n\r\n const appliesToLoaded = async (appliesToClass: SchemaItem) => {\r\n if (this._visitorHelper)\r\n await this._visitorHelper.visitSchemaPart(appliesToClass);\r\n };\r\n\r\n this.findSchemaItemSync(mixinProps.appliesTo, true, appliesToLoaded);\r\n\r\n this.loadClassSync(mixin, mixinProps, rawMixin);\r\n }\r\n\r\n /**\r\n * Load the relationship constraint, base class, and property type dependencies for a RelationshipClass object and load the RelationshipClass (and properties) from its serialized format.\r\n * @param rel The RelationshipClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawRel The serialized relationship class data.\r\n */\r\n private async loadRelationshipClass(rel: RelationshipClass, rawRel: Readonly<unknown>): Promise<void> {\r\n const relationshipClassProps = this._parser.parseRelationshipClass(rawRel);\r\n await this.loadClass(rel, relationshipClassProps, rawRel);\r\n await this.loadRelationshipConstraint(rel.source, relationshipClassProps.source);\r\n await this.loadRelationshipConstraint(rel.target, relationshipClassProps.target);\r\n\r\n const [sourceCustomAttributes, targetCustomAttributes] = this._parser.getRelationshipConstraintCustomAttributeProviders(rawRel);\r\n await this.loadCustomAttributes(rel.source, sourceCustomAttributes);\r\n await this.loadCustomAttributes(rel.target, targetCustomAttributes);\r\n }\r\n\r\n /**\r\n * Load the relationship constraint, base class, and property type dependencies for a RelationshipClass object and load the RelationshipClass (and properties) from its serialized format.\r\n * @param rel The RelationshipClass that we are loading dependencies for and \"deserializing into\".\r\n * @param rawRel The serialized relationship class data.\r\n */\r\n private loadRelationshipClassSync(rel: RelationshipClass, rawRel: Readonly<unknown>): void {\r\n const relationshipClassProps = this._parser.parseRelationshipClass(rawRel);\r\n this.loadClassSync(rel, relationshipClassProps, rawRel);\r\n this.loadRelationshipConstraintSync(rel.source, relationshipClassProps.source);\r\n this.loadRelationshipConstraintSync(rel.target, relationshipClassProps.target);\r\n\r\n const [sourceCustomAttributes, targetCustomAttributes] = this._parser.getRelationshipConstraintCustomAttributeProviders(rawRel);\r\n this.loadCustomAttributesSync(rel.source, sourceCustomAttributes);\r\n this.loadCustomAttributesSync(rel.target, targetCustomAttributes);\r\n }\r\n\r\n /**\r\n * Load the abstract constraint and constraint class dependencies for a RelationshipConstraint object and load the RelationshipConstraint from its parsed props.\r\n * @param relConstraint The RelationshipConstraint that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed relationship constraint props.\r\n */\r\n private async loadRelationshipConstraint(relConstraint: RelationshipConstraint, props: RelationshipConstraintProps): Promise<void> {\r\n if (undefined !== props.abstractConstraint) {\r\n await this.findSchemaItem(props.abstractConstraint);\r\n }\r\n if (undefined !== props.constraintClasses) { // TODO: this should be required\r\n for (const constraintClass of props.constraintClasses) {\r\n await this.findSchemaItem(constraintClass);\r\n }\r\n }\r\n await relConstraint.fromJSON(props);\r\n }\r\n\r\n /**\r\n * Load the abstract constraint and constraint class dependencies for a RelationshipConstraint object and load the RelationshipConstraint from its parsed props.\r\n * @param relConstraint The RelationshipConstraint that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed relationship constraint props.\r\n */\r\n private loadRelationshipConstraintSync(relConstraint: RelationshipConstraint, props: RelationshipConstraintProps): void {\r\n if (undefined !== props.abstractConstraint) {\r\n this.findSchemaItemSync(props.abstractConstraint);\r\n }\r\n if (undefined !== props.constraintClasses) {\r\n for (const constraintClass of props.constraintClasses) {\r\n this.findSchemaItemSync(constraintClass);\r\n }\r\n }\r\n\r\n relConstraint.fromJSONSync(props);\r\n }\r\n\r\n /**\r\n * Load the type dependencies for a serialized property, then creates and deserialized the Property object in the given ECClass.\r\n * @param classObj The ECClass that the Property should be created in.\r\n * @param propName The name of the Property.\r\n * @param propType The (serialized string) kind of property to create.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private async loadPropertyTypes(classObj: AnyClass, propName: string, propType: string, rawProperty: Readonly<unknown>): Promise<void> {\r\n\r\n const loadTypeName = async (typeName: string) => {\r\n if (undefined === parsePrimitiveType(typeName))\r\n await this.findSchemaItem(typeName);\r\n };\r\n\r\n const lowerCasePropType = propType.toLowerCase();\r\n\r\n switch (lowerCasePropType) {\r\n case \"primitiveproperty\":\r\n const primPropertyProps = this._parser.parsePrimitiveProperty(rawProperty);\r\n await loadTypeName(primPropertyProps.typeName);\r\n const primProp = await (classObj as MutableClass).createPrimitiveProperty(propName, primPropertyProps.typeName);\r\n return this.loadProperty(primProp, primPropertyProps, rawProperty);\r\n\r\n case \"structproperty\":\r\n const structPropertyProps = this._parser.parseStructProperty(rawProperty);\r\n await loadTypeName(structPropertyProps.typeName);\r\n const structProp = await (classObj as MutableClass).createStructProperty(propName, structPropertyProps.typeName);\r\n return this.loadProperty(structProp, structPropertyProps, rawProperty);\r\n\r\n case \"primitivearrayproperty\":\r\n const primArrPropertyProps = this._parser.parsePrimitiveArrayProperty(rawProperty);\r\n await loadTypeName(primArrPropertyProps.typeName);\r\n const primArrProp = await (classObj as MutableClass).createPrimitiveArrayProperty(propName, primArrPropertyProps.typeName);\r\n return this.loadProperty(primArrProp, primArrPropertyProps, rawProperty);\r\n\r\n case \"structarrayproperty\":\r\n const structArrPropertyProps = this._parser.parseStructArrayProperty(rawProperty);\r\n await loadTypeName(structArrPropertyProps.typeName);\r\n const structArrProp = await (classObj as MutableClass).createStructArrayProperty(propName, structArrPropertyProps.typeName);\r\n return this.loadProperty(structArrProp, structArrPropertyProps, rawProperty);\r\n\r\n case \"navigationproperty\":\r\n if (classObj.schemaItemType !== SchemaItemType.EntityClass && classObj.schemaItemType !== SchemaItemType.RelationshipClass && classObj.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Navigation Property ${classObj.name}.${propName} is invalid, because only EntityClasses, Mixins, and RelationshipClasses can have NavigationProperties.`);\r\n\r\n const navPropertyProps = this._parser.parseNavigationProperty(rawProperty);\r\n await this.findSchemaItem(navPropertyProps.relationshipName);\r\n const navProp = await (classObj as MutableEntityClass).createNavigationProperty(propName, navPropertyProps.relationshipName, navPropertyProps.direction);\r\n return this.loadProperty(navProp, navPropertyProps, rawProperty);\r\n }\r\n }\r\n\r\n /**\r\n * Load the type dependencies for a serialized property, then creates and deserialized the Property object in the given ECClass.\r\n * @param classObj The ECClass that the Property should be created in.\r\n * @param propName The name of the Property.\r\n * @param propType The (serialized string) kind of property to create.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private loadPropertyTypesSync(classObj: AnyClass, propName: string, propType: string, rawProperty: Readonly<unknown>): void {\r\n const loadTypeName = (typeName: string) => {\r\n if (undefined === parsePrimitiveType(typeName))\r\n this.findSchemaItemSync(typeName);\r\n };\r\n\r\n const lowerCasePropType = propType.toLowerCase();\r\n\r\n switch (lowerCasePropType) {\r\n case \"primitiveproperty\":\r\n const primPropertyProps = this._parser.parsePrimitiveProperty(rawProperty);\r\n loadTypeName(primPropertyProps.typeName);\r\n const primProp = (classObj as MutableClass).createPrimitivePropertySync(propName, primPropertyProps.typeName);\r\n return this.loadPropertySync(primProp, primPropertyProps, rawProperty);\r\n\r\n case \"structproperty\":\r\n const structPropertyProps = this._parser.parseStructProperty(rawProperty);\r\n loadTypeName(structPropertyProps.typeName);\r\n const structProp = (classObj as MutableClass).createStructPropertySync(propName, structPropertyProps.typeName);\r\n return this.loadPropertySync(structProp, structPropertyProps, rawProperty);\r\n\r\n case \"primitivearrayproperty\":\r\n const primArrPropertyProps = this._parser.parsePrimitiveArrayProperty(rawProperty);\r\n loadTypeName(primArrPropertyProps.typeName);\r\n const primArrProp = (classObj as MutableClass).createPrimitiveArrayPropertySync(propName, primArrPropertyProps.typeName);\r\n return this.loadPropertySync(primArrProp, primArrPropertyProps, rawProperty);\r\n\r\n case \"structarrayproperty\":\r\n const structArrPropertyProps = this._parser.parseStructArrayProperty(rawProperty);\r\n loadTypeName(structArrPropertyProps.typeName);\r\n const structArrProp = (classObj as MutableClass).createStructArrayPropertySync(propName, structArrPropertyProps.typeName);\r\n return this.loadPropertySync(structArrProp, structArrPropertyProps, rawProperty);\r\n\r\n case \"navigationproperty\":\r\n if (classObj.schemaItemType !== SchemaItemType.EntityClass && classObj.schemaItemType !== SchemaItemType.RelationshipClass && classObj.schemaItemType !== SchemaItemType.Mixin)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Navigation Property ${classObj.name}.${propName} is invalid, because only EntityClasses, Mixins, and RelationshipClasses can have NavigationProperties.`);\r\n\r\n const navPropertyProps = this._parser.parseNavigationProperty(rawProperty);\r\n this.findSchemaItemSync(navPropertyProps.relationshipName);\r\n const navProp = (classObj as MutableEntityClass).createNavigationPropertySync(propName, navPropertyProps.relationshipName, navPropertyProps.direction);\r\n return this.loadPropertySync(navProp, navPropertyProps, rawProperty);\r\n }\r\n }\r\n\r\n /**\r\n * Load the propertyCategory, kindOfQuantity, and customAttribute dependencies for a Property object and load the Property from its parsed props.\r\n * @param propertyObj The Property that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed property props.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private async loadProperty<U extends Property>(propertyObj: U, props: PropertyProps, rawProperty: Readonly<unknown>): Promise<void> {\r\n if (undefined !== props.category) {\r\n await this.findSchemaItem(props.category);\r\n }\r\n\r\n if (undefined !== props.kindOfQuantity) {\r\n await this.findSchemaItem(props.kindOfQuantity);\r\n }\r\n\r\n await propertyObj.fromJSON(props);\r\n await this.loadCustomAttributes(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));\r\n }\r\n\r\n /**\r\n * Load the propertyCategory, kindOfQuantity, and customAttribute dependencies for a Property object and load the Property from its parsed props.\r\n * @param propertyObj The Property that we are loading dependencies for and \"deserializing into\".\r\n * @param props The parsed property props.\r\n * @param rawProperty The serialized property data.\r\n */\r\n private loadPropertySync<U extends Property>(propertyObj: U, props: PropertyProps, rawProperty: Readonly<unknown>): void {\r\n if (undefined !== props.category) {\r\n this.findSchemaItemSync(props.category);\r\n }\r\n\r\n if (undefined !== props.kindOfQuantity) {\r\n this.findSchemaItemSync(props.kindOfQuantity);\r\n }\r\n\r\n propertyObj.fromJSONSync(props);\r\n this.loadCustomAttributesSync(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));\r\n }\r\n\r\n /**\r\n * Load the customAttribute class dependencies for a set of CustomAttribute objects and add\r\n * them to a given custom attribute container.\r\n * @param container The CustomAttributeContainer that each CustomAttribute will be added to.\r\n * @param customAttributes An iterable set of parsed CustomAttribute objects.\r\n */\r\n private async loadCustomAttributes(container: AnyCAContainer, caProviders: Iterable<CAProviderTuple>): Promise<void> {\r\n for (const providerTuple of caProviders) {\r\n // First tuple entry is the CA class name.\r\n const caClass = await this.findSchemaItem(providerTuple[0]);\r\n\r\n // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema\r\n if (caClass && caClass.key.schemaName !== container.schema.name &&\r\n !container.schema.getReferenceSync(caClass.key.schemaName)) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to load custom attribute ${caClass.fullName} from container ${container.fullName}, ${caClass.key.schemaName} reference not defined`);\r\n }\r\n\r\n // Second tuple entry ia a function that provides the CA instance.\r\n const provider = providerTuple[1];\r\n const customAttribute = provider(caClass as CustomAttributeClass);\r\n\r\n (container as AnyMutableCAContainer).addCustomAttribute(customAttribute);\r\n }\r\n }\r\n\r\n /**\r\n * Load the customAttribute class dependencies for a set of CustomAttribute objects and add them to a given custom attribute container.\r\n * @param container The CustomAttributeContainer that each CustomAttribute will be added to.\r\n * @param customAttributes An iterable set of parsed CustomAttribute objects.\r\n */\r\n private loadCustomAttributesSync(container: AnyCAContainer, caProviders: Iterable<CAProviderTuple>): void {\r\n for (const providerTuple of caProviders) {\r\n // First tuple entry is the CA class name.\r\n const caClass = this.findSchemaItemSync(providerTuple[0]) as CustomAttributeClass;\r\n\r\n // Second tuple entry ia a function that provides the CA instance.\r\n const provider = providerTuple[1];\r\n const customAttribute = provider(caClass);\r\n (container as AnyMutableCAContainer).addCustomAttribute(customAttribute);\r\n }\r\n }\r\n}\r\n"]}
|