@itwin/ecschema-metadata 5.9.0-dev.9 → 5.9.1

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 (148) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/lib/cjs/Deserialization/Helper.d.ts +1 -1
  3. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  4. package/lib/cjs/Deserialization/Helper.js +35 -21
  5. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  6. package/lib/cjs/Deserialization/JsonParser.js +7 -7
  7. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  8. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  9. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  10. package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
  11. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  12. package/lib/cjs/ECObjects.js.map +1 -1
  13. package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts +3 -2
  14. package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts.map +1 -1
  15. package/lib/cjs/Formatting/FormatSetFormatsProvider.js +7 -6
  16. package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -1
  17. package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts +1 -1
  18. package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts.map +1 -1
  19. package/lib/cjs/Formatting/SchemaFormatsProvider.js +6 -5
  20. package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -1
  21. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
  22. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +1 -1
  23. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
  24. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  25. package/lib/cjs/Metadata/Class.js +6 -4
  26. package/lib/cjs/Metadata/Class.js.map +1 -1
  27. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  28. package/lib/cjs/Metadata/EntityClass.js +2 -2
  29. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  30. package/lib/cjs/Metadata/InvertedUnit.js +2 -2
  31. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  32. package/lib/cjs/Metadata/KindOfQuantity.js +1 -1
  33. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  34. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  35. package/lib/cjs/Metadata/Property.js +6 -3
  36. package/lib/cjs/Metadata/Property.js.map +1 -1
  37. package/lib/cjs/Metadata/RelationshipClass.d.ts.map +1 -1
  38. package/lib/cjs/Metadata/RelationshipClass.js +5 -4
  39. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  40. package/lib/cjs/Metadata/Schema.js +1 -1
  41. package/lib/cjs/Metadata/Schema.js.map +1 -1
  42. package/lib/cjs/Metadata/SchemaItem.js +2 -2
  43. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  44. package/lib/cjs/Metadata/Unit.js +2 -2
  45. package/lib/cjs/Metadata/Unit.js.map +1 -1
  46. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  47. package/lib/cjs/UnitConversion/UnitConverter.d.ts +1 -1
  48. package/lib/cjs/UnitConversion/UnitConverter.d.ts.map +1 -1
  49. package/lib/cjs/UnitConversion/UnitConverter.js +4 -4
  50. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  51. package/lib/cjs/UnitConversion/UnitTree.d.ts +3 -4
  52. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  53. package/lib/cjs/UnitConversion/UnitTree.js +11 -11
  54. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  55. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +3 -0
  56. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  57. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +3 -0
  58. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  59. package/lib/cjs/ecschema-metadata.d.ts +0 -1
  60. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  61. package/lib/cjs/ecschema-metadata.js +0 -1
  62. package/lib/cjs/ecschema-metadata.js.map +1 -1
  63. package/lib/esm/Deserialization/Helper.d.ts +1 -1
  64. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  65. package/lib/esm/Deserialization/Helper.js +35 -21
  66. package/lib/esm/Deserialization/Helper.js.map +1 -1
  67. package/lib/esm/Deserialization/JsonParser.js +7 -7
  68. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  69. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  70. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -1
  71. package/lib/esm/Deserialization/XmlSerializationUtils.js +1 -1
  72. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  73. package/lib/esm/ECObjects.js.map +1 -1
  74. package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts +3 -2
  75. package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts.map +1 -1
  76. package/lib/esm/Formatting/FormatSetFormatsProvider.js +7 -6
  77. package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -1
  78. package/lib/esm/Formatting/SchemaFormatsProvider.d.ts +1 -1
  79. package/lib/esm/Formatting/SchemaFormatsProvider.d.ts.map +1 -1
  80. package/lib/esm/Formatting/SchemaFormatsProvider.js +6 -5
  81. package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -1
  82. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
  83. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +1 -1
  84. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
  85. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  86. package/lib/esm/Metadata/Class.js +6 -4
  87. package/lib/esm/Metadata/Class.js.map +1 -1
  88. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  89. package/lib/esm/Metadata/EntityClass.js +2 -2
  90. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  91. package/lib/esm/Metadata/InvertedUnit.js +2 -2
  92. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  93. package/lib/esm/Metadata/KindOfQuantity.js +1 -1
  94. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  95. package/lib/esm/Metadata/Property.d.ts.map +1 -1
  96. package/lib/esm/Metadata/Property.js +6 -3
  97. package/lib/esm/Metadata/Property.js.map +1 -1
  98. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -1
  99. package/lib/esm/Metadata/RelationshipClass.js +5 -4
  100. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  101. package/lib/esm/Metadata/Schema.js +1 -1
  102. package/lib/esm/Metadata/Schema.js.map +1 -1
  103. package/lib/esm/Metadata/SchemaItem.js +2 -2
  104. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  105. package/lib/esm/Metadata/Unit.js +2 -2
  106. package/lib/esm/Metadata/Unit.js.map +1 -1
  107. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  108. package/lib/esm/UnitConversion/UnitConverter.d.ts +1 -1
  109. package/lib/esm/UnitConversion/UnitConverter.d.ts.map +1 -1
  110. package/lib/esm/UnitConversion/UnitConverter.js +1 -1
  111. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  112. package/lib/esm/UnitConversion/UnitTree.d.ts +3 -4
  113. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -1
  114. package/lib/esm/UnitConversion/UnitTree.js +6 -6
  115. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  116. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts +3 -0
  117. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -1
  118. package/lib/esm/UnitProvider/SchemaUnitProvider.js +3 -0
  119. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  120. package/lib/esm/ecschema-metadata.d.ts +0 -1
  121. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  122. package/lib/esm/ecschema-metadata.js +0 -1
  123. package/lib/esm/ecschema-metadata.js.map +1 -1
  124. package/package.json +7 -7
  125. package/lib/cjs/UnitConversion/Graph.d.ts +0 -35
  126. package/lib/cjs/UnitConversion/Graph.d.ts.map +0 -1
  127. package/lib/cjs/UnitConversion/Graph.js +0 -88
  128. package/lib/cjs/UnitConversion/Graph.js.map +0 -1
  129. package/lib/cjs/UnitConversion/Parser.d.ts +0 -9
  130. package/lib/cjs/UnitConversion/Parser.d.ts.map +0 -1
  131. package/lib/cjs/UnitConversion/Parser.js +0 -42
  132. package/lib/cjs/UnitConversion/Parser.js.map +0 -1
  133. package/lib/cjs/UnitConversion/UnitConversion.d.ts +0 -46
  134. package/lib/cjs/UnitConversion/UnitConversion.d.ts.map +0 -1
  135. package/lib/cjs/UnitConversion/UnitConversion.js +0 -76
  136. package/lib/cjs/UnitConversion/UnitConversion.js.map +0 -1
  137. package/lib/esm/UnitConversion/Graph.d.ts +0 -35
  138. package/lib/esm/UnitConversion/Graph.d.ts.map +0 -1
  139. package/lib/esm/UnitConversion/Graph.js +0 -84
  140. package/lib/esm/UnitConversion/Graph.js.map +0 -1
  141. package/lib/esm/UnitConversion/Parser.d.ts +0 -9
  142. package/lib/esm/UnitConversion/Parser.d.ts.map +0 -1
  143. package/lib/esm/UnitConversion/Parser.js +0 -39
  144. package/lib/esm/UnitConversion/Parser.js.map +0 -1
  145. package/lib/esm/UnitConversion/UnitConversion.d.ts +0 -46
  146. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +0 -1
  147. package/lib/esm/UnitConversion/UnitConversion.js +0 -72
  148. package/lib/esm/UnitConversion/UnitConversion.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaUnitProvider.js","sourceRoot":"","sources":["../../../src/UnitProvider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BAChE,IAAI,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBACpG,mDAAmD;oBACnD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxD,6EAA6E;oBAC7E,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU;wBAC3C,OAAO,SAAS,CAAC;oBAEnB,+CAA+C;oBAC/C,MAAM,iBAAiB,GAAG,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;oBAC7F,MAAM,iBAAiB,GAAG,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC;oBAC3F,MAAM,iBAAiB,GAAG,CAAC,UAAU,IAAI,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC;oBACvF,iDAAiD;oBACjD,IAAI,iBAAiB,IAAI,iBAAiB,IAAI,iBAAiB;wBAC7D,OAAO,SAAS,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,uBAAO,EAAE,CAAC;IACvB,CAAC;CACF;AAxRD,gDAwRC","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 { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\nimport { BadUnit, UnitConversionInvert, UnitConversionProps, UnitExtraData, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\nimport { Unit } from \"../Metadata/Unit\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { UnitConverter } from \"../UnitConversion/UnitConverter\";\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\n\n/**\n * Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.\n * @beta\n */\nexport class SchemaUnitProvider implements UnitsProvider {\n private _unitConverter: UnitConverter;\n private _context: SchemaContext;\n\n /**\n *\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\n * created and the locater will be added.\n * @param _unitExtraData Additional data like alternate display label not found in Units Schema to match with Units; Defaults to empty array.\n */\n constructor(contextOrLocater: ISchemaLocater, private _unitExtraData: UnitExtraData[] = []) {\n if (contextOrLocater instanceof SchemaContext) {\n this._context = contextOrLocater;\n } else {\n this._context = new SchemaContext();\n this._context.addLocater(contextOrLocater);\n }\n this._unitConverter = new UnitConverter(this._context);\n }\n\n /**\n * Find unit in a schema that has unitName.\n * @param unitName Full name of unit.\n * @returns UnitProps interface from @itwin/core-quantity whose name matches unitName.\n */\n public async findUnitByName(unitName: string): Promise<UnitProps> {\n // Check if schema exists and unit exists in schema\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(unitName);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await this._context.getSchema(schemaKey);\n\n if (!schema) {\n return new BadUnit(); // return BadUnit if schema does not exist\n }\n\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n const unit = await this._context.getSchemaItem(itemKey, Unit);\n if (unit && unit.schemaItemType === SchemaItemType.Unit)\n return this.getUnitsProps(unit);\n\n const invertedUnit = await this._context.getSchemaItem(itemKey, InvertedUnit);\n if (invertedUnit && invertedUnit.schemaItemType === SchemaItemType.InvertedUnit) {\n return this.getUnitsProps(invertedUnit);\n }\n\n return new BadUnit();\n }\n\n /**\n * Find all units in context that belongs to given phenomenon.\n * @param phenomenon Full name of phenomenon.\n * @returns Array of UnitProps (from @itwin/core-quantity) interface objects whose name matches phenomenon param.\n */\n public async getUnitsByFamily(phenomenon: string): Promise<Array<UnitProps>> {\n // Check if schema exists and phenomenon exists in schema\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(phenomenon);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await this._context.getSchema(schemaKey);\n\n if (!schema) {\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema for phenomenon\", () => {\n return { phenomenon, schema: schemaName };\n });\n }\n\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n const phenom = await this._context.getSchemaItem(itemKey);\n if (!phenom)\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema item/phenomenon\", () => {\n return { item: schemaItemName, schema: schemaName };\n });\n\n if (phenom.schemaItemType !== SchemaItemType.Phenomenon)\n throw new BentleyError(BentleyStatus.ERROR, \"Item is not a phenomenon\", () => {\n return { itemType: phenom.key.fullName };\n });\n\n // Find units' full name that match given phenomenon param.\n const filteredUnits: Array<UnitProps> = [];\n const schemaItems = this._context.getSchemaItems();\n for (const value of schemaItems) {\n if (Unit.isUnit(value)) {\n const foundPhenomenon = await value.phenomenon;\n if (foundPhenomenon && foundPhenomenon.key.matchesFullName(phenomenon)) {\n const unitProps = await this.getUnitsProps(value);\n filteredUnits.push(unitProps);\n }\n } else if (InvertedUnit.isInvertedUnit(value) && value.invertsUnit) {\n const invertsUnit = await value.invertsUnit;\n if (invertsUnit) {\n const foundPhenomenon = await invertsUnit.phenomenon;\n if (foundPhenomenon && foundPhenomenon.key.matchesFullName(phenomenon)) {\n const unitProps = await this.getUnitsProps(value);\n filteredUnits.push(unitProps);\n }\n }\n }\n }\n\n return filteredUnits;\n }\n\n /**\n * Find alternate display labels associated with unitName, if any.\n * @param unitName Full name of Unit.\n */\n public getAlternateDisplayLabels(unitName: string): Array<string> {\n let alternateLabels: Array<string> = [];\n for (const entry of this._unitExtraData) {\n if (entry.name.toLowerCase() === unitName.toLowerCase()) {\n alternateLabels = entry.altDisplayLabels;\n }\n }\n\n return alternateLabels;\n }\n\n /**\n * Finds Unit by unitLabel, which could be a display label in the schema or alternate an display label defined in\n * this._unitExtraData. If there are duplicates of the same display label in the context or teh same alternate display\n * labels, specify schemaName, phenomenon, or unitSystem to get a specific unit.\n *\n * @param unitLabel Display label or alternate display label to query unit by.\n * @param schemaName Ensure Unit with unitLabel belongs to Schema with schemaName.\n * @param phenomenon Full name of phenomenon that Unit belongs to.\n * @param unitSystem Full name of unitSystem that Unit belongs to.\n * @returns The UnitProps interface from the @itwin/core-quantity package.\n */\n public async findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n const findLabel = unitLabel.toLowerCase();\n const findSchema = schemaName ? schemaName.toLowerCase() : undefined;\n const findPhenomenon = phenomenon ? phenomenon.toLowerCase() : undefined;\n const findUnitSystem = unitSystem ? unitSystem.toLowerCase() : undefined;\n\n const foundUnit: UnitProps = await this.findUnitByDisplayLabel(findLabel, findSchema, findPhenomenon, findUnitSystem);\n if (foundUnit.isValid)\n return foundUnit;\n\n // If there is no Unit with display label that matches label, then check for alternate display labels that may match\n return this.findUnitByAltDisplayLabel(findLabel, findSchema, findPhenomenon, findUnitSystem);\n }\n\n /**\n * Gets the @itwin/core-quantity UnitConversionProps for the given fromUnit and toUnit.\n * @param fromUnit The UnitProps of the 'from' unit.\n * @param toUnit The UnitProps of the 'to' unit.\n * @returns The UnitConversionProps interface from the @itwin/core-quantity package.\n */\n public async getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversionProps> {\n // need to check if either side is an inverted unit. The UnitConverter can only handle Units\n if (!fromUnit.isValid || !toUnit.isValid)\n throw new BentleyError(BentleyStatus.ERROR, \"Both provided units must be valid.\", () => {\n return { fromUnit, toUnit };\n });\n\n const { unitName: fromUnitName, isInverted: fromIsInverted } = await this.checkUnitPropsForConversion(fromUnit, this._context);\n const { unitName: toUnitName, isInverted: toIsInverted } = await this.checkUnitPropsForConversion(toUnit, this._context);\n\n const conversion = await this._unitConverter.calculateConversion(fromUnitName, toUnitName);\n const result: UnitConversionProps = {\n factor: conversion.factor,\n offset: conversion.offset,\n };\n if (fromIsInverted && !toIsInverted)\n result.inversion = UnitConversionInvert.InvertPreConversion;\n else if (!fromIsInverted && toIsInverted)\n result.inversion = UnitConversionInvert.InvertPostConversion;\n\n return result;\n }\n\n private async checkUnitPropsForConversion(input: UnitProps, context: SchemaContext): Promise<{ unitName: string, isInverted: boolean }> {\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(input.name);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await context.getSchema(schemaKey);\n\n if (!schema) {\n throw new BentleyError(BentleyStatus.ERROR, \"Could not obtain schema for unit.\", () => {\n return { name: input.name };\n });\n }\n\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n const invertedUnit = await context.getSchemaItem(itemKey, InvertedUnit);\n // Check if we found an item, the item is an inverted unit, and it has its invertsUnit property set\n if (invertedUnit && InvertedUnit.isInvertedUnit(invertedUnit) && invertedUnit.invertsUnit) {\n return { unitName: invertedUnit.invertsUnit.fullName, isInverted: true };\n }\n\n return { unitName: input.name, isInverted: false };\n }\n\n /**\n * Gets the @itwin/core UnitProps for the given Unit.\n * @param unit The Unit to convert.\n * @returns UnitProps interface from @itwin/core.\n */\n private async getUnitsProps(unit: Unit | InvertedUnit): Promise<UnitProps> {\n if (Unit.isUnit(unit)) {\n return {\n name: unit.fullName,\n label: unit.label ?? \"\",\n phenomenon: unit.phenomenon ? unit.phenomenon.fullName : \"\",\n isValid: true,\n system: unit.unitSystem === undefined ? \"\" : unit.unitSystem.fullName,\n };\n }\n\n const invertsUnit = await unit.invertsUnit;\n if (!invertsUnit)\n return new BadUnit();\n\n return {\n name: unit.fullName,\n label: unit.label ?? \"\",\n phenomenon: invertsUnit.phenomenon ? invertsUnit.phenomenon.fullName : \"\",\n isValid: true,\n system: unit.unitSystem === undefined ? \"\" : unit.unitSystem.fullName,\n };\n }\n\n /**\n * Finds Unit by displayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.\n * @internal\n */\n private async findUnitByDisplayLabel(displayLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n // TODO: Known bug: This only looks through loaded schemas. If schema name is provided, we can attempt to load that schema\n const schemaItems = this._context.getSchemaItems();\n for (const value of schemaItems) {\n if (Unit.isUnit(value) && value.label?.toLowerCase() === displayLabel) {\n // TODO: this can be optimized. We don't have to await these if we don't want to check for them\n const currPhenomenon = await value.phenomenon;\n const currUnitSystem = await value.unitSystem;\n if (!schemaName || value.schema.name.toLowerCase() === schemaName)\n if (!phenomenon || (currPhenomenon && currPhenomenon.key.matchesFullName(phenomenon)))\n if (!unitSystem || (currUnitSystem && currUnitSystem.key.matchesFullName(unitSystem)))\n return this.getUnitsProps(value);\n } else if (InvertedUnit.isInvertedUnit(value) && value.label?.toLowerCase() === displayLabel && value.invertsUnit) {\n const invertsUnit = await value.invertsUnit;\n if (invertsUnit) {\n const currPhenomenon = await invertsUnit.phenomenon;\n const currUnitSystem = await invertsUnit.unitSystem;\n if (!schemaName || value.schema.name.toLowerCase() === schemaName)\n if (!phenomenon || (currPhenomenon && currPhenomenon.key.matchesFullName(phenomenon)))\n if (!unitSystem || (currUnitSystem && currUnitSystem.key.matchesFullName(unitSystem)))\n return this.getUnitsProps(value);\n }\n }\n }\n\n return new BadUnit();\n }\n\n /**\n * Finds Unit by altDisplayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.\n * @internal\n */\n private async findUnitByAltDisplayLabel(altDisplayLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n for (const entry of this._unitExtraData) {\n if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {\n if (entry.altDisplayLabels.findIndex((ref: string) => ref.toLowerCase() === altDisplayLabel) !== -1) {\n // Found altDisplayLabel that matches label to find\n const unitProps = await this.findUnitByName(entry.name);\n // If no schemaName, phenomenon, or unitSystem are provided, return unitProps\n if (!schemaName && !phenomenon && !unitSystem)\n return unitProps;\n\n // Check if the provided values match unitProps\n const schemaNameMatches = !schemaName || unitProps.name.toLowerCase().startsWith(schemaName);\n const phenomenonMatches = !phenomenon || unitProps.phenomenon.toLowerCase() === phenomenon;\n const unitSystemMatches = !unitSystem || unitProps.system.toLowerCase() === unitSystem;\n // If all provided values match, return unitProps\n if (schemaNameMatches && phenomenonMatches && unitSystemMatches)\n return unitProps;\n }\n }\n }\n return new BadUnit();\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaUnitProvider.js","sourceRoot":"","sources":["../../../src/UnitProvider/SchemaUnitProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAAkE;AAClE,wDAAmI;AACnI,wCAA2D;AAC3D,uDAAoD;AACpD,4CAAwD;AACxD,2CAAwC;AACxC,4CAA8C;AAC9C,mEAAgE;AAChE,2DAAwD;AAExD;;;;;;GAMG;AACH,MAAa,kBAAkB;IAWyB;IAV9C,cAAc,CAAgB;IAC9B,QAAQ,CAAgB;IAEhC;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAU,iBAAkC,EAAE;QAApC,mBAAc,GAAd,cAAc,CAAsB;QACxF,IAAI,gBAAgB,YAAY,uBAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,QAAgB;QAC1C,mDAAmD;QACnD,MAAM,CAAC,UAA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;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,uBAAO,EAAE,CAAC;IACvB,CAAC;CACF;AAxRD,gDAwRC","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 { BentleyError, BentleyStatus } from \"@itwin/core-bentley\";\nimport { BadUnit, UnitConversionInvert, UnitConversionProps, UnitExtraData, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { SchemaItemKey, SchemaKey } from \"../SchemaKey\";\nimport { Unit } from \"../Metadata/Unit\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { UnitConverter } from \"../UnitConversion/UnitConverter\";\nimport { InvertedUnit } from \"../Metadata/InvertedUnit\";\n\n/**\n * Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.\n *\n * To layer schema-defined units on top of the bundled BIS units from `@itwin/core-quantity`,\n * pass this as `primary` to `createUnitsProvider` from `@itwin/core-quantity`.\n * @beta\n */\nexport class SchemaUnitProvider implements UnitsProvider {\n private _unitConverter: UnitConverter;\n private _context: SchemaContext;\n\n /**\n *\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\n * created and the locater will be added.\n * @param _unitExtraData Additional data like alternate display label not found in Units Schema to match with Units; Defaults to empty array.\n */\n constructor(contextOrLocater: ISchemaLocater, private _unitExtraData: UnitExtraData[] = []) {\n if (contextOrLocater instanceof SchemaContext) {\n this._context = contextOrLocater;\n } else {\n this._context = new SchemaContext();\n this._context.addLocater(contextOrLocater);\n }\n this._unitConverter = new UnitConverter(this._context);\n }\n\n /**\n * Find unit in a schema that has unitName.\n * @param unitName Full name of unit.\n * @returns UnitProps interface from @itwin/core-quantity whose name matches unitName.\n */\n public async findUnitByName(unitName: string): Promise<UnitProps> {\n // Check if schema exists and unit exists in schema\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(unitName);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await this._context.getSchema(schemaKey);\n\n if (!schema) {\n return new BadUnit(); // return BadUnit if schema does not exist\n }\n\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n const unit = await this._context.getSchemaItem(itemKey, Unit);\n if (unit && unit.schemaItemType === SchemaItemType.Unit)\n return this.getUnitsProps(unit);\n\n const invertedUnit = await this._context.getSchemaItem(itemKey, InvertedUnit);\n if (invertedUnit && invertedUnit.schemaItemType === SchemaItemType.InvertedUnit) {\n return this.getUnitsProps(invertedUnit);\n }\n\n return new BadUnit();\n }\n\n /**\n * Find all units in context that belongs to given phenomenon.\n * @param phenomenon Full name of phenomenon.\n * @returns Array of UnitProps (from @itwin/core-quantity) interface objects whose name matches phenomenon param.\n */\n public async getUnitsByFamily(phenomenon: string): Promise<Array<UnitProps>> {\n // Check if schema exists and phenomenon exists in schema\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(phenomenon);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await this._context.getSchema(schemaKey);\n\n if (!schema) {\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema for phenomenon\", () => {\n return { phenomenon, schema: schemaName };\n });\n }\n\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n const phenom = await this._context.getSchemaItem(itemKey);\n if (!phenom)\n throw new BentleyError(BentleyStatus.ERROR, \"Cannot find schema item/phenomenon\", () => {\n return { item: schemaItemName, schema: schemaName };\n });\n\n if (phenom.schemaItemType !== SchemaItemType.Phenomenon)\n throw new BentleyError(BentleyStatus.ERROR, \"Item is not a phenomenon\", () => {\n return { itemType: phenom.key.fullName };\n });\n\n // Find units' full name that match given phenomenon param.\n const filteredUnits: Array<UnitProps> = [];\n const schemaItems = this._context.getSchemaItems();\n for (const value of schemaItems) {\n if (Unit.isUnit(value)) {\n const foundPhenomenon = await value.phenomenon;\n if (foundPhenomenon && foundPhenomenon.key.matchesFullName(phenomenon)) {\n const unitProps = await this.getUnitsProps(value);\n filteredUnits.push(unitProps);\n }\n } else if (InvertedUnit.isInvertedUnit(value) && value.invertsUnit) {\n const invertsUnit = await value.invertsUnit;\n if (invertsUnit) {\n const foundPhenomenon = await invertsUnit.phenomenon;\n if (foundPhenomenon && foundPhenomenon.key.matchesFullName(phenomenon)) {\n const unitProps = await this.getUnitsProps(value);\n filteredUnits.push(unitProps);\n }\n }\n }\n }\n\n return filteredUnits;\n }\n\n /**\n * Find alternate display labels associated with unitName, if any.\n * @param unitName Full name of Unit.\n */\n public getAlternateDisplayLabels(unitName: string): Array<string> {\n let alternateLabels: Array<string> = [];\n for (const entry of this._unitExtraData) {\n if (entry.name.toLowerCase() === unitName.toLowerCase()) {\n alternateLabels = entry.altDisplayLabels;\n }\n }\n\n return alternateLabels;\n }\n\n /**\n * Finds Unit by unitLabel, which could be a display label in the schema or alternate an display label defined in\n * this._unitExtraData. If there are duplicates of the same display label in the context or teh same alternate display\n * labels, specify schemaName, phenomenon, or unitSystem to get a specific unit.\n *\n * @param unitLabel Display label or alternate display label to query unit by.\n * @param schemaName Ensure Unit with unitLabel belongs to Schema with schemaName.\n * @param phenomenon Full name of phenomenon that Unit belongs to.\n * @param unitSystem Full name of unitSystem that Unit belongs to.\n * @returns The UnitProps interface from the @itwin/core-quantity package.\n */\n public async findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n const findLabel = unitLabel.toLowerCase();\n const findSchema = schemaName ? schemaName.toLowerCase() : undefined;\n const findPhenomenon = phenomenon ? phenomenon.toLowerCase() : undefined;\n const findUnitSystem = unitSystem ? unitSystem.toLowerCase() : undefined;\n\n const foundUnit: UnitProps = await this.findUnitByDisplayLabel(findLabel, findSchema, findPhenomenon, findUnitSystem);\n if (foundUnit.isValid)\n return foundUnit;\n\n // If there is no Unit with display label that matches label, then check for alternate display labels that may match\n return this.findUnitByAltDisplayLabel(findLabel, findSchema, findPhenomenon, findUnitSystem);\n }\n\n /**\n * Gets the @itwin/core-quantity UnitConversionProps for the given fromUnit and toUnit.\n * @param fromUnit The UnitProps of the 'from' unit.\n * @param toUnit The UnitProps of the 'to' unit.\n * @returns The UnitConversionProps interface from the @itwin/core-quantity package.\n */\n public async getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversionProps> {\n // need to check if either side is an inverted unit. The UnitConverter can only handle Units\n if (!fromUnit.isValid || !toUnit.isValid)\n throw new BentleyError(BentleyStatus.ERROR, \"Both provided units must be valid.\", () => {\n return { fromUnit, toUnit };\n });\n\n const { unitName: fromUnitName, isInverted: fromIsInverted } = await this.checkUnitPropsForConversion(fromUnit, this._context);\n const { unitName: toUnitName, isInverted: toIsInverted } = await this.checkUnitPropsForConversion(toUnit, this._context);\n\n const conversion = await this._unitConverter.calculateConversion(fromUnitName, toUnitName);\n const result: UnitConversionProps = {\n factor: conversion.factor,\n offset: conversion.offset,\n };\n if (fromIsInverted && !toIsInverted)\n result.inversion = UnitConversionInvert.InvertPreConversion;\n else if (!fromIsInverted && toIsInverted)\n result.inversion = UnitConversionInvert.InvertPostConversion;\n\n return result;\n }\n\n private async checkUnitPropsForConversion(input: UnitProps, context: SchemaContext): Promise<{ unitName: string, isInverted: boolean }> {\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(input.name);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await context.getSchema(schemaKey);\n\n if (!schema) {\n throw new BentleyError(BentleyStatus.ERROR, \"Could not obtain schema for unit.\", () => {\n return { name: input.name };\n });\n }\n\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n const invertedUnit = await context.getSchemaItem(itemKey, InvertedUnit);\n // Check if we found an item, the item is an inverted unit, and it has its invertsUnit property set\n if (invertedUnit && InvertedUnit.isInvertedUnit(invertedUnit) && invertedUnit.invertsUnit) {\n return { unitName: invertedUnit.invertsUnit.fullName, isInverted: true };\n }\n\n return { unitName: input.name, isInverted: false };\n }\n\n /**\n * Gets the @itwin/core UnitProps for the given Unit.\n * @param unit The Unit to convert.\n * @returns UnitProps interface from @itwin/core.\n */\n private async getUnitsProps(unit: Unit | InvertedUnit): Promise<UnitProps> {\n if (Unit.isUnit(unit)) {\n return {\n name: unit.fullName,\n label: unit.label ?? \"\",\n phenomenon: unit.phenomenon ? unit.phenomenon.fullName : \"\",\n isValid: true,\n system: unit.unitSystem === undefined ? \"\" : unit.unitSystem.fullName,\n };\n }\n\n const invertsUnit = await unit.invertsUnit;\n if (!invertsUnit)\n return new BadUnit();\n\n return {\n name: unit.fullName,\n label: unit.label ?? \"\",\n phenomenon: invertsUnit.phenomenon ? invertsUnit.phenomenon.fullName : \"\",\n isValid: true,\n system: unit.unitSystem === undefined ? \"\" : unit.unitSystem.fullName,\n };\n }\n\n /**\n * Finds Unit by displayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.\n * @internal\n */\n private async findUnitByDisplayLabel(displayLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n // TODO: Known bug: This only looks through loaded schemas. If schema name is provided, we can attempt to load that schema\n const schemaItems = this._context.getSchemaItems();\n for (const value of schemaItems) {\n if (Unit.isUnit(value) && value.label?.toLowerCase() === displayLabel) {\n // TODO: this can be optimized. We don't have to await these if we don't want to check for them\n const currPhenomenon = await value.phenomenon;\n const currUnitSystem = await value.unitSystem;\n if (!schemaName || value.schema.name.toLowerCase() === schemaName)\n if (!phenomenon || (currPhenomenon && currPhenomenon.key.matchesFullName(phenomenon)))\n if (!unitSystem || (currUnitSystem && currUnitSystem.key.matchesFullName(unitSystem)))\n return this.getUnitsProps(value);\n } else if (InvertedUnit.isInvertedUnit(value) && value.label?.toLowerCase() === displayLabel && value.invertsUnit) {\n const invertsUnit = await value.invertsUnit;\n if (invertsUnit) {\n const currPhenomenon = await invertsUnit.phenomenon;\n const currUnitSystem = await invertsUnit.unitSystem;\n if (!schemaName || value.schema.name.toLowerCase() === schemaName)\n if (!phenomenon || (currPhenomenon && currPhenomenon.key.matchesFullName(phenomenon)))\n if (!unitSystem || (currUnitSystem && currUnitSystem.key.matchesFullName(unitSystem)))\n return this.getUnitsProps(value);\n }\n }\n }\n\n return new BadUnit();\n }\n\n /**\n * Finds Unit by altDisplayLabel and that it belongs to schemaName, phenomenon, and unitSystem if defined.\n * @internal\n */\n private async findUnitByAltDisplayLabel(altDisplayLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n for (const entry of this._unitExtraData) {\n if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {\n if (entry.altDisplayLabels.findIndex((ref: string) => ref.toLowerCase() === altDisplayLabel) !== -1) {\n // Found altDisplayLabel that matches label to find\n const unitProps = await this.findUnitByName(entry.name);\n // If no schemaName, phenomenon, or unitSystem are provided, return unitProps\n if (!schemaName && !phenomenon && !unitSystem)\n return unitProps;\n\n // Check if the provided values match unitProps\n const schemaNameMatches = !schemaName || unitProps.name.toLowerCase().startsWith(schemaName);\n const phenomenonMatches = !phenomenon || unitProps.phenomenon.toLowerCase() === phenomenon;\n const unitSystemMatches = !unitSystem || unitProps.system.toLowerCase() === unitSystem;\n // If all provided values match, return unitProps\n if (schemaNameMatches && phenomenonMatches && unitSystemMatches)\n return unitProps;\n }\n }\n }\n return new BadUnit();\n }\n}\n"]}
@@ -31,7 +31,6 @@ export * from "./PropertyTypes";
31
31
  export * from "./SchemaJsonLocater";
32
32
  export * from "./SchemaKey";
33
33
  export * from "./SchemaLoader";
34
- export * from "./UnitConversion/UnitConversion";
35
34
  export * from "./UnitConversion/UnitConverter";
36
35
  export * from "./UnitProvider/SchemaUnitProvider";
37
36
  export * from "./Validation/SchemaWalker";
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-metadata.d.ts","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"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Ac,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAC,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG"}
@@ -80,7 +80,6 @@ __exportStar(require("./PropertyTypes"), exports);
80
80
  __exportStar(require("./SchemaJsonLocater"), exports);
