@itwin/ecschema-metadata 5.2.0-dev.2 → 5.2.0-dev.20

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 (96) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/lib/cjs/Deserialization/JsonProps.d.ts +7 -2
  3. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  4. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  5. package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts +37 -0
  6. package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts.map +1 -0
  7. package/lib/cjs/Formatting/FormatSetFormatsProvider.js +58 -0
  8. package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -0
  9. package/lib/cjs/{SchemaFormatsProvider.d.ts → Formatting/SchemaFormatsProvider.d.ts} +1 -1
  10. package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts.map +1 -0
  11. package/lib/cjs/{SchemaFormatsProvider.js → Formatting/SchemaFormatsProvider.js} +6 -6
  12. package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -0
  13. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts +18 -24
  14. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
  15. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +52 -26
  16. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
  17. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +16 -3
  18. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
  19. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +5 -4
  20. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
  21. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
  22. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +2 -7
  23. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
  24. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
  25. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
  26. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +16 -16
  27. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
  28. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +3 -3
  29. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
  30. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +10 -4
  31. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -1
  32. package/lib/cjs/IncrementalLoading/SchemaParser.js +19 -19
  33. package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
  34. package/lib/cjs/Metadata/EntityClass.js +1 -1
  35. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  36. package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
  37. package/lib/cjs/Metadata/KindOfQuantity.js +9 -22
  38. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  39. package/lib/cjs/ecschema-metadata.d.ts +2 -1
  40. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  41. package/lib/cjs/ecschema-metadata.js +2 -1
  42. package/lib/cjs/ecschema-metadata.js.map +1 -1
  43. package/lib/esm/Deserialization/JsonProps.d.ts +7 -2
  44. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
  45. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  46. package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts +37 -0
  47. package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts.map +1 -0
  48. package/lib/esm/Formatting/FormatSetFormatsProvider.js +54 -0
  49. package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -0
  50. package/lib/esm/{SchemaFormatsProvider.d.ts → Formatting/SchemaFormatsProvider.d.ts} +1 -1
  51. package/lib/esm/Formatting/SchemaFormatsProvider.d.ts.map +1 -0
  52. package/lib/esm/{SchemaFormatsProvider.js → Formatting/SchemaFormatsProvider.js} +6 -6
  53. package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -0
  54. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts +18 -24
  55. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
  56. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +51 -25
  57. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
  58. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +16 -3
  59. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
  60. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +5 -4
  61. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
  62. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
  63. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +2 -7
  64. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
  65. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
  66. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
  67. package/lib/esm/IncrementalLoading/SchemaItemParsers.js +16 -16
  68. package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
  69. package/lib/esm/IncrementalLoading/SchemaItemQueries.js +3 -3
  70. package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
  71. package/lib/esm/IncrementalLoading/SchemaParser.d.ts +10 -4
  72. package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -1
  73. package/lib/esm/IncrementalLoading/SchemaParser.js +19 -19
  74. package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
  75. package/lib/esm/Metadata/EntityClass.js +1 -1
  76. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  77. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
  78. package/lib/esm/Metadata/KindOfQuantity.js +9 -22
  79. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  80. package/lib/esm/ecschema-metadata.d.ts +2 -1
  81. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  82. package/lib/esm/ecschema-metadata.js +2 -1
  83. package/lib/esm/ecschema-metadata.js.map +1 -1
  84. package/package.json +6 -6
  85. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts +0 -60
  86. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts.map +0 -1
  87. package/lib/cjs/IncrementalLoading/PerformanceLogger.js +0 -82
  88. package/lib/cjs/IncrementalLoading/PerformanceLogger.js.map +0 -1
  89. package/lib/cjs/SchemaFormatsProvider.d.ts.map +0 -1
  90. package/lib/cjs/SchemaFormatsProvider.js.map +0 -1
  91. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts +0 -60
  92. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts.map +0 -1
  93. package/lib/esm/IncrementalLoading/PerformanceLogger.js +0 -78
  94. package/lib/esm/IncrementalLoading/PerformanceLogger.js.map +0 -1
  95. package/lib/esm/SchemaFormatsProvider.d.ts.map +0 -1
  96. package/lib/esm/SchemaFormatsProvider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"IncrementalSchemaReader.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaReader.ts"],"names":[],"mappings":";;;AAKA,sDAA6D;AAC7D,8DAA2D;AAC3D,4CAA8C;AAC9C,6CAA4C;AAE5C,uDAAoD;AACpD,8EAA2E;AAE3E;;;;GAIG;AACH,MAAa,uBAAwB,SAAQ,yBAAgB;IAC1C,YAAY,CAAU;IAEvC;;;;;OAKG;IACH,YAAY,aAA4B,EAAE,WAAoB;QAC5D,KAAK,CAAC,uBAAU,EAAE,aAAa,CAAC,CAAC;QACjC,IAAI,CAAC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,CAAC,cAAc,KAAK,0BAAc,CAAC,cAAc;eAC3D,UAAU,CAAC,cAAc,KAAK,0BAAc,CAAC,MAAM;YACtD,UAAU,CAAC,iBAAkB,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;;YAE9D,UAAU,CAAC,iBAAkB,CAAC,UAAU,GAAG,IAAI,CAAC;IACpD,CAAC;CACF;AAnED,0DAmEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport { SchemaContext } from \"../Context\";\nimport { SchemaReadHelper } from \"../Deserialization/Helper\";\nimport { JsonParser } from \"../Deserialization/JsonParser\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECClass } from \"../Metadata/Class\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { SchemaLoadingController } from \"../utils/SchemaLoadingController\";\n\n/**\n * Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]\n * but overrides a few methods to support the incremental schema loading case.\n * @internal\n */\nexport class IncrementalSchemaReader extends SchemaReadHelper {\n private readonly _incremental: boolean;\n\n /**\n * Initializes a new [[IncrementalSchemaReader]] instance.\n * @param schemaContext The [[SchemaContext]] used to load the schemas.\n * @param incremental Indicates that the Schema should be read incrementally.\n * Pass false to load the full schema without an incremental/partial load.\n */\n constructor(schemaContext: SchemaContext, incremental: boolean) {\n super(JsonParser, schemaContext);\n this._incremental = incremental;\n }\n\n /**\n * Indicates that a given [[SchemaItem]] has been fully loaded.\n * @param schemaItem The SchemaItem to check.\n * @returns True if the item has been loaded, false if still in progress.\n */\n protected override isSchemaItemLoaded(schemaItem: SchemaItem | undefined): boolean {\n return schemaItem !== undefined\n && schemaItem.loadingController !== undefined\n && schemaItem.loadingController.isComplete;\n }\n\n /**\n * Starts loading the [[SchemaItem]] identified by the given name and itemType.\n * @param schema The [[Schema]] that contains the SchemaItem.\n * @param name The name of the SchemaItem to load.\n * @param itemType The SchemaItem type name of the item to load.\n * @param schemaItemObject The object accepting the SchemaItem data.\n * @returns A promise that resolves to the loaded SchemaItem instance. Can be undefined.\n */\n public override async loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): Promise<SchemaItem | undefined> {\n const schemaItem = await super.loadSchemaItem(schema, name, itemType, this._incremental ? undefined : schemaItemObject);\n\n // In incremental mode, we only load the stubs of the classes. These include the modifier and base classes.\n // The fromJSON method of the actual class instances may complain about missing properties in the props, so\n // calling the fromJSON on the ECClass ensures only the bare minimum is loaded.\n if (this._incremental && schemaItemObject && schemaItem) {\n if (schemaItem.schemaItemType === SchemaItemType.KindOfQuantity) {\n SchemaItem.prototype.fromJSONSync.call(schemaItem, schemaItemObject);\n } else {\n schemaItem.fromJSONSync(schemaItemObject);\n }\n }\n\n this.schemaItemLoading(schemaItem);\n return schemaItem;\n }\n\n private schemaItemLoading(schemaItem: SchemaItem | undefined) {\n if (schemaItem === undefined)\n return;\n\n if (schemaItem.loadingController === undefined) {\n const controller = new SchemaLoadingController();\n schemaItem.setLoadingController(controller);\n }\n\n if (ECClass.isECClass(schemaItem)\n || schemaItem.schemaItemType === SchemaItemType.KindOfQuantity\n || schemaItem.schemaItemType === SchemaItemType.Format)\n schemaItem.loadingController!.isComplete = !this._incremental;\n else\n schemaItem.loadingController!.isComplete = true;\n }\n}"]}
