@itwin/ecschema-metadata 3.1.0-dev.8 → 3.2.0-dev.12

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +25 -3
  2. package/lib/cjs/Context.d.ts +5 -0
  3. package/lib/cjs/Context.d.ts.map +1 -1
  4. package/lib/cjs/Context.js +13 -0
  5. package/lib/cjs/Context.js.map +1 -1
  6. package/lib/cjs/Deserialization/Helper.js +3 -3
  7. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  8. package/lib/cjs/Metadata/Format.d.ts +2 -15
  9. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  10. package/lib/cjs/Metadata/Format.js +42 -119
  11. package/lib/cjs/Metadata/Format.js.map +1 -1
  12. package/lib/cjs/Metadata/KindOfQuantity.js +2 -2
  13. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  14. package/lib/cjs/Metadata/OverrideFormat.d.ts +1 -1
  15. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  16. package/lib/cjs/Metadata/Unit.d.ts +4 -0
  17. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  18. package/lib/cjs/Metadata/Unit.js +6 -0
  19. package/lib/cjs/Metadata/Unit.js.map +1 -1
  20. package/lib/cjs/UnitConversion/UnitConversion.d.ts +1 -2
  21. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +1 -1
  22. package/lib/cjs/UnitConversion/UnitConversion.js +1 -2
  23. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  24. package/lib/cjs/UnitConversion/UnitConverter.d.ts +1 -1
  25. package/lib/cjs/UnitConversion/UnitConverter.js +1 -1
  26. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  27. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +78 -0
  28. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -0
  29. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +237 -0
  30. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -0
  31. package/lib/cjs/ecschema-metadata.d.ts +3 -1
  32. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  33. package/lib/cjs/ecschema-metadata.js +3 -1
  34. package/lib/cjs/ecschema-metadata.js.map +1 -1
  35. package/package.json +7 -5
  36. package/lib/cjs/utils/FormatEnums.d.ts +0 -106
  37. package/lib/cjs/utils/FormatEnums.d.ts.map +0 -1
  38. package/lib/cjs/utils/FormatEnums.js +0 -265
  39. package/lib/cjs/utils/FormatEnums.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # Change Log - @itwin/ecschema-metadata
2
2
 
3
- This log was last generated on Wed, 12 Jan 2022 14:52:38 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 10 Mar 2022 21:18:13 GMT and should not be manually modified.
4
+
5
+ ## 3.0.2
6
+ Thu, 10 Mar 2022 21:18:13 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.0.1
11
+ Thu, 24 Feb 2022 15:26:55 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 3.0.0
16
+ Mon, 24 Jan 2022 14:00:52 GMT
17
+
18
+ ### Updates
19
+
20
+ - Added delete class from schema and delete property from class as well as corresponding tests
21
+ - Upgrade target to ES2019
22
+ - rename to @itwin/ecschema-metadata
23
+ - remove ClientRequestContext and its subclasses
24
+ - Removing deprecated editing and validation types from ecschema-metadata.
25
+ - remove alpha toXmlString method and its implicit xmldom dependency
4
26
 
5
27
  ## 2.19.28
6
28
  Wed, 12 Jan 2022 14:52:38 GMT
@@ -635,7 +657,7 @@ Wed, 06 May 2020 13:17:49 GMT
635
657
 
636
658
  - new EC Rule 501 - CustomAttribute schemas must be referenced by the container's schema.
637
659
  - Removing deprecated API. Please see NextVersion.md under the heading 'ecschema-metadata Package' for details.
638
- - Deprecating schema classes' method 'toJson' and replacing it with the JSON.stringify supported method 'toJSON'. Also deprecating the 'deserialize' method and replacing it with 'fromJSON' for naming consistency.
660
+ - Deprecating schema classes' method 'toJson' and replacing it with the JSON.stringify supported method 'toJSON'. Also deprecating the 'deserialize' method and replacing it with 'fromJSON' for naming consistency.
639
661
  - Undefined display labels should equal empty display labels during schema comparison.
640
662
  - order imports.
641
663
  - Removed unused package dependencies
@@ -761,7 +783,7 @@ Mon, 13 May 2019 15:52:05 GMT
761
783
  - Adds parameter for api-extractor to validate missing release tags
762
784
  - Adds ignoreMissingTags flag
763
785
  - Fix broken links
764
- - Setup a generic context for tracking client requests, and made various related enhancements to logging, usage tracking and authorization.
786
+ - Setup a generic context for tracking client requests, and made various related enhancements to logging, usage tracking and authorization.
765
787
  - Added ability to suppress rule violations from being reported during schema validation.
766
788
  - Upgrade TypeDoc dependency to 0.14.2
767
789
  - Updated BIS and EC schema validation documentation and adjusted diagnostic codes to match documentation.