81
81
  __exportStar(require("./SchemaKey"), exports);
82
82
  __exportStar(require("./SchemaLoader"), exports);
83
- __exportStar(require("./UnitConversion/UnitConversion"), exports);
84
83
  __exportStar(require("./UnitConversion/UnitConverter"), exports);
85
84
  __exportStar(require("./UnitProvider/SchemaUnitProvider"), exports);
86
85
  __exportStar(require("./Validation/SchemaWalker"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;AAE/F,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,8DAA4C;AAC5C,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,0CAAwD;AAA/C,gGAAA,OAAO,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC7B,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAC7B,sDAAqD;AAA5C,0GAAA,WAAW,OAAA;AACpB,sDAAgF;AAAxD,0GAAA,WAAW,OAAA;AACnC,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,0CAAyC;AAAhC,8FAAA,KAAK,OAAA;AACd,4DAA0C;AAC1C,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,gDAI6B;AAH3B,oGAAA,QAAQ,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,0GAAA,cAAc,OAAA;AACxF,+GAAA,mBAAmB,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACX,yGAAA,aAAa,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAElG,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,kEAAmH;AAA1G,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAAE,6HAAA,wBAAwB,OAAA;AAC5E,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAsC;AACtC,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,kDAAgC;AAChC,sDAAoC;AACpC,8CAA4B;AAC5B,iDAA+B;AAC/B,kEAAgD;AAChD,iEAA+C;AAC/C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAC5C,qEAAmD;AACnD,wEAAsD;AACtD,0EAAwD;AACxD,gFAA8D;AAE9D,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./Constants\";\nexport * from \"./Context\";\nexport * from \"./DelayedPromise\";\nexport * from \"./Deserialization/SchemaGraphUtil\";\nexport * from \"./Deserialization/JsonProps\";\nexport * from \"./Deserialization/Helper\";\nexport * from \"./Deserialization/XmlParser\";\nexport * from \"./ECName\";\nexport * from \"./ECObjects\";\nexport * from \"./Exception\";\nexport * from \"./Interfaces\";\nexport { ECClass, StructClass } from \"./Metadata/Class\";\nexport { Constant } from \"./Metadata/Constant\";\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\nexport { EntityClass } from \"./Metadata/EntityClass\";\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\nexport { Format } from \"./Metadata/Format\";\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nexport { Mixin } from \"./Metadata/Mixin\";\nexport * from \"./Metadata/OverrideFormat\";\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\nexport {\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\n} from \"./Metadata/Property\";\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\nexport { Schema } from \"./Metadata/Schema\";\nexport * from \"./Metadata/SchemaItem\";\nexport { Unit } from \"./Metadata/Unit\";\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\nexport * from \"./PropertyTypes\";\nexport * from \"./SchemaJsonLocater\";\nexport * from \"./SchemaKey\";\nexport * from \"./SchemaLoader\";\nexport * from \"./UnitConversion/UnitConversion\";\nexport * from \"./UnitConversion/UnitConverter\";\nexport * from \"./UnitProvider/SchemaUnitProvider\";\nexport * from \"./Validation/SchemaWalker\";\nexport * from \"./SchemaPartVisitorDelegate\";\nexport * from \"./Formatting/SchemaFormatsProvider\";\nexport * from \"./Formatting/FormatSetFormatsProvider\";\nexport * from \"./IncrementalLoading/ECSqlSchemaLocater\";\nexport * from \"./IncrementalLoading/IncrementalSchemaLocater\";\nexport { CustomAttribute, CustomAttributeContainerProps} from \"./Metadata/CustomAttribute\";\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\n\n/** @docs-package-description\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\n */\n/**\n * @docs-group-description Metadata\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\n */\n/**\n * @docs-group-description Utils\n * A set of utility classes used throughout the package.\n */\n"]}