1
+ {"version":3,"file":"IncrementalSchemaReader.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaReader.ts"],"names":[],"mappings":";;;AAKA,sDAA6D;AAC7D,8DAA2D;AAC3D,4CAA8C;AAC9C,6CAA4C;AAG5C,8EAA2E;AAE3E;;;;GAIG;AACH,MAAa,uBAAwB,SAAQ,yBAAgB;IAC1C,YAAY,CAAU;IAEvC;;;;;OAKG;IACH,YAAY,aAA4B,EAAE,WAAoB;QAC5D,KAAK,CAAC,uBA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MAAM;YACtD,UAAU,CAAC,iBAAiB,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;;YAE7D,UAAU,CAAC,iBAAiB,CAAC,UAAU,GAAG,IAAI,CAAC;IACnD,CAAC;CACF;AAjED,0DAiEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport { SchemaContext } from \"../Context\";\nimport { SchemaReadHelper } from \"../Deserialization/Helper\";\nimport { JsonParser } from \"../Deserialization/JsonParser\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECClass } from \"../Metadata/Class\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { SchemaLoadingController } from \"../utils/SchemaLoadingController\";\n\n/**\n * Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]\n * but overrides a few methods to support the incremental schema loading case.\n * @internal\n */\nexport class IncrementalSchemaReader extends SchemaReadHelper {\n private readonly _incremental: boolean;\n\n /**\n * Initializes a new [[IncrementalSchemaReader]] instance.\n * @param schemaContext The [[SchemaContext]] used to load the schemas.\n * @param incremental Indicates that the Schema should be read incrementally.\n * Pass false to load the full schema without an incremental/partial load.\n */\n constructor(schemaContext: SchemaContext, incremental: boolean) {\n super(JsonParser, schemaContext);\n this._incremental = incremental;\n }\n\n /**\n * Indicates that a given [[SchemaItem]] has been fully loaded.\n * @param schemaItem The SchemaItem to check.\n * @returns True if the item has been loaded, false if still in progress.\n */\n protected override isSchemaItemLoaded(schemaItem: SchemaItem | undefined): boolean {\n return schemaItem !== undefined\n && schemaItem.loadingController !== undefined\n && schemaItem.loadingController.isComplete;\n }\n\n /**\n * Starts loading the [[SchemaItem]] identified by the given name and itemType.\n * @param schema The [[Schema]] that contains the SchemaItem.\n * @param name The name of the SchemaItem to load.\n * @param itemType The SchemaItem type name of the item to load.\n * @param schemaItemObject The object accepting the SchemaItem data.\n * @returns A promise that resolves to the loaded SchemaItem instance. Can be undefined.\n */\n public override async loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): Promise<SchemaItem | undefined> {\n const schemaItem = await super.loadSchemaItem(schema, name, itemType, this._incremental ? undefined : schemaItemObject);\n\n // In incremental mode, we only load the stubs of the classes. These include the modifier and base classes.\n // The fromJSON method of the actual class instances may complain about missing properties in the props, so\n // calling the fromJSON on the ECClass ensures only the bare minimum is loaded.\n if (this._incremental && schemaItemObject && schemaItem) {\n await schemaItem.fromJSON(schemaItemObject);\n }\n\n this.schemaItemLoading(schemaItem);\n return schemaItem;\n }\n\n private schemaItemLoading(schemaItem: SchemaItem | undefined): void {\n if (schemaItem === undefined)\n return;\n\n if (schemaItem.loadingController === undefined) {\n const controller = new SchemaLoadingController();\n schemaItem.setLoadingController(controller);\n\n return this.schemaItemLoading(schemaItem);\n }\n\n if (ECClass.isECClass(schemaItem)\n || schemaItem.schemaItemType === SchemaItemType.KindOfQuantity\n || schemaItem.schemaItemType === SchemaItemType.Format)\n schemaItem.loadingController.isComplete = !this._incremental;\n else\n schemaItem.loadingController.isComplete = true;\n }\n}"]}
@@ -1,5 +1,5 @@
1
- import { SchemaContext } from "../Context";
2
1
  import { AnySchemaItemProps, KindOfQuantityProps, SchemaItemProps } from "../Deserialization/JsonProps";
2
+ import { SchemaInfo } from "../Interfaces";
3
3
  /**
4
4
  * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.
5
5
  * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb
@@ -8,13 +8,13 @@ import { AnySchemaItemProps, KindOfQuantityProps, SchemaItemProps } from "../Des
8
8
  */
9
9
  export declare class SchemaItemParser {
10
10
  protected _schema: string;
11
- protected _context: SchemaContext;
11
+ protected _schemaInfos: Iterable<SchemaInfo>;
12
12
  /**
13
13
  * Initializes a new SchemaItemParser.
14
14
  * @param schemaName The name the Schema containing the SchemaItems.
15
15
  * @param context The SchemaContext containing the Schema.
16
16
  */
17
- constructor(schemaName: string, context: SchemaContext);
17
+ constructor(schemaName: string, schemaInfos: Iterable<SchemaInfo>);
18
18
  /**
19
19
  * Parses the given SchemaItemProps JSON returned from an ECSql query.
20
20
  * @param data The SchemaItemProps JSON as returned from an iModelDb.
@@ -29,7 +29,7 @@ export declare class SchemaItemParser {
29
29
  * @param rawTypeName The name or aliased name of the SchemaItem.
30
30
  * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'
31
31
  */
32
- getQualifiedTypeName(rawTypeName: string): Promise<string>;
32
+ getQualifiedTypeName(rawTypeName: string): string;
33
33
  private resolveNameFromAlias;
34
34
  }
35
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItemParsers.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemParsers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAUxG;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC;IAElC;;;;OAIG;gBACgB,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAK7D;;;;OAIG;IACU,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAUtE;;;;;;;OAOG;IACU,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAgBzD,oBAAoB;CAOnC;AAMD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD;;;;OAIG;IACmB,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAWtE,sBAAsB;YActB,0BAA0B;CAmBzC"}
1
+ {"version":3,"file":"SchemaItemParsers.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemParsers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAExG,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAS3C;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAE7C;;;;OAIG;gBACgB,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC;IAKxE;;;;OAIG;IACU,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAUtE;;;;;;;OAOG;IACI,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAgBxD,OAAO,CAAC,oBAAoB;CAO7B;AAMD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD;;;;OAIG;IACmB,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAWpF,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,0BAA0B;CAmBnC"}
@@ -17,15 +17,15 @@ const SchemaParser_1 = require("./SchemaParser");
17
17
  */