@@ -64,6 +64,10 @@ export declare class SchemaCache implements ISchemaLocater {
64
64
  * @param matchType
65
65
  */
66
66
  getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType?: SchemaMatchType): T | undefined;
67
+ /**
68
+ * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema
69
+ */
70
+ getSchemaItems(): IterableIterator<SchemaItem>;
67
71
  }
68
72
  /**
69
73
  * The SchemaContext, context object is used to facilitate schema and schema item location.
@@ -119,5 +123,6 @@ export declare class SchemaContext implements ISchemaLocater, ISchemaItemLocater
119
123
  getCachedSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType?: SchemaMatchType): Schema | undefined;
120
124
  getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;
121
125
  getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined;
126
+ getSchemaItems(): IterableIterator<SchemaItem>;
122
127
  }
123
128
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.ts"],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AG,SAAS;IAOpF,cAAc,IAAI,gBAAgB,CAAC,UAAU,CAAC;CAGtD"}
@@ -71,6 +71,16 @@ class SchemaCache {
71
71
  return foundSchema;
72
72
  return foundSchema;
73
73
  }
74
+ /**
75
+ * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema
76
+ */
77
+ *getSchemaItems() {
78
+ for (const schema of this._schema) {
79
+ for (const schemaItem of schema.getItems()) {
80
+ yield schemaItem;
81
+ }
82
+ }
83
+ }
74
84
  }
75
85
  exports.SchemaCache = SchemaCache;
76
86
  /**
@@ -171,6 +181,9 @@ class SchemaContext {
171
181
  return undefined;
172
182
  return schema.getItemSync(schemaItemKey.name);
173
183
  }
184
+ getSchemaItems() {
185
+ return this._knownSchemas.getSchemaItems();
186
+ }
174
187
  }
175
188
  exports.SchemaContext = SchemaContext;
176
189
  //# sourceMappingURL=Context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAK9D;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAa;CAAI;AAAhD,8BAAgD;AAkChD;;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;IAElD;;;OAGG;IACI,KAAK,CAAC,SAAS,CAAmB,MAAS;QAChD,IAAI,MAAM,IAAI,CAAC,SAAS,CAAI,MAAM,CAAC,SAAS,CAAC;YAC3C,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,eAAe,EAAE,eAAe,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,qCAAqC,CAAC,CAAC;QAE7I,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IA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AAC;QACnB,OAAO,MAAM,CAAC,WAAW,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACF;AA5GD,sCA4GC","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 { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class SchemaMap extends Array<Schema> { }\r\n\r\n/**\r\n * The interface defines what is needed to be a ISchemaLocater, which are used in a SchemaContext.\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 optional context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext): Promise<T | 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 optional context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: 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 * @beta\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 /**\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 (await this.getSchema<T>(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(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.getSchemaSync<T>(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(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: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return undefined;\r\n\r\n return foundSchema as T;\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n * @param matchType\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return foundSchema;\r\n\r\n return foundSchema as T;\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 ISchemaLocater, 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\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 */\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 *\r\n * @param schemaKey\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: 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 *\r\n * @param schemaKey\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 * @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: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this.getCachedSchemaSync(schemaKey, matchType) as T;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\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: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n return schema as T;\r\n }\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 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"]}