1
+ {"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;AAE/F,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,8DAA4C;AAC5C,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,0CAAwD;AAA/C,gGAAA,OAAO,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC7B,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAC7B,sDAAqD;AAA5C,0GAAA,WAAW,OAAA;AACpB,sDAAgF;AAAxD,0GAAA,WAAW,OAAA;AACnC,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,0CAAyC;AAAhC,8FAAA,KAAK,OAAA;AACd,4DAA0C;AAC1C,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,gDAI6B;AAH3B,oGAAA,QAAQ,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,0GAAA,cAAc,OAAA;AACxF,+GAAA,mBAAmB,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACX,yGAAA,aAAa,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAElG,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,kEAAmH;AAA1G,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAAE,6HAAA,wBAAwB,OAAA;AAC5E,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAsC;AACtC,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,kDAAgC;AAChC,sDAAoC;AACpC,8CAA4B;AAC5B,iDAA+B;AAC/B,iEAA+C;AAC/C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAC5C,qEAAmD;AACnD,wEAAsD;AACtD,0EAAwD;AACxD,gFAA8D;AAE9D,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./Constants\";\nexport * from \"./Context\";\nexport * from \"./DelayedPromise\";\nexport * from \"./Deserialization/SchemaGraphUtil\";\nexport * from \"./Deserialization/JsonProps\";\nexport * from \"./Deserialization/Helper\";\nexport * from \"./Deserialization/XmlParser\";\nexport * from \"./ECName\";\nexport * from \"./ECObjects\";\nexport * from \"./Exception\";\nexport * from \"./Interfaces\";\nexport { ECClass, StructClass } from \"./Metadata/Class\";\nexport { Constant } from \"./Metadata/Constant\";\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\nexport { EntityClass } from \"./Metadata/EntityClass\";\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\nexport { Format } from \"./Metadata/Format\";\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nexport { Mixin } from \"./Metadata/Mixin\";\nexport * from \"./Metadata/OverrideFormat\";\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\nexport {\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\n} from \"./Metadata/Property\";\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\nexport { Schema } from \"./Metadata/Schema\";\nexport * from \"./Metadata/SchemaItem\";\nexport { Unit } from \"./Metadata/Unit\";\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\nexport * from \"./PropertyTypes\";\nexport * from \"./SchemaJsonLocater\";\nexport * from \"./SchemaKey\";\nexport * from \"./SchemaLoader\";\nexport * from \"./UnitConversion/UnitConverter\";\nexport * from \"./UnitProvider/SchemaUnitProvider\";\nexport * from \"./Validation/SchemaWalker\";\nexport * from \"./SchemaPartVisitorDelegate\";\nexport * from \"./Formatting/SchemaFormatsProvider\";\nexport * from \"./Formatting/FormatSetFormatsProvider\";\nexport * from \"./IncrementalLoading/ECSqlSchemaLocater\";\nexport * from \"./IncrementalLoading/IncrementalSchemaLocater\";\nexport { CustomAttribute, CustomAttributeContainerProps} from \"./Metadata/CustomAttribute\";\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\n\n/** @docs-package-description\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\n */\n/**\n * @docs-group-description Metadata\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\n */\n/**\n * @docs-group-description Utils\n * A set of utility classes used throughout the package.\n */\n"]}
@@ -10,7 +10,7 @@ import { AbstractParserConstructor, CAProviderTuple } from "./AbstractParser";
10
10
  type AnyCAContainer = Schema | ECClass | Property | RelationshipConstraint;