18
18
  class SchemaItemParser {
19
19
  _schema;
20
- _context;
20
+ _schemaInfos;
21
21
  /**
22
22
  * Initializes a new SchemaItemParser.
23
23
  * @param schemaName The name the Schema containing the SchemaItems.
24
24
  * @param context The SchemaContext containing the Schema.
25
25
  */
26
- constructor(schemaName, context) {
26
+ constructor(schemaName, schemaInfos) {
27
27
  this._schema = schemaName;
28
- this._context = context;
28
+ this._schemaInfos = schemaInfos;
29
29
  }
30
30
  /**
31
31
  * Parses the given SchemaItemProps JSON returned from an ECSql query.
@@ -48,7 +48,7 @@ class SchemaItemParser {
48
48
  * @param rawTypeName The name or aliased name of the SchemaItem.
49
49
  * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'
50
50
  */
51
- async getQualifiedTypeName(rawTypeName) {
51
+ getQualifiedTypeName(rawTypeName) {
52
52
  const nameParts = rawTypeName.split(":");
53
53
  if (nameParts.length !== 2) {
54
54
  const [schemaName, itemName] = SchemaItem_1.SchemaItem.parseFullName(rawTypeName);
@@ -56,15 +56,15 @@ class SchemaItemParser {
56
56
  return `${this._schema}.${itemName}`;
57
57
  return rawTypeName;
58
58
  }
59
- const resolvedName = await this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());
59
+ const resolvedName = this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());
60
60
  if (!resolvedName)
61
61
  throw new Error(`No valid schema found for alias '${nameParts[0]}'`);
62
62
  return `${resolvedName}.${nameParts[1]}`;
63
63
  }
64
- async resolveNameFromAlias(alias) {
65
- for (const schema of this._context.getKnownSchemas()) {
66
- if (schema.alias === alias)
67
- return schema.schemaKey.name;
64
+ resolveNameFromAlias(alias) {
65
+ for (const schemaInfo of this._schemaInfos) {
66
+ if (schemaInfo.alias === alias)
67
+ return schemaInfo.schemaKey.name;
68
68
  }
69
69
  return undefined;
70
70
  }
@@ -85,31 +85,31 @@ class KindOfQuantityParser extends SchemaItemParser {
85
85
  async parse(data) {
86
86
  const mutableProps = await super.parse(data);
87
87
  if (mutableProps.persistenceUnit) {
88
- mutableProps.persistenceUnit = await this.getQualifiedTypeName(mutableProps.persistenceUnit);
88
+ mutableProps.persistenceUnit = this.getQualifiedTypeName(mutableProps.persistenceUnit);
89
89
  }
90
- mutableProps.presentationUnits = await this.parsePresentationUnits(mutableProps);
90
+ mutableProps.presentationUnits = this.parsePresentationUnits(mutableProps);
91
91
  return mutableProps;
92
92
  }
93
- async parsePresentationUnits(props) {
93
+ parsePresentationUnits(props) {
94
94
  const presentationUnits = [];
95
95
  if (!props.presentationUnits)
96
96
  return [];
97
97
  for (const presentationUnit of props.presentationUnits) {
98
98
  const presFormatOverride = OverrideFormat_1.OverrideFormat.parseFormatString(presentationUnit);
99
- const formatString = await this.createOverrideFormatString(presFormatOverride);
99
+ const formatString = this.createOverrideFormatString(presFormatOverride);
100
100
  presentationUnits.push(formatString);
101
101
  }
102
102
  ;
103
103
  return presentationUnits;
104
104
  }
105
- async createOverrideFormatString(overrideFormatProps) {
106
- let formatFullName = await this.getQualifiedTypeName(overrideFormatProps.name);
105
+ createOverrideFormatString(overrideFormatProps) {
106
+ let formatFullName = this.getQualifiedTypeName(overrideFormatProps.name);
107
107
  if (overrideFormatProps.precision)
108
108
  formatFullName += `(${overrideFormatProps.precision.toString()})`;
109
109
  if (undefined === overrideFormatProps.unitAndLabels)
110
110
  return formatFullName;
111
111
  for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {
112
- const unitFullName = await this.getQualifiedTypeName(unit);
112
+ const unitFullName = this.getQualifiedTypeName(unit);
113
113
  if (undefined === unitLabel)
114
114
  formatFullName += `[${unitFullName}]`;
115
115
  else
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItemParsers.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemParsers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAIhG,4CAAmD;AACnD,+DAAiF;AACjF,uDAAoD;AACpD,iDAAsD;AAMtD;;;;;GAKG;AACH,MAAa,gBAAgB;IACjB,OAAO,CAAS;IAChB,QAAQ,CAAgB;IAElC;;;;OAIG;IACH,YAAmB,UAAkB,EAAE,OAAsB;QAC3D,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,KAAK,CAAC,IAAwB;QACzC,MAAM,KAAK,GAAG,IAA8B,CAAC;QAC7C,KAAK,CAAC,cAAc,GAAG,IAAA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CAAC,IAAI,CAAC,CAAC;QAC/E,IAAI,mBAAmB,CAAC,SAAS;YAC/B,cAAc,IAAI,IAAI,mBAAmB,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;QAEpE,IAAI,SAAS,KAAK,mBAAmB,CAAC,aAAa;YACjD,OAAO,cAAc,CAAC;QAExB,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,mBAAmB,CAAC,aAAa,EAAE,CAAC;YAClE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAE3D,IAAI,SAAS,KAAK,SAAS;gBACzB,cAAc,IAAI,IAAI,YAAY,GAAG,CAAC;;gBAEtC,cAAc,IAAI,IAAI,YAAY,IAAI,SAAS,GAAG,CAAC;QACvD,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAlDD,oDAkDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { SchemaContext } from \"../Context\";\nimport { AnySchemaItemProps, KindOfQuantityProps, SchemaItemProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType } from \"../ECObjects\";\nimport { OverrideFormat, OverrideFormatProps } from \"../Metadata/OverrideFormat\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { parseCustomAttribute } from \"./SchemaParser\";\n\ntype MutableSchemaItemProps = {\n -readonly [K in keyof SchemaItemProps]: SchemaItemProps[K]\n};\n\n/**\n * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.\n * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb\n * is in a different format than is required for a SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaItemParser {\n protected _schema: string;\n protected _context: SchemaContext;\n\n /**\n * Initializes a new SchemaItemParser.\n * @param schemaName The name the Schema containing the SchemaItems.\n * @param context The SchemaContext containing the Schema.\n */\n public constructor(schemaName: string, context: SchemaContext) {\n this._schema = schemaName;\n this._context = context;\n }\n\n /**\n * Parses the given SchemaItemProps JSON returned from an ECSql query.\n * @param data The SchemaItemProps JSON as returned from an iModelDb.\n * @returns The corrected SchemaItemProps Json.\n */\n public async parse(data: AnySchemaItemProps): Promise<SchemaItemProps> {\n const props = data as MutableSchemaItemProps;\n props.schemaItemType = parseSchemaItemType((data as any).schemaItemType);\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n return props;\n }\n\n /**\n * Helper method to resolve the SchemaItem's full name from the given rawTypeName.\n * If the SchemaItem is defined in the same Schema from which it is referenced,\n * the rawTypeName will be SchemaItem name ('PhysicalElement'). Otherwise,\n * the rawTypeName will have the schema alias ('bis:PhysicalElement').\n * @param rawTypeName The name or aliased name of the SchemaItem.\n * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'\n */\n public async getQualifiedTypeName(rawTypeName: string): Promise<string> {\n const nameParts = rawTypeName.split(\":\");\n if (nameParts.length !== 2) {\n const [schemaName, itemName] = SchemaItem.parseFullName(rawTypeName);\n if (!schemaName || schemaName === '')\n return `${this._schema}.${itemName}`;\n return rawTypeName;\n }\n\n const resolvedName = await this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());\n if (!resolvedName)\n throw new Error(`No valid schema found for alias '${nameParts[0]}'`);\n\n return `${resolvedName}.${nameParts[1]}`;\n }\n\n private async resolveNameFromAlias(alias: string): Promise<string | undefined> {\n for (const schema of this._context.getKnownSchemas()) {\n if (schema.alias === alias)\n return schema.schemaKey.name;\n }\n return undefined;\n }\n}\n\ntype MutableKindOfQuantityProps = {\n -readonly [K in keyof KindOfQuantityProps]: KindOfQuantityProps[K]\n};\n\n/**\n * Parses KindOfQuantityProps JSON returned from an ECSql query and returns the correct KindOfQuantityProps JSON.\n * This is necessary as a small amount information (ie. unqualified type names of presentationUnits) returned from\n * the iModelDb is in a different format than is required for a KindOfQuantityProps JSON object.\n * @internal\n */\nexport class KindOfQuantityParser extends SchemaItemParser {\n /**\n * Parses the given KindOfQuantityProps JSON returned from an ECSql query.\n * @param data The KindOfQuantityProps JSON as returned from an iModelDb.\n * @returns The corrected KindOfQuantityProps Json.\n */\n public override async parse(data: KindOfQuantityProps): Promise<KindOfQuantityProps> {\n const mutableProps = await super.parse(data) as MutableKindOfQuantityProps;\n\n if (mutableProps.persistenceUnit) {\n mutableProps.persistenceUnit = await this.getQualifiedTypeName(mutableProps.persistenceUnit);\n }\n mutableProps.presentationUnits = await this.parsePresentationUnits(mutableProps);\n\n return mutableProps;\n }\n\n private async parsePresentationUnits(props: KindOfQuantityProps): Promise<string[]> {\n const presentationUnits: string[] = [];\n if (!props.presentationUnits)\n return [];\n\n for (const presentationUnit of props.presentationUnits) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(presentationUnit);\n const formatString = await this.createOverrideFormatString(presFormatOverride);\n presentationUnits.push(formatString);\n };\n\n return presentationUnits;\n }\n\n private async createOverrideFormatString(overrideFormatProps: OverrideFormatProps): Promise<string> {\n\n let formatFullName = await this.getQualifiedTypeName(overrideFormatProps.name);\n if (overrideFormatProps.precision)\n formatFullName += `(${overrideFormatProps.precision.toString()})`;\n\n if (undefined === overrideFormatProps.unitAndLabels)\n return formatFullName;\n\n for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {\n const unitFullName = await this.getQualifiedTypeName(unit);\n\n if (undefined === unitLabel)\n formatFullName += `[${unitFullName}]`;\n else\n formatFullName += `[${unitFullName}|${unitLabel}]`;\n }\n return formatFullName;\n }\n}"]}
1
+ {"version":3,"file":"SchemaItemParsers.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemParsers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,4CAAmD;AAEnD,+DAAiF;AAC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ACnG,MAAM,YAAY,GAAG,IAAI,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;YACzE,iBAAiB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;QAAA,CAAC;QAEF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,0BAA0B,CAAC,mBAAwC;QAEzE,IAAI,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzE,IAAI,mBAAmB,CAAC,SAAS;YAC/B,cAAc,IAAI,IAAI,mBAAmB,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;QAEpE,IAAI,SAAS,KAAK,mBAAmB,CAAC,aAAa;YACjD,OAAO,cAAc,CAAC;QAExB,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,mBAAmB,CAAC,aAAa,EAAE,CAAC;YAClE,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAErD,IAAI,SAAS,KAAK,SAAS;gBACzB,cAAc,IAAI,IAAI,YAAY,GAAG,CAAC;;gBAEtC,cAAc,IAAI,IAAI,YAAY,IAAI,SAAS,GAAG,CAAC;QACvD,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAlDD,oDAkDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { AnySchemaItemProps, KindOfQuantityProps, SchemaItemProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType } from \"../ECObjects\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { OverrideFormat, OverrideFormatProps } from \"../Metadata/OverrideFormat\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { parseCustomAttribute } from \"./SchemaParser\";\n\ntype MutableSchemaItemProps = {\n -readonly [K in keyof SchemaItemProps]: SchemaItemProps[K]\n};\n\n/**\n * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.\n * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb\n * is in a different format than is required for a SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaItemParser {\n protected _schema: string;\n protected _schemaInfos: Iterable<SchemaInfo>;\n\n /**\n * Initializes a new SchemaItemParser.\n * @param schemaName The name the Schema containing the SchemaItems.\n * @param context The SchemaContext containing the Schema.\n */\n public constructor(schemaName: string, schemaInfos: Iterable<SchemaInfo>) {\n this._schema = schemaName;\n this._schemaInfos = schemaInfos;\n }\n\n /**\n * Parses the given SchemaItemProps JSON returned from an ECSql query.\n * @param data The SchemaItemProps JSON as returned from an iModelDb.\n * @returns The corrected SchemaItemProps Json.\n */\n public async parse(data: AnySchemaItemProps): Promise<SchemaItemProps> {\n const props = data as MutableSchemaItemProps;\n props.schemaItemType = parseSchemaItemType((data as any).schemaItemType);\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n return props;\n }\n\n /**\n * Helper method to resolve the SchemaItem's full name from the given rawTypeName.\n * If the SchemaItem is defined in the same Schema from which it is referenced,\n * the rawTypeName will be SchemaItem name ('PhysicalElement'). Otherwise,\n * the rawTypeName will have the schema alias ('bis:PhysicalElement').\n * @param rawTypeName The name or aliased name of the SchemaItem.\n * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'\n */\n public getQualifiedTypeName(rawTypeName: string): string {\n const nameParts = rawTypeName.split(\":\");\n if (nameParts.length !== 2) {\n const [schemaName, itemName] = SchemaItem.parseFullName(rawTypeName);\n if (!schemaName || schemaName === '')\n return `${this._schema}.${itemName}`;\n return rawTypeName;\n }\n\n const resolvedName = this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());\n if (!resolvedName)\n throw new Error(`No valid schema found for alias '${nameParts[0]}'`);\n\n return `${resolvedName}.${nameParts[1]}`;\n }\n\n private resolveNameFromAlias(alias: string): string | undefined {\n for (const schemaInfo of this._schemaInfos) {\n if (schemaInfo.alias === alias)\n return schemaInfo.schemaKey.name;\n }\n return undefined;\n }\n}\n\ntype MutableKindOfQuantityProps = {\n -readonly [K in keyof KindOfQuantityProps]: KindOfQuantityProps[K]\n};\n\n/**\n * Parses KindOfQuantityProps JSON returned from an ECSql query and returns the correct KindOfQuantityProps JSON.\n * This is necessary as a small amount information (ie. unqualified type names of presentationUnits) returned from\n * the iModelDb is in a different format than is required for a KindOfQuantityProps JSON object.\n * @internal\n */\nexport class KindOfQuantityParser extends SchemaItemParser {\n /**\n * Parses the given KindOfQuantityProps JSON returned from an ECSql query.\n * @param data The KindOfQuantityProps JSON as returned from an iModelDb.\n * @returns The corrected KindOfQuantityProps Json.\n */\n public override async parse(data: KindOfQuantityProps): Promise<KindOfQuantityProps> {\n const mutableProps = await super.parse(data) as MutableKindOfQuantityProps;\n\n if (mutableProps.persistenceUnit) {\n mutableProps.persistenceUnit = this.getQualifiedTypeName(mutableProps.persistenceUnit);\n }\n mutableProps.presentationUnits = this.parsePresentationUnits(mutableProps);\n\n return mutableProps;\n }\n\n private parsePresentationUnits(props: KindOfQuantityProps): string[] {\n const presentationUnits: string[] = [];\n if (!props.presentationUnits)\n return [];\n\n for (const presentationUnit of props.presentationUnits) {\n const presFormatOverride: OverrideFormatProps = OverrideFormat.parseFormatString(presentationUnit);\n const formatString = this.createOverrideFormatString(presFormatOverride);\n presentationUnits.push(formatString);\n };\n\n return presentationUnits;\n }\n\n private createOverrideFormatString(overrideFormatProps: OverrideFormatProps): string {\n\n let formatFullName = this.getQualifiedTypeName(overrideFormatProps.name);\n if (overrideFormatProps.precision)\n formatFullName += `(${overrideFormatProps.precision.toString()})`;\n\n if (undefined === overrideFormatProps.unitAndLabels)\n return formatFullName;\n\n for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {\n const unitFullName = this.getQualifiedTypeName(unit);\n\n if (undefined === unitLabel)\n formatFullName += `[${unitFullName}]`;\n else\n formatFullName += `[${unitFullName}|${unitLabel}]`;\n }\n return formatFullName;\n }\n}"]}
@@ -21,10 +21,10 @@ SELECT
21
21
  'name', [koq].[Name],
22
22
  'label', [koq].[DisplayLabel],
23
23
  'description', [koq].[Description]
24
- ${singleSchema ? `
25
24
  ,'relativeError', [koq].[RelativeError],
26
- 'persistenceUnit', [koq].[PersistenceUnit],
27
- 'presentationUnits', (
25
+ 'persistenceUnit', [koq].[PersistenceUnit]
26
+ ${singleSchema ? `
27
+ , 'presentationUnits', (
28
28
  SELECT json_group_array(js."value")
29
29
  FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js
30
30
  WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItemQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaItemQueries.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;qFAGqF;AAErF;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;MAQ7C,YAAY,CAAC,CAAC,CAAC;;;;;;;OAOd,CAAA,CAAC,CAAC,EAAE;;;;EAIT,YAAY,CAAC,CAAC,CAAC;;;;CAIhB,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;EAYnD,YAAY,CAAC,CAAC,CAAC;;;;CAIhB,CAAC,CAAC,CAAC,EAAE;CACL,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuB9C,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAC;A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AAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAA;AAED;;;GAGG;AACH,gEAAgE;AACnD,QAAA,iBAAiB,GAAG;IAC/B,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,UAAU;IACV,MAAM;CACP,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/************************************************************************************\n * All SchemaItem queries for each SchemaItemType are defined here. These queries\n * are shared for both 'partial schema' and 'full schema' queries.\n ***********************************************************************************/\n\n/**\n * Query for SchemaItemType KindOfQuantity data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst kindOfQuantity = (singleSchema?: boolean) => `\nSELECT\n [koq].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'KindOfQuantity',\n 'name', [koq].[Name],\n 'label', [koq].[DisplayLabel],\n 'description', [koq].[Description]\n ${singleSchema ? `\n ,'relativeError', [koq].[RelativeError],\n 'persistenceUnit', [koq].[PersistenceUnit],\n 'presentationUnits', (\n SELECT json_group_array(js.\"value\")\n FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js\n WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]\n ) `: \"\"}\n ) as [item]\nFROM\n [meta].[KindOfQuantityDef] [koq]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType PropertyCategory data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst propertyCategory = (singleSchema?: boolean) => `\nSELECT\n [pc].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'PropertyCategory',\n 'name', [pc].[Name],\n 'label', [pc].[DisplayLabel],\n 'description', [pc].[Description],\n 'priority', [pc].[Priority]\n ) as [item]\nFROM\n [meta].[PropertyCategoryDef] [pc]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Enumeration data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst enumeration = (singleSchema?: boolean) => `\nSELECT\n [ed].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Enumeration',\n 'name', [ed].[Name],\n 'label', [ed].[DisplayLabel],\n 'description', [ed].[Description],\n 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),\n 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),\n 'enumerators', (\n SELECT json_group_array(json(json_object(\n 'name', json_extract(js.\"value\", '$.Name'),\n 'value', IFNULL(json_extract(js.\"value\", '$.StringValue'), (json_extract(js.\"value\", '$.IntValue'))),\n 'label', json_extract(js.\"value\", '$.DisplayLabel'),\n 'description', json_extract(js.\"value\", '$.Description')\n )))\n FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js\n WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]\n )\n ) as [item]\nFROM\n [meta].[ECEnumerationDef] [ed]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Unit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Unit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'definition', [ud].[Definition],\n 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),\n 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),\n 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),\n 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),\n 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [uss]\n ON [uss].[ECInstanceId] = [usd].[Schema].[Id]\nJOIN [meta].[PhenomenonDef] [pd]\n ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [ps]\n ON [ps].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NULL\n`;\n\n/**\n * Query for SchemaItemType InvertedUnit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst invertedUnit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'InvertedUnit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),\n 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))\n ) as [item]\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [systemSchema]\n ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]\nLEFT JOIN [meta].[UnitDef] [iud]\n ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [ius]\n ON [ius].[ECInstanceId] = [iud].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NOT NULL\n`;\n\n/**\n * Query for SchemaItemType Constant data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst constant = (singleSchema?: boolean) => `\nSELECT\n [cd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Constant',\n 'name', [cd].[Name],\n 'label', [cd].[DisplayLabel],\n 'description', [cd].[Description],\n 'definition', [cd].[Definition],\n 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),\n 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),\n 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [cd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : \"\"}\nJOIN [meta].[PhenomenonDef] [phenomDef]\n ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [phenomSchema]\n ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [cd].[IsConstant] = 1\n`;\n\n/**\n * Query for SchemaItemType UnitSystem data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unitSystem = (singleSchema?: boolean) => `\nSELECT\n [us].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'UnitSystem',\n 'name', [us].[Name],\n 'label', [us].[DisplayLabel],\n 'description', [us].[Description]\n ) as [item]\nFROM\n [meta].[UnitSystemDef] [us]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Phenomenon data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst phenomenon = (singleSchema?: boolean) => `\nSELECT\n [pd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Phenomenon',\n 'name', [pd].[Name],\n 'label', [pd].[DisplayLabel],\n 'description', [pd].[Description],\n 'definition', [pd].[Definition]\n ) as [item]\nFROM\n [meta].[PhenomenonDef] [pd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Format data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst format = (singleSchema?: boolean) => `\nSELECT\n [fd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Format',\n 'name', [fd].[Name],\n 'label', [fd].[DisplayLabel],\n 'description', [fd].[Description],\n 'type', json_extract([fd].[NumericSpec], '$.type'),\n 'precision', json_extract([fd].[NumericSpec], '$.precision'),\n 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),\n 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),\n 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),\n 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),\n 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),\n 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),\n 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),\n 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),\n 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),\n 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')\n ${singleSchema ? `\n ,'composite', (\n SELECT\n json_object(\n 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),\n 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),\n 'units', (\n SELECT json_group_array(json(json_object(\n 'name', CONCAT([sd].[Name], '.', [ud].[Name]),\n 'label', [fud].[Label]\n )))\n FROM [meta].[FormatDef] [fd2]\n LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]\n LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]\n INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]\n WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]\n )\n )\n FROM [meta].[FormatDef] [fd1]\n WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL\n )` : \"\"}\n) AS item\nFROM\n [meta].[FormatDef] [fd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`\n\n/**\n * Queries for each SchemaItemType\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const SchemaItemQueries = {\n kindOfQuantity,\n propertyCategory,\n enumeration,\n unit,\n invertedUnit,\n constant,\n unitSystem,\n phenomenon,\n format\n};\n"]}
1
+ {"version":3,"file":"S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;;;;;;;EAe3C,YAAY,CAAC,CAAC,CAAC;;gFAE+D,CAAC,CAAC,CAAC,EAAE;;;;;;IAMjF,YAAY,CAAC,CAAC,CAAC;oCACiB,CAAC,CAAC,CAAC,EAAE;;CAExC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;EAW7C,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;EAY7C,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,YAAsB,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;MAoBrC,YAAY,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;MAoBf,CAAC,CAAC,CAAC,EAAE;;;;EAIT,YAAY,CAAC,CAAC,CAAC;;;oCAGmB,CAAC,CAAC,CAAC,EAAE;CACxC,CAAA;AAED;;;GAGG;AACH,gEAAgE;AACnD,QAAA,iBAAiB,GAAG;IAC/B,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,UAAU;IACV,MAAM;CACP,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/************************************************************************************\n * All SchemaItem queries for each SchemaItemType are defined here. These queries\n * are shared for both 'partial schema' and 'full schema' queries.\n ***********************************************************************************/\n\n/**\n * Query for SchemaItemType KindOfQuantity data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst kindOfQuantity = (singleSchema?: boolean) => `\nSELECT\n [koq].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'KindOfQuantity',\n 'name', [koq].[Name],\n 'label', [koq].[DisplayLabel],\n 'description', [koq].[Description]\n ,'relativeError', [koq].[RelativeError],\n 'persistenceUnit', [koq].[PersistenceUnit]\n ${singleSchema ? `\n , 'presentationUnits', (\n SELECT json_group_array(js.\"value\")\n FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js\n WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]\n ) `: \"\"}\n ) as [item]\nFROM\n [meta].[KindOfQuantityDef] [koq]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType PropertyCategory data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst propertyCategory = (singleSchema?: boolean) => `\nSELECT\n [pc].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'PropertyCategory',\n 'name', [pc].[Name],\n 'label', [pc].[DisplayLabel],\n 'description', [pc].[Description],\n 'priority', [pc].[Priority]\n ) as [item]\nFROM\n [meta].[PropertyCategoryDef] [pc]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName\n` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Enumeration data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst enumeration = (singleSchema?: boolean) => `\nSELECT\n [ed].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Enumeration',\n 'name', [ed].[Name],\n 'label', [ed].[DisplayLabel],\n 'description', [ed].[Description],\n 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),\n 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),\n 'enumerators', (\n SELECT json_group_array(json(json_object(\n 'name', json_extract(js.\"value\", '$.Name'),\n 'value', IFNULL(json_extract(js.\"value\", '$.StringValue'), (json_extract(js.\"value\", '$.IntValue'))),\n 'label', json_extract(js.\"value\", '$.DisplayLabel'),\n 'description', json_extract(js.\"value\", '$.Description')\n )))\n FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js\n WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]\n )\n ) as [item]\nFROM\n [meta].[ECEnumerationDef] [ed]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Unit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'Unit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'definition', [ud].[Definition],\n 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),\n 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),\n 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),\n 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),\n 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [uss]\n ON [uss].[ECInstanceId] = [usd].[Schema].[Id]\nJOIN [meta].[PhenomenonDef] [pd]\n ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [ps]\n ON [ps].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NULL\n`;\n\n/**\n * Query for SchemaItemType InvertedUnit data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst invertedUnit = (singleSchema?: boolean) => `\nSELECT\n [ud].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'InvertedUnit',\n 'name', [ud].[Name],\n 'label', [ud].[DisplayLabel],\n 'description', [ud].[Description],\n 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),\n 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))\n ) as [item]\nFROM\n [meta].[UnitDef] [ud]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : \"\"}\nJOIN [meta].[UnitSystemDef] [usd]\n ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]\nJOIN [meta].[ECSchemaDef] [systemSchema]\n ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]\nLEFT JOIN [meta].[UnitDef] [iud]\n ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [ius]\n ON [ius].[ECInstanceId] = [iud].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [ud].[IsConstant] = 0 AND\n [ud].[InvertingUnit] IS NOT NULL\n`;\n\n/**\n * Query for SchemaItemType Constant data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst constant = (singleSchema?: boolean) => `\nSELECT\n [cd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Constant',\n 'name', [cd].[Name],\n 'label', [cd].[DisplayLabel],\n 'description', [cd].[Description],\n 'definition', [cd].[Definition],\n 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),\n 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),\n 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])\n ) as item\nFROM\n [meta].[UnitDef] [cd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : \"\"}\nJOIN [meta].[PhenomenonDef] [phenomDef]\n ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]\nJOIN [meta].[ECSchemaDef] [phenomSchema]\n ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]\nWHERE\n ${singleSchema ? `\n [schema].[Name] = :schemaName AND` : \"\"}\n [cd].[IsConstant] = 1\n`;\n\n/**\n * Query for SchemaItemType UnitSystem data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst unitSystem = (singleSchema?: boolean) => `\nSELECT\n [us].[Schema].[Id] AS [SchemaId],\n json_object (\n 'schemaItemType', 'UnitSystem',\n 'name', [us].[Name],\n 'label', [us].[DisplayLabel],\n 'description', [us].[Description]\n ) as [item]\nFROM\n [meta].[UnitSystemDef] [us]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Phenomenon data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst phenomenon = (singleSchema?: boolean) => `\nSELECT\n [pd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Phenomenon',\n 'name', [pd].[Name],\n 'label', [pd].[DisplayLabel],\n 'description', [pd].[Description],\n 'definition', [pd].[Definition]\n ) as [item]\nFROM\n [meta].[PhenomenonDef] [pd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`;\n\n/**\n * Query for SchemaItemType Format data.\n * @param singleSchema Indicates if a filter and join for a single Schema should be applied.\n */\nconst format = (singleSchema?: boolean) => `\nSELECT\n [fd].[Schema].[Id] AS [SchemaId],\n json_object(\n 'schemaItemType', 'Format',\n 'name', [fd].[Name],\n 'label', [fd].[DisplayLabel],\n 'description', [fd].[Description],\n 'type', json_extract([fd].[NumericSpec], '$.type'),\n 'precision', json_extract([fd].[NumericSpec], '$.precision'),\n 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),\n 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),\n 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),\n 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),\n 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),\n 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),\n 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),\n 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),\n 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),\n 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')\n ${singleSchema ? `\n ,'composite', (\n SELECT\n json_object(\n 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),\n 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),\n 'units', (\n SELECT json_group_array(json(json_object(\n 'name', CONCAT([sd].[Name], '.', [ud].[Name]),\n 'label', [fud].[Label]\n )))\n FROM [meta].[FormatDef] [fd2]\n LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]\n LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]\n INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]\n WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]\n )\n )\n FROM [meta].[FormatDef] [fd1]\n WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL\n )` : \"\"}\n) AS item\nFROM\n [meta].[FormatDef] [fd]\n${singleSchema ? `\nJOIN\n [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]\nWHERE [schema].[Name] = :schemaName` : \"\"}\n`\n\n/**\n * Queries for each SchemaItemType\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const SchemaItemQueries = {\n kindOfQuantity,\n propertyCategory,\n enumeration,\n unit,\n invertedUnit,\n constant,\n unitSystem,\n phenomenon,\n format\n};\n"]}
@@ -1,6 +1,11 @@
1
- import { SchemaContext } from "../Context";
2
1
  import { SchemaItemProps, SchemaProps } from "../Deserialization/JsonProps";
2
+ import { SchemaItemType } from "../ECObjects";
3
+ import { SchemaInfo } from "../Interfaces";
3
4
  import { CustomAttribute } from "../Metadata/CustomAttribute";
5
+ interface NamedSchemaItemProps extends SchemaItemProps {
6
+ name: string;
7
+ schemaItemType: SchemaItemType;
8
+ }
4
9
  /**
5
10
  * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.
6
11
  * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)
@@ -16,7 +21,7 @@ export declare class SchemaParser {
16
21
  * @param context The SchemaContext that will contain the schema and it's references.
17
22
  * @returns The corrected SchemaProps JSON.
18
23
  */
19
- static parse(schema: SchemaProps, context: SchemaContext): Promise<SchemaProps>;
24
+ static parse(schema: SchemaProps, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaProps>;
20
25
  /**
21
26
  * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.
22
27
  * @param schemaItems The SchemaItemProps array returned from an iModelDb.
@@ -24,9 +29,9 @@ export declare class SchemaParser {
24
29
  * @param context The SchemaContext containing the Schema.
25
30
  * @returns The corrected SchemaItemProps.
26
31
  */
27
- static parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, context: SchemaContext): Promise<SchemaItemProps[] | undefined>;
32
+ static parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps[] | undefined>;
28
33
  private static parseItems;
29
- static parseItem(props: SchemaItemProps, schemaName: string, context: SchemaContext): Promise<SchemaItemProps>;
34
+ static parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps>;
30
35
  }
31
36
  /**
32
37
  * Utility method to parse CustomAttribute data retrieved from a ECSql query.
@@ -39,4 +44,5 @@ export declare function parseCustomAttribute(customAttribute: {
39
44
  ecSchema: string;
40
45
  [propName: string]: any;
41
46
  }): CustomAttribute;
47
+ export {};
42
48
  //# sourceMappingURL=SchemaParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaParser.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAY9D;;;;;;GAMG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;WACiB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IAiB5F;;;;;;OAMG;WACiB,gBAAgB,CAAC,WAAW,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CAAC,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAyB5I;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAA,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,GAAG,eAAe,CAKrI"}
@@ -28,14 +28,14 @@ class SchemaParser {
28
28
  * @param context The SchemaContext that will contain the schema and it's references.
29
29
  * @returns The corrected SchemaProps JSON.
30
30
  */
31
- static async parse(schema, context) {
31
+ static async parse(schema, schemaInfos) {
32
32
  const props = schema;
33
33
  props.$schema = Constants_1.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
34
34
  props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return parseCustomAttribute(attr); }) : undefined;
35
35
  props.label = props.label === null ? undefined : props.label;
36
36
  props.description = props.description === null ? undefined : props.description;
37
37
  if (props.items) {
38
- props.items = await this.parseItems(props.items, props.name, context);
38
+ props.items = await this.parseItems(props.items, props.name, schemaInfos);
39
39
  }
40
40
  if (!props.customAttributes || props.customAttributes.length === 0)
41
41
  delete props.customAttributes;
@@ -49,47 +49,47 @@ class SchemaParser {
49
49
  * @param context The SchemaContext containing the Schema.
50
50
  * @returns The corrected SchemaItemProps.
51
51
  */
52
- static async parseSchemaItems(schemaItems, schemaName, context) {
52
+ static async parseSchemaItems(schemaItems, schemaName, schemaInfos) {
53
53
  const items = [];
54
54
  for (const item of schemaItems) {
55
- const props = await this.parseItem(item, schemaName, context);
55
+ const props = await this.parseItem(item, schemaName, schemaInfos);
56
56
  const cleaned = JSON.parse(JSON.stringify(props, clean));
57
57
  items.push(cleaned);
58
58
  }
59
59
  return items.length > 0 ? items : undefined;
60
60
  }
61
- static async parseItems(schemaItemProps, schemaName, context) {
61
+ static async parseItems(schemaItemProps, schemaName, schemaInfos) {
62
62
  const items = {};
63
63
  for (const itemProps of schemaItemProps) {
64
- const props = await this.parseItem(itemProps, schemaName, context);
64
+ const props = await this.parseItem(itemProps, schemaName, schemaInfos);
65
65
  items[props.name] = props;
66
66
  delete props.name;
67
67
  }
68
68
  return Object.keys(items).length > 0 ? items : undefined;
69
69
  }
70
- static async parseItem(props, schemaName, context) {
70
+ static async parseItem(props, schemaName, schemaInfos) {
71
71
  const schemaItem = "string" === typeof (props) ? JSON.parse(props) : props;
72
72
  const type = (0, ECObjects_1.parseSchemaItemType)(schemaItem.schemaItemType);
73
73
  switch (type) {
74
74
  case ECObjects_1.SchemaItemType.KindOfQuantity:
75
- const koqParser = new SchemaItemParsers_1.KindOfQuantityParser(schemaName, context);
76
- return koqParser.parse(schemaItem);
75
+ const koqParser = new SchemaItemParsers_1.KindOfQuantityParser(schemaName, schemaInfos);
76
+ return await koqParser.parse(schemaItem);
77
77
  case ECObjects_1.SchemaItemType.EntityClass:
78
78
  case ECObjects_1.SchemaItemType.StructClass:
79
- const classParser = new ClassParsers_1.ClassParser(schemaName, context);
80
- return classParser.parse(schemaItem);
79
+ const classParser = new ClassParsers_1.ClassParser(schemaName, schemaInfos);
80
+ return await classParser.parse(schemaItem);
81
81
  case ECObjects_1.SchemaItemType.RelationshipClass:
82
- const relationshipParser = new ClassParsers_1.RelationshipClassParser(schemaName, context);
83
- return relationshipParser.parse(schemaItem);
82
+ const relationshipParser = new ClassParsers_1.RelationshipClassParser(schemaName, schemaInfos);
83
+ return await relationshipParser.parse(schemaItem);
84
84
  case ECObjects_1.SchemaItemType.Mixin:
85
- const mixinParser = new ClassParsers_1.MixinParser(schemaName, context);
86
- return mixinParser.parse(schemaItem);
85
+ const mixinParser = new ClassParsers_1.MixinParser(schemaName, schemaInfos);
86
+ return await mixinParser.parse(schemaItem);
87
87
  case ECObjects_1.SchemaItemType.CustomAttributeClass:
88
- const caParser = new ClassParsers_1.CustomAttributeClassParser(schemaName, context);
89
- return caParser.parse(schemaItem);
88
+ const caParser = new ClassParsers_1.CustomAttributeClassParser(schemaName, schemaInfos);
89
+ return await caParser.parse(schemaItem);
90
90
  default:
91
- const itemParser = new SchemaItemParsers_1.SchemaItemParser(schemaName, context);
92
- return itemParser.parse(schemaItem);
91
+ const itemParser = new SchemaItemParsers_1.SchemaItemParser(schemaName, schemaInfos);
92
+ return await itemParser.parse(schemaItem);
93
93
  }
94
94
  }
95
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaParser.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+GhG,oDAKC;AAlHD,4CAAqD;AAGrD,4CAAmE;AAEnE,iDAA+G;AAC/G,2DAA6E;AAE7E,SAAS,KAAK,CAAC,IAAY,EAAE,KAAU;IACrC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5C,CAAC;AAMD;;;;;;GAMG;AACH,MAAa,YAAY;IACvB;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAmB,EAAE,OAAsB;QACnE,MAAM,KAAK,GAAG,MAA4B,CAAC;QAC3C,KAAK,CAAC,OAAO,GAAG,iCAAqB,CAAC,iBAAiB;YACrD,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAClJ,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7D,KAAK,CAAC,WAAW,GAAG,KAAK,CAA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AC;YAC9C,KAAK,0BAAc,CAAC,KAAK;gBACvB,MAAM,WAAW,GAAG,IAAI,0BAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBACzD,OAAO,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACvC,KAAK,0BAAc,CAAC,oBAAoB;gBACtC,MAAM,QAAQ,GAAG,IAAI,yCAA0B,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBACrE,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACpC;gBACE,MAAM,UAAU,GAAG,IAAI,oCAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBAC7D,OAAO,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AA9ED,oCA8EC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,eAA+E;IAClH,OAAO;QACL,GAAG,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC;QAC3C,SAAS,EAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE;KACpF,CAAA;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECSchemaNamespaceUris } from \"../Constants\";\nimport { SchemaContext } from \"../Context\";\nimport { SchemaItemProps, SchemaProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType, SchemaItemType } from \"../ECObjects\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { ClassParser, CustomAttributeClassParser, MixinParser, RelationshipClassParser } from \"./ClassParsers\";\nimport { KindOfQuantityParser, SchemaItemParser } from \"./SchemaItemParsers\";\n\nfunction clean(_key: string, value: any) {\n return value === null ? undefined : value;\n}\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K]\n};\n\n/**\n * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.\n * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)\n * returned from the iModelDb is in a different format than is required for a given Schema or\n * SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaParser {\n /**\n * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps\n * JSON object.\n * @param schema The SchemaProps JSON object to parse.\n * @param context The SchemaContext that will contain the schema and it's references.\n * @returns The corrected SchemaProps JSON.\n */\n public static async parse(schema: SchemaProps, context: SchemaContext): Promise<SchemaProps> {\n const props = schema as MutableSchemaProps;\n props.$schema = ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n props.label = props.label === null ? undefined : props.label;\n props.description = props.description === null ? undefined : props.description;\n if (props.items) {\n props.items = await this.parseItems(props.items as any, props.name, context);\n }\n\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n const cleaned = JSON.parse(JSON.stringify(props, clean)) as SchemaProps;\n return cleaned;\n }\n\n /**\n * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.\n * @param schemaItems The SchemaItemProps array returned from an iModelDb.\n * @param schemaName The name of the Schema to which the SchemaItemProps belong.\n * @param context The SchemaContext containing the Schema.\n * @returns The corrected SchemaItemProps.\n */\n public static async parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, context: SchemaContext): Promise<SchemaItemProps[] | undefined> {\n const items: SchemaItemProps[] = [];\n for (const item of schemaItems) {\n const props = await this.parseItem(item, schemaName, context);\n const cleaned = JSON.parse(JSON.stringify(props, clean));\n items.push(cleaned);\n }\n return items.length > 0 ? items : undefined;\n }\n\n private static async parseItems(schemaItemProps: readonly SchemaItemProps[], schemaName: string, context: SchemaContext): Promise<{ [name: string]: SchemaItemProps } | undefined> {\n const items: { [name: string]: SchemaItemProps } = {};\n for (const itemProps of schemaItemProps) {\n const props = await this.parseItem(itemProps, schemaName, context);\n items[props.name!] = props;\n delete (props as any).name;\n }\n\n return Object.keys(items).length > 0 ? items : undefined;\n }\n\n public static async parseItem(props: SchemaItemProps, schemaName: string, context: SchemaContext): Promise<SchemaItemProps> {\n const schemaItem = \"string\" === typeof (props) ? JSON.parse(props) : props;\n const type = parseSchemaItemType(schemaItem.schemaItemType);\n switch (type) {\n case SchemaItemType.KindOfQuantity:\n const koqParser = new KindOfQuantityParser(schemaName, context);\n return koqParser.parse(schemaItem);\n case SchemaItemType.EntityClass:\n case SchemaItemType.StructClass:\n const classParser = new ClassParser(schemaName, context);\n return classParser.parse(schemaItem);\n case SchemaItemType.RelationshipClass:\n const relationshipParser = new RelationshipClassParser(schemaName, context);\n return relationshipParser.parse(schemaItem);\n case SchemaItemType.Mixin:\n const mixinParser = new MixinParser(schemaName, context);\n return mixinParser.parse(schemaItem);\n case SchemaItemType.CustomAttributeClass:\n const caParser = new CustomAttributeClassParser(schemaName, context);\n return caParser.parse(schemaItem);\n default:\n const itemParser = new SchemaItemParser(schemaName, context);\n return itemParser.parse(schemaItem);\n }\n }\n}\n\n/**\n * Utility method to parse CustomAttribute data retrieved from a ECSql query.\n * @param customAttribute CustomAttribute data as retrieved from an iModel query.\n * @returns The CustomAttribute instance.\n * @internal\n */\nexport function parseCustomAttribute(customAttribute: { ecClass: string; ecSchema: string;[propName: string]: any; }): CustomAttribute {\n return {\n ...customAttribute[customAttribute.ecClass],\n className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,\n }\n}"]}
1
+ {"version":3,"file":"SchemaParser.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAoHhG,oDAKC;AAvHD,4CAAqD;AAErD,4CAAmE;AAGnE,iDAA+G;AAC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,KAAK,CAAC,UAAU,CAAyB,CAAC;QACtE,CAAC;IACH,CAAC;CACF;AA9ED,oCA8EC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,eAA+E;IAClH,OAAO;QACL,GAAG,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC;QAC3C,SAAS,EAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE;KACpF,CAAA;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { ECSchemaNamespaceUris } from \"../Constants\";\nimport { SchemaItemProps, SchemaProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType, SchemaItemType } from \"../ECObjects\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { ClassParser, CustomAttributeClassParser, MixinParser, RelationshipClassParser } from \"./ClassParsers\";\nimport { KindOfQuantityParser, SchemaItemParser } from \"./SchemaItemParsers\";\n\nfunction clean(_key: string, value: any) {\n return value === null ? undefined : value;\n}\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K]\n};\n\ninterface NamedSchemaItemProps extends SchemaItemProps {\n name: string;\n schemaItemType: SchemaItemType;\n}\n\n/**\n * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.\n * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)\n * returned from the iModelDb is in a different format than is required for a given Schema or\n * SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaParser {\n /**\n * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps\n * JSON object.\n * @param schema The SchemaProps JSON object to parse.\n * @param context The SchemaContext that will contain the schema and it's references.\n * @returns The corrected SchemaProps JSON.\n */\n public static async parse(schema: SchemaProps, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaProps> {\n const props = schema as MutableSchemaProps;\n props.$schema = ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n props.label = props.label === null ? undefined : props.label;\n props.description = props.description === null ? undefined : props.description;\n if (props.items) {\n props.items = await this.parseItems(props.items as any, props.name, schemaInfos);\n }\n\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n const cleaned = JSON.parse(JSON.stringify(props, clean)) as SchemaProps;\n return cleaned;\n }\n\n /**\n * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.\n * @param schemaItems The SchemaItemProps array returned from an iModelDb.\n * @param schemaName The name of the Schema to which the SchemaItemProps belong.\n * @param context The SchemaContext containing the Schema.\n * @returns The corrected SchemaItemProps.\n */\n public static async parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps[] | undefined> {\n const items: NamedSchemaItemProps[] = [];\n for (const item of schemaItems) {\n const props = await this.parseItem(item, schemaName, schemaInfos);\n const cleaned = JSON.parse(JSON.stringify(props, clean));\n items.push(cleaned);\n }\n return items.length > 0 ? items : undefined;\n }\n\n private static async parseItems(schemaItemProps: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<{ [name: string]: SchemaItemProps } | undefined> {\n const items: { [name: string]: SchemaItemProps } = {};\n for (const itemProps of schemaItemProps) {\n const props = await this.parseItem(itemProps, schemaName, schemaInfos);\n items[props.name] = props;\n delete (props as any).name;\n }\n\n return Object.keys(items).length > 0 ? items : undefined;\n }\n\n public static async parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps> {\n const schemaItem = \"string\" === typeof (props) ? JSON.parse(props) : props;\n const type = parseSchemaItemType(schemaItem.schemaItemType);\n switch (type) {\n case SchemaItemType.KindOfQuantity:\n const koqParser = new KindOfQuantityParser(schemaName, schemaInfos);\n return await koqParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.EntityClass:\n case SchemaItemType.StructClass:\n const classParser = new ClassParser(schemaName, schemaInfos);\n return await classParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.RelationshipClass:\n const relationshipParser = new RelationshipClassParser(schemaName, schemaInfos);\n return await relationshipParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.Mixin:\n const mixinParser = new MixinParser(schemaName, schemaInfos);\n return await mixinParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.CustomAttributeClass:\n const caParser = new CustomAttributeClassParser(schemaName, schemaInfos);\n return await caParser.parse(schemaItem) as NamedSchemaItemProps;\n default:\n const itemParser = new SchemaItemParser(schemaName, schemaInfos);\n return await itemParser.parse(schemaItem) as NamedSchemaItemProps;\n }\n }\n}\n\n/**\n * Utility method to parse CustomAttribute data retrieved from a ECSql query.\n * @param customAttribute CustomAttribute data as retrieved from an iModel query.\n * @returns The CustomAttribute instance.\n * @internal\n */\nexport function parseCustomAttribute(customAttribute: { ecClass: string; ecSchema: string;[propName: string]: any; }): CustomAttribute {\n return {\n ...customAttribute[customAttribute.ecClass],\n className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,\n }\n}"]}
@@ -269,7 +269,7 @@ async function createNavigationProperty(ecClass, name, relationship, direction)
269
269
  }