1
+ {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAK9D;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAa;CAAI;AAAhD,8BAAgD;AAkChD;;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;IAElD;;;OAGG;IACI,KAAK,CAAC,SAAS,CAAmB,MAAS;QAChD,IAAI,MAAM,IAAI,CAAC,SAAS,CAAI,MAAM,CAAC,SAAS,CAAC;YAC3C,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,eAAe,EAAE,eAAe,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,qCAAqC,CAAC,CAAC;QAE7I,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,aAAa,CAAmB,MAAS;QAC9C,IAAI,IAAI,CAAC,aAAa,CAAI,MAAM,CAAC,SAAS,CAAC;YACzC,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,eAAe,EAAE,eAAe,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,qCAAqC,CAAC,CAAC;QAE7I,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAmB,SAAoB,EAAE,YAA6B,2BAAe,CAAC,MAAM;QAChH,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC;YAClB,OAAO,SAAS,CAAC;QAEnB,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE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AAC;YACpE,IAAI,SAAS,KAAK,MAAM;gBACtB,OAAO,MAAM,CAAC;SACjB;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAmB,SAAoB,EAAE,YAA6B,2BAAe,CAAC,MAAM;QACtH,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAM,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACI,mBAAmB,CAAmB,SAAoB,EAAE,YAA6B,2BAAe,CAAC,MAAM;QACpH,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,MAAW,CAAC;IACrB,CAAC;IAEM,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;IAEM,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;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;CACF;AAhHD,sCAgHC","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 { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class SchemaMap extends Array<Schema> { }\r\n\r\n/**\r\n * The interface defines what is needed to be a ISchemaLocater, which are used in a SchemaContext.\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 optional context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext): Promise<T | 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 optional context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: 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 * @beta\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 /**\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 (await this.getSchema<T>(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(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.getSchemaSync<T>(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(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: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return undefined;\r\n\r\n return foundSchema as T;\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n * @param matchType\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return foundSchema;\r\n\r\n return foundSchema as T;\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 */\r\n public* getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const schema of this._schema) {\r\n for (const schemaItem of schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\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 ISchemaLocater, 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\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 */\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 *\r\n * @param schemaKey\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: 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 *\r\n * @param schemaKey\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 * @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: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this.getCachedSchemaSync(schemaKey, matchType) as T;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\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: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n return schema as T;\r\n }\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 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 public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n}\r\n"]}
@@ -11,7 +11,7 @@ const Exception_1 = require("../Exception");
11
11
  const SchemaItem_1 = require("../Metadata/SchemaItem");
12
12
  const SchemaKey_1 = require("../SchemaKey");
13
13
  const SchemaPartVisitorDelegate_1 = require("../SchemaPartVisitorDelegate");
14
- const FormatEnums_1 = require("../utils/FormatEnums");
14
+ const core_quantity_1 = require("@itwin/core-quantity");
15
15
  const SchemaGraph_1 = require("../utils/SchemaGraph");
16
16
  /**
17
17
  * This class properly handles the order the deserialization of ECSchemas and SchemaItems from serialized formats.
@@ -432,7 +432,7 @@ class SchemaReadHelper {
432
432
  await this.findSchemaItem(koqProps.persistenceUnit);
433
433
  if (undefined !== koqProps.presentationUnits) {
434
434
  for (const formatString of koqProps.presentationUnits) {
435
- for (const name of (0, FormatEnums_1.getItemNamesFromFormatString)(formatString)) {
435
+ for (const name of (0, core_quantity_1.getItemNamesFromFormatString)(formatString)) {
436
436
  await this.findSchemaItem(name);
437
437
  }
438
438
  }
@@ -449,7 +449,7 @@ class SchemaReadHelper {
449
449
  this.findSchemaItemSync(koqProps.persistenceUnit);
450
450
  if (undefined !== koqProps.presentationUnits) {
451
451
  for (const formatString of koqProps.presentationUnits) {
452
- for (const name of (0, FormatEnums_1.getItemNamesFromFormatString)(formatString)) {
452
+ for (const name of (0, core_quantity_1.getItemNamesFromFormatString)(formatString)) {
453
453
  this.findSchemaItemSync(name);
454
454
  }
455
455
  }
@@ -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,sDAAoE;AAGpE,sDAAmD;AAKnD;;;;GAIG;AACH,MAAa,gBAAgB;IA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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;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;AAv8BD,4CAu8BC","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 } 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 \"../utils/FormatEnums\";\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\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 * 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 // 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 // Need to add this schema to the context to be able to locate schemaItems within the context.\r\n await this._context.addSchema(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 await this.loadSchemaReference(reference);\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 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(ref: SchemaReferenceProps): Promise<void> {\r\n const schemaKey = new SchemaKey(ref.name, ECVersion.fromString(ref.version));\r\n const refSchema = await this._context.getSchema(schemaKey, SchemaMatchType.LatestWriteCompatible);\r\n if (undefined === 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 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 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 const graph = new SchemaGraph(schema);\r\n const cycles = graph.detectCycles();\r\n if (cycles) {\r\n const result = cycles.map((cycle) => `${cycle.schema.name} --> ${cycle.refSchema.name}`).join(\", \");\r\n yield `Schema '${schema.name}' has reference cycles: ${result}`;\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 && undefined === await this._schema!.getItem(itemName)) {\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)) {\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)) {\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]) 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 /**\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;IAU3B,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,E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AED;;;;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;AAv8BD,4CAu8BC","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 } 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\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 * 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 // 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 // Need to add this schema to the context to be able to locate schemaItems within the context.\r\n await this._context.addSchema(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 await this.loadSchemaReference(reference);\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 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(ref: SchemaReferenceProps): Promise<void> {\r\n const schemaKey = new SchemaKey(ref.name, ECVersion.fromString(ref.version));\r\n const refSchema = await this._context.getSchema(schemaKey, SchemaMatchType.LatestWriteCompatible);\r\n if (undefined === 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 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 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 const graph = new SchemaGraph(schema);\r\n const cycles = graph.detectCycles();\r\n if (cycles) {\r\n const result = cycles.map((cycle) => `${cycle.schema.name} --> ${cycle.refSchema.name}`).join(\", \");\r\n yield `Schema '${schema.name}' has reference cycles: ${result}`;\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 && undefined === await this._schema!.getItem(itemName)) {\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)) {\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)) {\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]) 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 /**\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"]}