11
11
  /**
12
12
  * Specifies the version specification for the schema
13
- * @internal
13
+ * @beta
14
14
  */
15
15
  export interface ECSpecVersion {
16
16
  readVersion: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Helper.d.ts","sourceRoot":"","sources":["../../../src/Deserialization/Helper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAY,UAAU,EAAiB,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAQvE,OAAO,EAAmB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAoD,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACzH,OAAO,EAAiB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAA6B,MAAM,8BAA8B,CAAC;AAE7F,OAAO,EAAkB,yBAAyB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAI9F,KAAK,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,sBAAsB,CAAC;AAG3E;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,qBAAa,gBAAgB,CAAC,CAAC,GAAG,OAAO;IACvC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,cAAc,CAAC,CAA4B;IACnD,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,OAAO,CAA2B;IAI1C,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,WAAW,CAAC,C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Aa;IAarB;;;;OAIG;YACW,qBAAqB;IAWnC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAWjC;;;;OAIG;YACW,0BAA0B;IAYxC;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;IAatC;;;;;;OAMG;YACW,iBAAiB;IAmD/B;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAkD7B;;;;;OAKG;YACW,YAAY;IAa1B;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;WAYlB,oBAAoB,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO;CAM3E"}
@@ -77,14 +77,17 @@ export class SchemaReadHelper {
77
77
  if (!this._schemaInfo) {
78
78
  await this.readSchemaInfo(schema, rawSchema, addSchemaToCache);
79
79
  }
80
+ const schemaInfo = this._schemaInfo;
81
+ if (!schemaInfo)
82
+ throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `Schema info not loaded for ${schema.schemaKey.toString()}`);
80
83
  // If not adding schema to cache (occurs in readSchemaInfo), we must load the schema here
81
84
  if (!addSchemaToCache) {
82
- const loadedSchema = await this.loadSchema(this._schemaInfo, schema);
85
+ const loadedSchema = await this.loadSchema(schemaInfo, schema);
83
86
  if (undefined === loadedSchema)
84
87
  throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
85
88
  return loadedSchema;
86
89
  }
87
- const cachedSchema = await this._context.getCachedSchema(this._schemaInfo.schemaKey, SchemaMatchType.Latest);
90
+ const cachedSchema = await this._context.getCachedSchema(schemaInfo.schemaKey, SchemaMatchType.Latest);
88
91
  if (undefined === cachedSchema)
89
92
  throw new ECSchemaError(ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
90
93
  return cachedSchema;
@@ -116,7 +119,7 @@ export class SchemaReadHelper {
116
119
  if (this.isSchemaItemLoaded(schemaItem))
117
120
  continue;
118
121
  const loadedItem = await this.loadSchemaItem(schema, itemName, itemType, rawItem);
119
- if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
122
+ if (loadedItem && this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
120
123
  await this._visitorHelper.visitSchemaPart(loadedItem);
121
124
  }
122
125
  }
@@ -148,7 +151,7 @@ export class SchemaReadHelper {
148
151
  // Load all schema items
149
152
  for (const [itemName, itemType, rawItem] of this._parser.getItems()) {
150
153
  const loadedItem = this.loadSchemaItemSync(schema, itemName, itemType, rawItem);
151
- if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
154
+ if (loadedItem && this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
152
155
  this._visitorHelper.visitSchemaPartSync(loadedItem);
153
156
  }
154
157
  }
@@ -183,13 +186,16 @@ export class SchemaReadHelper {
183
186
  * @param ref The object to read the SchemaReference's props from.
184
187
  */
185
188
  loadSchemaReferenceSync(ref) {
189
+ const schema = this._schema;
190
+ if (!schema)
191
+ throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Schema not set when loading reference ${ref.name}`);
186
192
  const schemaKey = new SchemaKey(ref.name, ECVersion.fromString(ref.version));
187
193
  const refSchema = this._context.getSchemaSync(schemaKey, SchemaMatchType.LatestWriteCompatible);
188
194
  if (!refSchema)
189
- throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${this._schema.schemaKey.name}`);
190
- this._schema.addReferenceSync(refSchema);
191
- SchemaGraph.generateGraphSync(this._schema).throwIfCycles();
192
- const results = this.validateSchemaReferences(this._schema);
195
+ throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${schema.schemaKey.name}`);
196
+ schema.addReferenceSync(refSchema);
197
+ SchemaGraph.generateGraphSync(schema).throwIfCycles();
198
+ const results = this.validateSchemaReferences(schema);
193
199
  let errorMessage = "";
194
200
  for (const result of results) {
195
201
  errorMessage += `${result}\r\n`;
@@ -429,13 +435,16 @@ export class SchemaReadHelper {
429
435
  if (undefined === schemaName || 0 === schemaName.length)
430
436
  throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);
431
437
  if (isInThisSchema) {
432
- schemaItem = await this._schema.getItem(itemName);
438
+ if (!this._schema)
439
+ throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Schema not set when resolving SchemaItem ${name}`);
440
+ const schema = this._schema;
441
+ schemaItem = await schema.getItem(itemName);
433
442
  if (schemaItem)
434
443
  return schemaItem;
435
444
  const foundItem = this._parser.findItem(itemName);
436
445
  if (foundItem) {
437
- schemaItem = await this.loadSchemaItem(this._schema, ...foundItem);
438
- if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
446
+ schemaItem = await this.loadSchemaItem(schema, ...foundItem);
447
+ if (!skipVisitor && schemaItem && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
439
448
  await this._visitorHelper.visitSchemaPart(schemaItem);
440
449
  }
441
450
  if (loadCallBack && schemaItem)
@@ -464,18 +473,23 @@ export class SchemaReadHelper {
464
473
  const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());
465
474
  if (undefined === schemaName || schemaName.length === 0)
466
475
  throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);
467
- if (isInThisSchema && undefined === this._schema.getItemSync(itemName)) {
468
- const foundItem = this._parser.findItem(itemName);
469
- if (foundItem) {
470
- schemaItem = this.loadSchemaItemSync(this._schema, ...foundItem);
471
- if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
472
- this._visitorHelper.visitSchemaPartSync(schemaItem);
476
+ if (isInThisSchema) {
477
+ if (!this._schema)
478
+ throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Schema not set when resolving SchemaItem ${name}`);
479
+ const schema = this._schema;
480
+ if (undefined === schema.getItemSync(itemName)) {
481
+ const foundItem = this._parser.findItem(itemName);
482
+ if (foundItem) {
483
+ schemaItem = this.loadSchemaItemSync(schema, ...foundItem);
484
+ if (!skipVisitor && schemaItem && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
485
+ this._visitorHelper.visitSchemaPartSync(schemaItem);
486
+ }
487
+ if (loadCallBack && schemaItem)
488
+ loadCallBack(schemaItem);
489
+ return schemaItem;
473
490
  }
474
- if (loadCallBack && schemaItem)
475
- loadCallBack(schemaItem);
476
- return schemaItem;
491
+ throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);
477
492
  }
478
- throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Unable to locate SchemaItem ${name}.`);
479
493
  }
480
494
  schemaItem = this._context.getSchemaItemSync(new SchemaItemKey(itemName, new SchemaKey(schemaName)));
481
495
  if (undefined === schemaItem)