270
270
  /** @internal */
271
271
  function createNavigationPropertySync(ecClass, name, relationship, direction) {
272
- if (ecClass.getPropertySync(name))
272
+ if (ecClass.getPropertySync(name, true))
273
273
  throw new Exception_1.ECSchemaError(Exception_1.ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
274
274
  let resolvedRelationship;
275
275
  if (typeof (relationship) === "string") {
@@ -1 +1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Y,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,wCAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,6BAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @public @preview\n */\nexport class EntityClass extends ECClass implements HasMixins {\n public override readonly schemaItemType = EntityClass.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\n private _mixins?: LazyLoadedMixin[];\n\n public get mixins(): ReadonlyArray<LazyLoadedMixin> {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return;\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n * @internal\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin);\n if (mObj && ECClass.isECClass(mObj)) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n /**\n *\n * @param cache\n * @returns\n *\n * @internal\n */\nprotected override async buildPropertyCache(): Promise<Map<string, Property>> {\n const cache = new Map<string, Property>();\n const baseClass = await this.baseClass;\n if (baseClass) {\n for (const property of await baseClass.getProperties()) {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n }\n }\n\n for (const mixin of this.mixins) {\n const mixinObj = await mixin;\n const mixinProps = mixinObj.getPropertiesSync();\n for (const property of mixinProps) {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n }\n }\n\n const localProps = await this.getProperties(true);\n if (localProps) {\n for (const property of localProps) {\n cache.set(property.name.toUpperCase(), property);\n }\n }\n return cache;\n}\n\n /**\n *\n * @param cache\n * @internal\n */\n protected override buildPropertyCacheSync(): Map<string, Property> {\n const cache = new Map<string, Property>();\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n Array.from(baseClass.getPropertiesSync()).forEach((property) => {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n });\n }\n\n for (const mixin of this.getMixinsSync()) {\n const mixinProps = mixin.getPropertiesSync();\n for (const property of mixinProps) {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n }\n }\n\n const localProps = this.getPropertiesSync(true);\n if (localProps) {\n Array.from(localProps).forEach(property => {\n cache.set(property.name.toUpperCase(), property);\n });\n }\n return cache;\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const lazyMixin of this.mixins) {\n const mixin = await lazyMixin;\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n\n if (!this._mixins.find((value) => mixinSchemaItemKey.matchesFullName(value.fullName))) {\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\n if (undefined === mixin)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n }\n\n /**\n * Type guard to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is an EntityClass, false otherwise.\n */\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\n * @internal\n */\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\n if (!this.isEntityClass(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name, true))\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name))\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}
1
+ {"version":3,"file":"EntityClass.js","sourceRoot":"","sources":["../../../src/Metadata/EntityClass.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAuRH,4DAsBC;AAGD,oEAsBC;AApUD,sDAA4D;AAE5D,oFAAiF;AACjF,4CAAyF;AACzF,4CAA6D;AAG7D,mCAAkC;AAClC,mCAAgC;AAChC,yCAAuE;AACvE,2DAAwD;AAGxD;;;GAGG;AACH,MAAa,WAAY,SAAQ,eAAO;IACb,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IACrE,gBAAgB;IACT,MAAM,KAAc,cAAc,KAAK,OAAO,0BAAc,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1E,OAAO,CAAqB;IAEpC,IAAW,MAAM;QACf,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,CAAC,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO;YACf,OAAO;QAET,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,aAAK,CAAC,CAAC;YACtD,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,IAAI,CAAC;YACb,CAAC;QACH,CAAC;IACH,CA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I,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,mCAAmC,YAAY,8CAA8C,CAAC,CAAC,CAAE,2DAA2D;IAElN,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,YAAY,GAAG,IAAA,kCAAsB,EAAC,SAAS,CAAC,CAAC;QACvD,IAAI,SAAS,KAAK,YAAY;YAC5B,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,wBAAwB,EAAE,mCAAmC,SAAS,qCAAqC,CAAC,CAAC;QACtJ,SAAS,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,gBAAgB,GAAG,IAAI,wCAAuB,CAAC,oBAAoB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACjH,OAAO,IAAI,6BAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { DelayedPromiseWithProps } from \"../DelayedPromise\";\nimport { EntityClassProps } from \"../Deserialization/JsonProps\";\nimport { XmlSerializationUtils } from \"../Deserialization/XmlSerializationUtils\";\nimport { parseStrengthDirection, SchemaItemType, StrengthDirection } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { HasMixins, LazyLoadedMixin } from \"../Interfaces\";\nimport { SchemaItemKey } from \"../SchemaKey\";\nimport { ECClass } from \"./Class\";\nimport { Mixin } from \"./Mixin\";\nimport { AnyProperty, NavigationProperty, Property } from \"./Property\";\nimport { RelationshipClass } from \"./RelationshipClass\";\nimport { SchemaItem } from \"./SchemaItem\";\n\n/**\n * A Typescript class representation of an ECEntityClass.\n * @public @preview\n */\nexport class EntityClass extends ECClass implements HasMixins {\n public override readonly schemaItemType = EntityClass.schemaItemType;\n /** @internal */\n public static override get schemaItemType() { return SchemaItemType.EntityClass; }\n private _mixins?: LazyLoadedMixin[];\n\n public get mixins(): ReadonlyArray<LazyLoadedMixin> {\n if (!this._mixins)\n return [];\n return this._mixins;\n }\n\n public *getMixinsSync(): Iterable<Mixin> {\n if (!this._mixins)\n return;\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin, Mixin);\n if (mObj) {\n yield mObj;\n }\n }\n }\n\n /**\n *\n * @param mixin\n * @internal\n */\n protected addMixin(mixin: Mixin) {\n if (!this._mixins)\n this._mixins = [];\n\n this._mixins.push(new DelayedPromiseWithProps(mixin.key, async () => mixin));\n return;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override async getInheritedProperty(name: string): Promise<AnyProperty | undefined> {\n let inheritedProperty = await super.getInheritedProperty(name);\n\n if (!inheritedProperty && this._mixins) {\n const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));\n mixinProps.some((prop) => {\n inheritedProperty = prop as AnyProperty;\n return inheritedProperty !== undefined;\n });\n }\n\n return inheritedProperty as AnyProperty | undefined;\n }\n\n /**\n * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.\n * @param name The name of the property to find.\n */\n public override getInheritedPropertySync(name: string): Property | undefined {\n const inheritedProperty = super.getInheritedPropertySync(name);\n if (inheritedProperty)\n return inheritedProperty;\n\n if (!this._mixins) {\n return undefined;\n }\n\n for (const mixin of this._mixins) {\n const mObj = this.schema.lookupItemSync(mixin);\n if (mObj && ECClass.isECClass(mObj)) {\n const result = mObj.getPropertySync(name, true);\n if (result) {\n return result;\n }\n }\n }\n\n return undefined;\n }\n\n /**\n *\n * @param cache\n * @returns\n *\n * @internal\n */\nprotected override async buildPropertyCache(): Promise<Map<string, Property>> {\n const cache = new Map<string, Property>();\n const baseClass = await this.baseClass;\n if (baseClass) {\n for (const property of await baseClass.getProperties()) {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n }\n }\n\n for (const mixin of this.mixins) {\n const mixinObj = await mixin;\n const mixinProps = mixinObj.getPropertiesSync();\n for (const property of mixinProps) {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n }\n }\n\n const localProps = await this.getProperties(true);\n if (localProps) {\n for (const property of localProps) {\n cache.set(property.name.toUpperCase(), property);\n }\n }\n return cache;\n}\n\n /**\n *\n * @param cache\n * @internal\n */\n protected override buildPropertyCacheSync(): Map<string, Property> {\n const cache = new Map<string, Property>();\n const baseClass = this.getBaseClassSync();\n if (baseClass) {\n Array.from(baseClass.getPropertiesSync()).forEach((property) => {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n });\n }\n\n for (const mixin of this.getMixinsSync()) {\n const mixinProps = mixin.getPropertiesSync();\n for (const property of mixinProps) {\n if (!cache.has(property.name.toUpperCase()))\n cache.set(property.name.toUpperCase(), property);\n }\n }\n\n const localProps = this.getPropertiesSync(true);\n if (localProps) {\n Array.from(localProps).forEach(property => {\n cache.set(property.name.toUpperCase(), property);\n });\n }\n return cache;\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected async createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n return this.addProperty(await createNavigationProperty(this, name, relationship, direction));\n }\n\n /**\n *\n * @param name\n * @param relationship\n * @param direction\n * @internal\n */\n protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));\n }\n\n /**\n * Save this EntityClass' properties to an object for serializing to JSON.\n * @param standalone Serialization includes only this object (as opposed to the full schema).\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\n */\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): EntityClassProps {\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\n if (this.mixins.length > 0)\n schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);\n return schemaJson;\n }\n\n /** @internal */\n public override async toXml(schemaXml: Document): Promise<Element> {\n const itemElement = await super.toXml(schemaXml);\n\n for (const lazyMixin of this.mixins) {\n const mixin = await lazyMixin;\n const mixinElement = schemaXml.createElement(\"BaseClass\");\n const mixinName = XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);\n mixinElement.textContent = mixinName;\n itemElement.appendChild(mixinElement);\n }\n return itemElement;\n }\n\n public override async fromJSON(entityClassProps: EntityClassProps) {\n this.fromJSONSync(entityClassProps);\n }\n\n public override fromJSONSync(entityClassProps: EntityClassProps) {\n super.fromJSONSync(entityClassProps);\n\n if (undefined !== entityClassProps.mixins) {\n if (!this._mixins)\n this._mixins = [];\n for (const name of entityClassProps.mixins) {\n const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);\n if (!mixinSchemaItemKey)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n\n if (!this._mixins.find((value) => mixinSchemaItemKey.matchesFullName(value.fullName))) {\n this._mixins.push(new DelayedPromiseWithProps<SchemaItemKey, Mixin>(mixinSchemaItemKey,\n async () => {\n const mixin = await this.schema.lookupItem(mixinSchemaItemKey, Mixin);\n if (undefined === mixin)\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin (\"${name}\") that cannot be found.`);\n return mixin;\n }));\n }\n }\n }\n }\n\n /**\n * Type guard to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns True if the item is an EntityClass, false otherwise.\n */\n public static isEntityClass(item?: SchemaItem): item is EntityClass {\n if (item && item.schemaItemType === SchemaItemType.EntityClass)\n return true;\n\n return false;\n }\n\n /**\n * Type assertion to check if the SchemaItem is of type EntityClass.\n * @param item The SchemaItem to check.\n * @returns The item cast to EntityClass if it is an EntityClass, undefined otherwise.\n * @internal\n */\n public static assertIsEntityClass(item?: SchemaItem): asserts item is EntityClass {\n if (!this.isEntityClass(item))\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaItemType, `Expected '${SchemaItemType.EntityClass}' (EntityClass)`);\n }\n}\n\n/**\n * Hackish approach that works like a \"friend class\" so we can access protected members without making them public.\n * @internal\n */\nexport abstract class MutableEntityClass extends EntityClass {\n public abstract override addMixin(mixin: Mixin): any;\n public abstract override createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;\n public abstract override createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;\n public abstract override setDisplayLabel(displayLabel: string): void;\n}\n\n/** @internal */\nexport async function createNavigationProperty(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty> {\n if (await ecClass.getProperty(name, true))\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = await ecClass.schema.lookupItem(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n\n/** @internal */\nexport function createNavigationPropertySync(ecClass: ECClass, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty {\n if (ecClass.getPropertySync(name, true))\n throw new ECSchemaError(ECSchemaStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);\n\n let resolvedRelationship: RelationshipClass | undefined;\n if (typeof (relationship) === \"string\") {\n resolvedRelationship = ecClass.schema.lookupItemSync(relationship, RelationshipClass);\n } else\n resolvedRelationship = relationship;\n\n if (!resolvedRelationship)\n throw new ECSchemaError(ECSchemaStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`); // eslint-disable-line @typescript-eslint/no-base-to-string\n\n if (typeof (direction) === \"string\") {\n const tmpDirection = parseStrengthDirection(direction);\n if (undefined === tmpDirection)\n throw new ECSchemaError(ECSchemaStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);\n direction = tmpDirection;\n }\n\n const lazyRelationship = new DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);\n return new NavigationProperty(ecClass, name, lazyRelationship, direction);\n}\n"]}