@itwin/ecschema-metadata 5.11.0-dev.2 → 5.11.0-dev.4

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 (154) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/cjs/Constants.js.map +1 -1
  3. package/lib/cjs/DelayedPromise.js.map +1 -1
  4. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  5. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  6. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  7. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  8. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  9. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  10. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  11. package/lib/cjs/ECName.js.map +1 -1
  12. package/lib/cjs/ECObjects.js.map +1 -1
  13. package/lib/cjs/Exception.js.map +1 -1
  14. package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -1
  15. package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -1
  16. package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -1
  17. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
  18. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +466 -466
  19. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -1
  20. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
  21. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
  22. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
  23. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +235 -235
  24. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
  25. package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
  26. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +309 -309
  27. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -1
  28. package/lib/cjs/Interfaces.js.map +1 -1
  29. package/lib/cjs/Localization/LocalizationProvider.d.ts +31 -0
  30. package/lib/cjs/Localization/LocalizationProvider.d.ts.map +1 -0
  31. package/lib/cjs/Localization/LocalizationProvider.js +37 -0
  32. package/lib/cjs/Localization/LocalizationProvider.js.map +1 -0
  33. package/lib/cjs/Localization/LocalizationTypes.d.ts +41 -0
  34. package/lib/cjs/Localization/LocalizationTypes.d.ts.map +1 -0
  35. package/lib/cjs/Localization/LocalizationTypes.js +7 -0
  36. package/lib/cjs/Localization/LocalizationTypes.js.map +1 -0
  37. package/lib/cjs/Localization/SchemaLocalization.d.ts +94 -0
  38. package/lib/cjs/Localization/SchemaLocalization.d.ts.map +1 -0
  39. package/lib/cjs/Localization/SchemaLocalization.js +197 -0
  40. package/lib/cjs/Localization/SchemaLocalization.js.map +1 -0
  41. package/lib/cjs/Metadata/Class.js.map +1 -1
  42. package/lib/cjs/Metadata/Constant.js.map +1 -1
  43. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  44. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  45. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  46. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  47. package/lib/cjs/Metadata/Format.js.map +1 -1
  48. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  49. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  50. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  51. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  52. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  53. package/lib/cjs/Metadata/Property.js.map +1 -1
  54. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  55. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  56. package/lib/cjs/Metadata/Schema.js.map +1 -1
  57. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  58. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  59. package/lib/cjs/PropertyTypes.js.map +1 -1
  60. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  61. package/lib/cjs/SchemaKey.js.map +1 -1
  62. package/lib/cjs/SchemaLoader.js.map +1 -1
  63. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  64. package/lib/cjs/SchemaView.js.map +1 -1
  65. package/lib/cjs/SchemaViewBinaryReader.js.map +1 -1
  66. package/lib/cjs/SchemaViewInterfaces.js.map +1 -1
  67. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  68. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  69. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  70. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  71. package/lib/cjs/ecschema-metadata.d.ts +3 -0
  72. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  73. package/lib/cjs/ecschema-metadata.js +3 -0
  74. package/lib/cjs/ecschema-metadata.js.map +1 -1
  75. package/lib/cjs/utils/ECClassHierarchy.js.map +1 -1
  76. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  77. package/lib/cjs/utils/SchemaLoadingController.js.map +1 -1
  78. package/lib/esm/Constants.js.map +1 -1
  79. package/lib/esm/DelayedPromise.js.map +1 -1
  80. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  81. package/lib/esm/Deserialization/Helper.js.map +1 -1
  82. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  83. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  84. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  85. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  86. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  87. package/lib/esm/ECName.js.map +1 -1
  88. package/lib/esm/ECObjects.js.map +1 -1
  89. package/lib/esm/Exception.js.map +1 -1
  90. package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -1
  91. package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -1
  92. package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -1
  93. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
  94. package/lib/esm/IncrementalLoading/FullSchemaQueries.js +466 -466
  95. package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -1
  96. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
  97. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
  98. package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
  99. package/lib/esm/IncrementalLoading/SchemaItemQueries.js +235 -235
  100. package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
  101. package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
  102. package/lib/esm/IncrementalLoading/SchemaStubQueries.js +309 -309
  103. package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -1
  104. package/lib/esm/Interfaces.js.map +1 -1
  105. package/lib/esm/Localization/LocalizationProvider.d.ts +31 -0
  106. package/lib/esm/Localization/LocalizationProvider.d.ts.map +1 -0
  107. package/lib/esm/Localization/LocalizationProvider.js +33 -0
  108. package/lib/esm/Localization/LocalizationProvider.js.map +1 -0
  109. package/lib/esm/Localization/LocalizationTypes.d.ts +41 -0
  110. package/lib/esm/Localization/LocalizationTypes.d.ts.map +1 -0
  111. package/lib/esm/Localization/LocalizationTypes.js +6 -0
  112. package/lib/esm/Localization/LocalizationTypes.js.map +1 -0
  113. package/lib/esm/Localization/SchemaLocalization.d.ts +94 -0
  114. package/lib/esm/Localization/SchemaLocalization.d.ts.map +1 -0
  115. package/lib/esm/Localization/SchemaLocalization.js +193 -0
  116. package/lib/esm/Localization/SchemaLocalization.js.map +1 -0
  117. package/lib/esm/Metadata/Class.js.map +1 -1
  118. package/lib/esm/Metadata/Constant.js.map +1 -1
  119. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  120. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  121. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  122. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  123. package/lib/esm/Metadata/Format.js.map +1 -1
  124. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  125. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  126. package/lib/esm/Metadata/Mixin.js.map +1 -1
  127. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  128. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  129. package/lib/esm/Metadata/Property.js.map +1 -1
  130. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  131. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  132. package/lib/esm/Metadata/Schema.js.map +1 -1
  133. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  134. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  135. package/lib/esm/PropertyTypes.js.map +1 -1
  136. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  137. package/lib/esm/SchemaKey.js.map +1 -1
  138. package/lib/esm/SchemaLoader.js.map +1 -1
  139. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  140. package/lib/esm/SchemaView.js.map +1 -1
  141. package/lib/esm/SchemaViewBinaryReader.js.map +1 -1
  142. package/lib/esm/SchemaViewInterfaces.js.map +1 -1
  143. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  144. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  145. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  146. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  147. package/lib/esm/ecschema-metadata.d.ts +3 -0
  148. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  149. package/lib/esm/ecschema-metadata.js +3 -0
  150. package/lib/esm/ecschema-metadata.js.map +1 -1
  151. package/lib/esm/utils/ECClassHierarchy.js.map +1 -1
  152. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  153. package/lib/esm/utils/SchemaLoadingController.js.map +1 -1
  154. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaStubQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaStubQueries.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,OAAO;;cAEK,KAAK;cACL,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,OAAO;;cAEK,KAAK;cACL,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE;IACjD,OAAO;;cAEK,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;;;;;;;;;;CAcrB,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;;;oBAMT,QAAQ,CAAC,OAAO,CAAC;;;;;;;;;;0BAUX,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;;;;CAc9C,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;oBAMA,QAAQ,CAAC,OAAO,CAAC;;;;;;;;;0BASX,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;;;CAa9C,CAAC;AAEF,MAAM,iBAAiB,GAAG;;;;;;oBAMN,QAAQ,CAAC,OAAO,CAAC;;;oBAGjB,QAAQ,CAAC,OAAO,CAAC;6BACR,iBAAiB,CAAC,OAAO,CAAC;;;;;;;0BAO7B,QAAQ,CAAC,WAAW,CAAC;;;0BAGrB,QAAQ,CAAC,WAAW,CAAC;mCACZ,iBAAiB,CAAC,WAAW,CAAC;;;;;;;;;;;CAWhE,CAAC;AAEF,MAAM,WAAW,GAAG;;;;;;oBAMA,QAAQ,CAAC,OAAO,CAAC;;;;;;;;;0BASX,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;0BAkBrB,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;;;;gCAcf,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BzD,CAAC;AAEF,MAAM,UAAU,GAAG;;;;;;oBAMC,QAAQ,CAAC,OAAO,CAAC;;;;;;;;;;;;;;0BAcX,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;CAmB9C,CAAC;AAEF,MAAM,eAAe,GAAG;;IAEpB,oBAAoB;;IAEpB,WAAW;;IAEX,iBAAiB;;IAEjB,WAAW;;IAEX,UAAU;;IAEV,iBAAiB,CAAC,WAAW,EAAE;;IAE/B,iBAAiB,CAAC,cAAc,EAAE;;IAElC,iBAAiB,CAAC,gBAAgB,EAAE;;IAEpC,iBAAiB,CAAC,IAAI,EAAE;;IAExB,iBAAiB,CAAC,YAAY,EAAE;;IAEhC,iBAAiB,CAAC,QAAQ,EAAE;;IAE5B,iBAAiB,CAAC,UAAU,EAAE;;IAE9B,iBAAiB,CAAC,UAAU,EAAE;;IAE9B,iBAAiB,CAAC,MAAM,EAAE;;CAE7B,CAAC;AAEF,MAAM,eAAe,GAAG;;MAElB,aAAa;MACb,eAAe;;;;;;;;CAQpB,CAAC;AAEF,MAAM,eAAe,GAAG;;MAElB,oBAAoB;;;;;;;;;;;;;;;;;CAiBzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe;IACf,eAAe;CAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\r\n\r\nexport const modifier = (alias: string) => {\r\n return `\r\n CASE\r\n WHEN [${alias}].[modifier] = 0 THEN 'None'\r\n WHEN [${alias}].[modifier] = 1 THEN 'Abstract'\r\n WHEN [${alias}].[modifier] = 2 THEN 'Sealed'\r\n ELSE NULL\r\n END\r\n `;\r\n};\r\n\r\nexport const strength = (alias: string) => {\r\n return `\r\n CASE\r\n WHEN [${alias}].[RelationshipStrength] = 0 THEN 'Referencing'\r\n WHEN [${alias}].[RelationshipStrength] = 1 THEN 'Holding'\r\n WHEN [${alias}].[RelationshipStrength] = 2 THEN 'Embedding'\r\n ELSE NULL\r\n END\r\n `;\r\n};\r\n\r\nexport const strengthDirection = (alias: string) => {\r\n return `\r\n CASE\r\n WHEN [${alias}].[RelationshipStrengthDirection] = 1 THEN 'Forward'\r\n WHEN [${alias}].[RelationshipStrengthDirection] = 2 THEN 'Backward'\r\n ELSE NULL\r\n END\r\n `;\r\n};\r\n\r\nconst withAppliesTo = `\r\n AppliesToCTE AS (\r\n SELECT\r\n [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],\r\n [appliesToSchema].[name] as [AppliesToSchema],\r\n json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]\r\n FROM [meta].[CustomAttribute] [ca]\r\n JOIN [meta].[ECClassDef] [mixinAppliesTo]\r\n ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]\r\n JOIN [meta].[ECSchemaDef] [appliesToSchema]\r\n ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]\r\n WHERE [ca].[ContainerType] = 30\r\n AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'\r\n )\r\n`;\r\n\r\nconst withSchemaReferences = `\r\n SchemaReferences AS (\r\n SELECT\r\n [ref].[SourceECInstanceId] AS [SchemaId],\r\n CONCAT([Name],'.',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [fullName]\r\n FROM\r\n [meta].[ECSchemaDef] AS [refSchema]\r\n INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]\r\n ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]\r\n )\r\n`;\r\n\r\nconst customAttributeQuery = `\r\n SELECT\r\n [Schema].[Id] AS [SchemaId],\r\n json_object(\r\n 'name', [class].[Name],\r\n 'schemaItemType', 'CustomAttributeClass',\r\n 'modifier', ${modifier(\"class\")},\r\n 'label', [class].[DisplayLabel],\r\n 'description', [class].[Description],\r\n 'appliesTo', [class].[CustomAttributeContainerType],\r\n 'baseClasses', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\r\n 'name', [baseClass].[Name],\r\n 'schemaItemType', 'CustomAttributeClass',\r\n 'modifier', ${modifier(\"baseClass\")},\r\n 'label', [baseClass].[DisplayLabel],\r\n 'description', [baseClass].[Description],\r\n 'appliesTo', [baseClass].[CustomAttributeContainerType]\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [baseClass]\r\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\r\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\r\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\r\n )\r\n ) AS [item]\r\n FROM [meta].[ECClassDef] [class]\r\n WHERE [class].[Type] = 3\r\n`;\r\n\r\nconst structQuery = `\r\n SELECT\r\n [Schema].[Id] AS [SchemaId],\r\n json_object(\r\n 'name', [class].[Name],\r\n 'schemaItemType', 'StructClass',\r\n 'modifier', ${modifier(\"class\")},\r\n 'label', [class].[DisplayLabel],\r\n 'description', [class].[Description],\r\n 'baseClasses', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\r\n 'name', [baseClass].[Name],\r\n 'schemaItemType', 'StructClass',\r\n 'modifier', ${modifier(\"baseClass\")},\r\n 'label', [baseClass].[DisplayLabel],\r\n 'description', [baseClass].[Description]\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [baseClass]\r\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\r\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\r\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\r\n )\r\n ) AS [item]\r\n FROM [meta].[ECClassDef] [class]\r\n WHERE [class].[Type] = 2\r\n`;\r\n\r\nconst relationshipQuery = `\r\n SELECT\r\n [Schema].[Id] AS [SchemaId],\r\n json_object(\r\n 'name', [class].[Name],\r\n 'schemaItemType', 'RelationshipClass',\r\n 'modifier', ${modifier(\"class\")},\r\n 'label', [class].[DisplayLabel],\r\n 'description', [class].[Description],\r\n 'strength', ${strength(\"class\")},\r\n 'strengthDirection', ${strengthDirection(\"class\")},\r\n 'baseClasses', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\r\n 'name', [baseClass].[Name],\r\n 'schemaItemType', 'RelationshipClass',\r\n 'modifier', ${modifier(\"baseClass\")},\r\n 'label', [baseClass].[DisplayLabel],\r\n 'description', [baseClass].[Description],\r\n 'strength', ${strength(\"baseClass\")},\r\n 'strengthDirection', ${strengthDirection(\"baseClass\")}\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [baseClass]\r\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\r\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\r\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\r\n )\r\n ) AS [item]\r\n FROM [meta].[ECClassDef] [class]\r\n WHERE [class].[Type] = 1\r\n`;\r\n\r\nconst entityQuery = `\r\n SELECT\r\n [Schema].[Id] AS [SchemaId],\r\n json_object(\r\n 'name', [class].[Name],\r\n 'schemaItemType', 'EntityClass',\r\n 'modifier', ${modifier(\"class\")},\r\n 'label', [class].[DisplayLabel],\r\n 'description', [class].[Description],\r\n 'baseClasses', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\r\n 'name', [baseClass].[Name],\r\n 'schemaItemType', 'EntityClass',\r\n 'modifier', ${modifier(\"baseClass\")},\r\n 'label', [baseClass].[DisplayLabel],\r\n 'description', [baseClass].[Description]\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [baseClass]\r\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\r\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\r\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\r\n AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]\r\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\r\n ),\r\n 'mixins', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\r\n 'name', [baseClass].[Name],\r\n 'schemaItemType', 'Mixin',\r\n 'modifier', ${modifier(\"baseClass\")},\r\n 'label', [baseClass].[DisplayLabel],\r\n 'description', [baseClass].[Description],\r\n 'appliesTo', (\r\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\r\n FROM [AppliesToCTE] [atCTE]\r\n WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]\r\n ),\r\n 'baseClasses', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([mixinBaseClass].[ECInstanceId], 's'),\r\n 'name', [mixinBaseClass].[Name],\r\n 'schemaItemType', 'Mixin',\r\n 'modifier', ${modifier(\"mixinBaseClass\")},\r\n 'label', [mixinBaseClass].[DisplayLabel],\r\n 'description', [mixinBaseClass].[Description],\r\n 'appliesTo', (\r\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\r\n FROM [AppliesToCTE] [atCTE]\r\n WHERE [atCTE].[AppliesToId] = [mixinBaseClass].[ECInstanceId]\r\n )\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [mixinBaseClass]\r\n INNER JOIN [meta].[ClassHasAllBaseClasses] [mixinBaseClassMap]\r\n ON [mixinBaseClassMap].[TargetECInstanceId] = [mixinBaseClass].[ECInstanceId]\r\n WHERE [mixinBaseClassMap].[SourceECInstanceId] = [baseClass].[ECInstanceId]\r\n )\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [baseClass]\r\n INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]\r\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\r\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\r\n AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]\r\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\r\n )\r\n ) AS [item]\r\n FROM [meta].[ECClassDef] [class]\r\n WHERE [class].[Type] = 0\r\n AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\r\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\r\n`;\r\n\r\nconst mixinQuery = `\r\n SELECT\r\n [Schema].[Id] AS [SchemaId],\r\n json_object(\r\n 'name', [class].[Name],\r\n 'schemaItemType', 'Mixin',\r\n 'modifier', ${modifier(\"class\")},\r\n 'label', [class].[DisplayLabel],\r\n 'description', [class].[Description],\r\n 'appliesTo', (\r\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\r\n FROM [AppliesToCTE] [atCTE]\r\n WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]\r\n ),\r\n 'baseClasses', (\r\n SELECT\r\n json_group_array(json(json_object(\r\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\r\n 'name', [baseClass].[Name],\r\n 'schemaItemType', 'Mixin',\r\n 'modifier', ${modifier(\"baseClass\")},\r\n 'label', [baseClass].[DisplayLabel],\r\n 'description', [baseClass].[Description],\r\n 'appliesTo', (\r\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\r\n FROM [AppliesToCTE] [atCTE]\r\n WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]\r\n )\r\n )))\r\n FROM\r\n [meta].[ECClassDef] [baseClass]\r\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\r\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\r\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\r\n )\r\n ) AS [item]\r\n FROM [meta].[ECClassDef] [class]\r\n WHERE [class].[Type] = 0 AND EXISTS (SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\r\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\r\n`;\r\n\r\nconst withSchemaItems = `\r\nSchemaItems AS (\r\n ${customAttributeQuery}\r\n UNION ALL\r\n ${structQuery}\r\n UNION ALL\r\n ${relationshipQuery}\r\n UNION ALL\r\n ${entityQuery}\r\n UNION ALL\r\n ${mixinQuery}\r\n UNION ALL\r\n ${SchemaItemQueries.enumeration()}\r\n UNION ALL\r\n ${SchemaItemQueries.kindOfQuantity()}\r\n UNION ALL\r\n ${SchemaItemQueries.propertyCategory()}\r\n UNION ALL\r\n ${SchemaItemQueries.unit()}\r\n UNION ALL\r\n ${SchemaItemQueries.invertedUnit()}\r\n UNION ALL\r\n ${SchemaItemQueries.constant()}\r\n UNION ALL\r\n ${SchemaItemQueries.phenomenon()}\r\n UNION ALL\r\n ${SchemaItemQueries.unitSystem()}\r\n UNION ALL\r\n ${SchemaItemQueries.format()}\r\n )\r\n`;\r\n\r\nconst schemaStubQuery = `\r\n WITH\r\n ${withAppliesTo},\r\n ${withSchemaItems}\r\n SELECT\r\n [items].[item]\r\n FROM\r\n [SchemaItems] [items]\r\n JOIN [meta].[ECSchemaDef] [schemaDef]\r\n ON [schemaDef].[ECInstanceId] = [items].[SchemaId]\r\n WHERE [schemaDef].[Name] = :schemaName\r\n`;\r\n\r\nconst schemaInfoQuery = `\r\n WITH\r\n ${withSchemaReferences}\r\n SELECT\r\n [Name] as [name],\r\n CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],\r\n [Alias] as [alias],\r\n [DisplayLabel] as [label],\r\n [Description] as [description],\r\n (\r\n SELECT\r\n json_group_array([schemaReferences].[fullName])\r\n FROM\r\n [SchemaReferences] [schemaReferences]\r\n WHERE\r\n [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]\r\n ) AS [references]\r\n FROM\r\n [meta].[ECSchemaDef] [schemaDef]\r\n`;\r\n\r\n/**\r\n * Partial Schema queries.\r\n * @internal\r\n */\r\nexport const ecsqlQueries = {\r\n schemaStubQuery,\r\n schemaInfoQuery,\r\n};\r\n"]}
1
+ {"version":3,"file":"SchemaStubQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaStubQueries.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAA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;;;;;;;;gCAcf,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BzD,CAAC;AAEF,MAAM,UAAU,GAAG;;;;;;oBAMC,QAAQ,CAAC,OAAO,CAAC;;;;;;;;;;;;;;0BAcX,QAAQ,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;CAmB9C,CAAC;AAEF,MAAM,eAAe,GAAG;;IAEpB,oBAAoB;;IAEpB,WAAW;;IAEX,iBAAiB;;IAEjB,WAAW;;IAEX,UAAU;;IAEV,iBAAiB,CAAC,WAAW,EAAE;;IAE/B,iBAAiB,CAAC,cAAc,EAAE;;IAElC,iBAAiB,CAAC,gBAAgB,EAAE;;IAEpC,iBAAiB,CAAC,IAAI,EAAE;;IAExB,iBAAiB,CAAC,YAAY,EAAE;;IAEhC,iBAAiB,CAAC,QAAQ,EAAE;;IAE5B,iBAAiB,CAAC,UAAU,EAAE;;IAE9B,iBAAiB,CAAC,UAAU,EAAE;;IAE9B,iBAAiB,CAAC,MAAM,EAAE;;CAE7B,CAAC;AAEF,MAAM,eAAe,GAAG;;MAElB,aAAa;MACb,eAAe;;;;;;;;CAQpB,CAAC;AAEF,MAAM,eAAe,GAAG;;MAElB,oBAAoB;;;;;;;;;;;;;;;;;CAiBzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe;IACf,eAAe;CAChB,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 *--------------------------------------------------------------------------------------------*/\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\n\nexport const modifier = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[modifier] = 0 THEN 'None'\n WHEN [${alias}].[modifier] = 1 THEN 'Abstract'\n WHEN [${alias}].[modifier] = 2 THEN 'Sealed'\n ELSE NULL\n END\n `;\n};\n\nexport const strength = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[RelationshipStrength] = 0 THEN 'Referencing'\n WHEN [${alias}].[RelationshipStrength] = 1 THEN 'Holding'\n WHEN [${alias}].[RelationshipStrength] = 2 THEN 'Embedding'\n ELSE NULL\n END\n `;\n};\n\nexport const strengthDirection = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[RelationshipStrengthDirection] = 1 THEN 'Forward'\n WHEN [${alias}].[RelationshipStrengthDirection] = 2 THEN 'Backward'\n ELSE NULL\n END\n `;\n};\n\nconst withAppliesTo = `\n AppliesToCTE AS (\n SELECT\n [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],\n [appliesToSchema].[name] as [AppliesToSchema],\n json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]\n FROM [meta].[CustomAttribute] [ca]\n JOIN [meta].[ECClassDef] [mixinAppliesTo]\n ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]\n JOIN [meta].[ECSchemaDef] [appliesToSchema]\n ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]\n WHERE [ca].[ContainerType] = 30\n AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'\n )\n`;\n\nconst withSchemaReferences = `\n SchemaReferences AS (\n SELECT\n [ref].[SourceECInstanceId] AS [SchemaId],\n CONCAT([Name],'.',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [fullName]\n FROM\n [meta].[ECSchemaDef] AS [refSchema]\n INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]\n ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]\n )\n`;\n\nconst customAttributeQuery = `\n SELECT\n [Schema].[Id] AS [SchemaId],\n json_object(\n 'name', [class].[Name],\n 'schemaItemType', 'CustomAttributeClass',\n 'modifier', ${modifier(\"class\")},\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'appliesTo', [class].[CustomAttributeContainerType],\n 'baseClasses', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\n 'name', [baseClass].[Name],\n 'schemaItemType', 'CustomAttributeClass',\n 'modifier', ${modifier(\"baseClass\")},\n 'label', [baseClass].[DisplayLabel],\n 'description', [baseClass].[Description],\n 'appliesTo', [baseClass].[CustomAttributeContainerType]\n )))\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n WHERE [class].[Type] = 3\n`;\n\nconst structQuery = `\n SELECT\n [Schema].[Id] AS [SchemaId],\n json_object(\n 'name', [class].[Name],\n 'schemaItemType', 'StructClass',\n 'modifier', ${modifier(\"class\")},\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'baseClasses', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\n 'name', [baseClass].[Name],\n 'schemaItemType', 'StructClass',\n 'modifier', ${modifier(\"baseClass\")},\n 'label', [baseClass].[DisplayLabel],\n 'description', [baseClass].[Description]\n )))\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n WHERE [class].[Type] = 2\n`;\n\nconst relationshipQuery = `\n SELECT\n [Schema].[Id] AS [SchemaId],\n json_object(\n 'name', [class].[Name],\n 'schemaItemType', 'RelationshipClass',\n 'modifier', ${modifier(\"class\")},\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'strength', ${strength(\"class\")},\n 'strengthDirection', ${strengthDirection(\"class\")},\n 'baseClasses', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\n 'name', [baseClass].[Name],\n 'schemaItemType', 'RelationshipClass',\n 'modifier', ${modifier(\"baseClass\")},\n 'label', [baseClass].[DisplayLabel],\n 'description', [baseClass].[Description],\n 'strength', ${strength(\"baseClass\")},\n 'strengthDirection', ${strengthDirection(\"baseClass\")}\n )))\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n WHERE [class].[Type] = 1\n`;\n\nconst entityQuery = `\n SELECT\n [Schema].[Id] AS [SchemaId],\n json_object(\n 'name', [class].[Name],\n 'schemaItemType', 'EntityClass',\n 'modifier', ${modifier(\"class\")},\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'baseClasses', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\n 'name', [baseClass].[Name],\n 'schemaItemType', 'EntityClass',\n 'modifier', ${modifier(\"baseClass\")},\n 'label', [baseClass].[DisplayLabel],\n 'description', [baseClass].[Description]\n )))\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n ),\n 'mixins', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\n 'name', [baseClass].[Name],\n 'schemaItemType', 'Mixin',\n 'modifier', ${modifier(\"baseClass\")},\n 'label', [baseClass].[DisplayLabel],\n 'description', [baseClass].[Description],\n 'appliesTo', (\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\n FROM [AppliesToCTE] [atCTE]\n WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]\n ),\n 'baseClasses', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([mixinBaseClass].[ECInstanceId], 's'),\n 'name', [mixinBaseClass].[Name],\n 'schemaItemType', 'Mixin',\n 'modifier', ${modifier(\"mixinBaseClass\")},\n 'label', [mixinBaseClass].[DisplayLabel],\n 'description', [mixinBaseClass].[Description],\n 'appliesTo', (\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\n FROM [AppliesToCTE] [atCTE]\n WHERE [atCTE].[AppliesToId] = [mixinBaseClass].[ECInstanceId]\n )\n )))\n FROM\n [meta].[ECClassDef] [mixinBaseClass]\n INNER JOIN [meta].[ClassHasAllBaseClasses] [mixinBaseClassMap]\n ON [mixinBaseClassMap].[TargetECInstanceId] = [mixinBaseClass].[ECInstanceId]\n WHERE [mixinBaseClassMap].[SourceECInstanceId] = [baseClass].[ECInstanceId]\n )\n )))\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n WHERE [class].[Type] = 0\n AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n`;\n\nconst mixinQuery = `\n SELECT\n [Schema].[Id] AS [SchemaId],\n json_object(\n 'name', [class].[Name],\n 'schemaItemType', 'Mixin',\n 'modifier', ${modifier(\"class\")},\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'appliesTo', (\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\n FROM [AppliesToCTE] [atCTE]\n WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]\n ),\n 'baseClasses', (\n SELECT\n json_group_array(json(json_object(\n 'schema', ec_classname([baseClass].[ECInstanceId], 's'),\n 'name', [baseClass].[Name],\n 'schemaItemType', 'Mixin',\n 'modifier', ${modifier(\"baseClass\")},\n 'label', [baseClass].[DisplayLabel],\n 'description', [baseClass].[Description],\n 'appliesTo', (\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\n FROM [AppliesToCTE] [atCTE]\n WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]\n )\n )))\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n WHERE [class].[Type] = 0 AND EXISTS (SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n`;\n\nconst withSchemaItems = `\nSchemaItems AS (\n ${customAttributeQuery}\n UNION ALL\n ${structQuery}\n UNION ALL\n ${relationshipQuery}\n UNION ALL\n ${entityQuery}\n UNION ALL\n ${mixinQuery}\n UNION ALL\n ${SchemaItemQueries.enumeration()}\n UNION ALL\n ${SchemaItemQueries.kindOfQuantity()}\n UNION ALL\n ${SchemaItemQueries.propertyCategory()}\n UNION ALL\n ${SchemaItemQueries.unit()}\n UNION ALL\n ${SchemaItemQueries.invertedUnit()}\n UNION ALL\n ${SchemaItemQueries.constant()}\n UNION ALL\n ${SchemaItemQueries.phenomenon()}\n UNION ALL\n ${SchemaItemQueries.unitSystem()}\n UNION ALL\n ${SchemaItemQueries.format()}\n )\n`;\n\nconst schemaStubQuery = `\n WITH\n ${withAppliesTo},\n ${withSchemaItems}\n SELECT\n [items].[item]\n FROM\n [SchemaItems] [items]\n JOIN [meta].[ECSchemaDef] [schemaDef]\n ON [schemaDef].[ECInstanceId] = [items].[SchemaId]\n WHERE [schemaDef].[Name] = :schemaName\n`;\n\nconst schemaInfoQuery = `\n WITH\n ${withSchemaReferences}\n SELECT\n [Name] as [name],\n CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],\n [Alias] as [alias],\n [DisplayLabel] as [label],\n [Description] as [description],\n (\n SELECT\n json_group_array([schemaReferences].[fullName])\n FROM\n [SchemaReferences] [schemaReferences]\n WHERE\n [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]\n ) AS [references]\n FROM\n [meta].[ECSchemaDef] [schemaDef]\n`;\n\n/**\n * Partial Schema queries.\n * @internal\n */\nexport const ecsqlQueries = {\n schemaStubQuery,\n schemaInfoQuery,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { ECClass, StructClass } from \"./Metadata/Class\";\r\nimport { Constant } from \"./Metadata/Constant\";\r\nimport { CustomAttribute, CustomAttributeContainerProps } from \"./Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\r\nimport { EntityClass } from \"./Metadata/EntityClass\";\r\nimport { AnyEnumerator, Enumeration } from \"./Metadata/Enumeration\";\r\nimport { Format } from \"./Metadata/Format\";\r\nimport { InvertedUnit } from \"./Metadata/InvertedUnit\";\r\nimport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\r\nimport { Mixin } from \"./Metadata/Mixin\";\r\nimport { OverrideFormat } from \"./Metadata/OverrideFormat\";\r\nimport { Phenomenon } from \"./Metadata/Phenomenon\";\r\nimport { AnyProperty } from \"./Metadata/Property\";\r\nimport { PropertyCategory } from \"./Metadata/PropertyCategory\";\r\nimport { RelationshipClass, RelationshipConstraint } from \"./Metadata/RelationshipClass\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { Unit } from \"./Metadata/Unit\";\r\nimport { UnitSystem } from \"./Metadata/UnitSystem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/** @public @preview */\r\nexport type LazyLoadedSchema = SchemaKey & Promise<Schema>;\r\n\r\n/** @public @preview */\r\nexport type LazyLoadedSchemaItem<T extends SchemaItem> = SchemaItemKey & Promise<T>;\r\n/** @public @preview */\r\nexport type LazyLoadedECClass = LazyLoadedSchemaItem<ECClass>;\r\n/** @public @preview */\r\nexport type LazyLoadedEntityClass = LazyLoadedSchemaItem<EntityClass>;\r\n/** @public @preview */\r\nexport type LazyLoadedMixin = LazyLoadedSchemaItem<Mixin>;\r\n/** @public @preview */\r\nexport type LazyLoadedStructClass = LazyLoadedSchemaItem<StructClass>;\r\n/** @public @preview */\r\nexport type LazyLoadedRelationshipClass = LazyLoadedSchemaItem<RelationshipClass>;\r\n/** @public @preview */\r\nexport type LazyLoadedEnumeration = LazyLoadedSchemaItem<Enumeration>;\r\n/** @public @preview */\r\nexport type LazyLoadedFormat = LazyLoadedSchemaItem<Format>;\r\n/** @public @preview */\r\nexport type LazyLoadedKindOfQuantity = LazyLoadedSchemaItem<KindOfQuantity>;\r\n/** @public @preview */\r\nexport type LazyLoadedPropertyCategory = LazyLoadedSchemaItem<PropertyCategory>;\r\n/** @public @preview */\r\nexport type LazyLoadedRelationshipConstraintClass = LazyLoadedSchemaItem<EntityClass | Mixin | RelationshipClass>;\r\n/** @public @preview */\r\nexport type LazyLoadedUnit = LazyLoadedSchemaItem<Unit>;\r\n/** @public @preview */\r\nexport type LazyLoadedInvertedUnit = LazyLoadedSchemaItem<InvertedUnit>;\r\n/** @public @preview */\r\nexport type LazyLoadedPhenomenon = LazyLoadedSchemaItem<Phenomenon>;\r\n/** @public @preview */\r\nexport type LazyLoadedUnitSystem = LazyLoadedSchemaItem<UnitSystem>;\r\n\r\n/** @public @preview */\r\nexport type AnyClass =\r\n EntityClass |\r\n Mixin |\r\n StructClass |\r\n CustomAttributeClass |\r\n RelationshipClass;\r\n\r\n/** @public @preview */\r\nexport type AnySchemaItem =\r\n AnyClass |\r\n Enumeration |\r\n KindOfQuantity |\r\n PropertyCategory |\r\n Unit |\r\n InvertedUnit |\r\n Constant |\r\n Phenomenon |\r\n UnitSystem |\r\n Format;\r\n\r\n/** @public @preview */\r\nexport type AnyECType =\r\n Schema |\r\n SchemaItem |\r\n AnyProperty |\r\n RelationshipConstraint |\r\n CustomAttributeContainerProps |\r\n CustomAttribute |\r\n OverrideFormat |\r\n AnyEnumerator;\r\n\r\n/**\r\n * Holds the SchemaKeys for a schema and it's references. Designed so that Schema fulfills this interface.\r\n * @public @preview\r\n */\r\nexport interface SchemaInfo {\r\n readonly alias: string;\r\n readonly schemaKey: SchemaKey;\r\n readonly references: ReadonlyArray<WithSchemaKey>;\r\n}\r\n\r\n/** @public @preview */\r\nexport interface WithSchemaKey {\r\n readonly schemaKey: SchemaKey;\r\n}\r\n\r\n/** This is needed to break a circular dependency between Class and EntityClass.\r\n * @public @preview\r\n */\r\nexport interface HasMixins {\r\n readonly mixins: ReadonlyArray<LazyLoadedMixin>;\r\n getMixinsSync(): Iterable<Mixin>;\r\n}\r\n"]}
1
+ {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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 { ECClass, StructClass } from \"./Metadata/Class\";\nimport { Constant } from \"./Metadata/Constant\";\nimport { CustomAttribute, CustomAttributeContainerProps } from \"./Metadata/CustomAttribute\";\nimport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\nimport { EntityClass } from \"./Metadata/EntityClass\";\nimport { AnyEnumerator, Enumeration } from \"./Metadata/Enumeration\";\nimport { Format } from \"./Metadata/Format\";\nimport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nimport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nimport { Mixin } from \"./Metadata/Mixin\";\nimport { OverrideFormat } from \"./Metadata/OverrideFormat\";\nimport { Phenomenon } from \"./Metadata/Phenomenon\";\nimport { AnyProperty } from \"./Metadata/Property\";\nimport { PropertyCategory } from \"./Metadata/PropertyCategory\";\nimport { RelationshipClass, RelationshipConstraint } from \"./Metadata/RelationshipClass\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\nimport { Unit } from \"./Metadata/Unit\";\nimport { UnitSystem } from \"./Metadata/UnitSystem\";\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\n\n/** @public @preview */\nexport type LazyLoadedSchema = SchemaKey & Promise<Schema>;\n\n/** @public @preview */\nexport type LazyLoadedSchemaItem<T extends SchemaItem> = SchemaItemKey & Promise<T>;\n/** @public @preview */\nexport type LazyLoadedECClass = LazyLoadedSchemaItem<ECClass>;\n/** @public @preview */\nexport type LazyLoadedEntityClass = LazyLoadedSchemaItem<EntityClass>;\n/** @public @preview */\nexport type LazyLoadedMixin = LazyLoadedSchemaItem<Mixin>;\n/** @public @preview */\nexport type LazyLoadedStructClass = LazyLoadedSchemaItem<StructClass>;\n/** @public @preview */\nexport type LazyLoadedRelationshipClass = LazyLoadedSchemaItem<RelationshipClass>;\n/** @public @preview */\nexport type LazyLoadedEnumeration = LazyLoadedSchemaItem<Enumeration>;\n/** @public @preview */\nexport type LazyLoadedFormat = LazyLoadedSchemaItem<Format>;\n/** @public @preview */\nexport type LazyLoadedKindOfQuantity = LazyLoadedSchemaItem<KindOfQuantity>;\n/** @public @preview */\nexport type LazyLoadedPropertyCategory = LazyLoadedSchemaItem<PropertyCategory>;\n/** @public @preview */\nexport type LazyLoadedRelationshipConstraintClass = LazyLoadedSchemaItem<EntityClass | Mixin | RelationshipClass>;\n/** @public @preview */\nexport type LazyLoadedUnit = LazyLoadedSchemaItem<Unit>;\n/** @public @preview */\nexport type LazyLoadedInvertedUnit = LazyLoadedSchemaItem<InvertedUnit>;\n/** @public @preview */\nexport type LazyLoadedPhenomenon = LazyLoadedSchemaItem<Phenomenon>;\n/** @public @preview */\nexport type LazyLoadedUnitSystem = LazyLoadedSchemaItem<UnitSystem>;\n\n/** @public @preview */\nexport type AnyClass =\n EntityClass |\n Mixin |\n StructClass |\n CustomAttributeClass |\n RelationshipClass;\n\n/** @public @preview */\nexport type AnySchemaItem =\n AnyClass |\n Enumeration |\n KindOfQuantity |\n PropertyCategory |\n Unit |\n InvertedUnit |\n Constant |\n Phenomenon |\n UnitSystem |\n Format;\n\n/** @public @preview */\nexport type AnyECType =\n Schema |\n SchemaItem |\n AnyProperty |\n RelationshipConstraint |\n CustomAttributeContainerProps |\n CustomAttribute |\n OverrideFormat |\n AnyEnumerator;\n\n/**\n * Holds the SchemaKeys for a schema and it's references. Designed so that Schema fulfills this interface.\n * @public @preview\n */\nexport interface SchemaInfo {\n readonly alias: string;\n readonly schemaKey: SchemaKey;\n readonly references: ReadonlyArray<WithSchemaKey>;\n}\n\n/** @public @preview */\nexport interface WithSchemaKey {\n readonly schemaKey: SchemaKey;\n}\n\n/** This is needed to break a circular dependency between Class and EntityClass.\n * @public @preview\n */\nexport interface HasMixins {\n readonly mixins: ReadonlyArray<LazyLoadedMixin>;\n getMixinsSync(): Iterable<Mixin>;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { SchemaLocalizationJson } from "./LocalizationTypes";
2
+ /**
3
+ * Interface for providing localization JSON files for schemas.
4
+ * @beta
5
+ */
6
+ export interface ILocalizationProvider {
7
+ /**
8
+ * Load localization JSON for a given schema and locale.
9
+ * @param schemaName The name of the schema
10
+ * @param locale The locale identifier (e.g., "de", "fr", "es-CO")
11
+ * @returns Promise resolving to the localization JSON, or undefined if not found
12
+ */
13
+ getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;
14
+ }
15
+ /**
16
+ * The provider to load the localization JSON files.
17
+ * @beta
18
+ */
19
+ export declare class LocalizationProvider implements ILocalizationProvider {
20
+ private _loader;
21
+ /**
22
+ * Constructs a LocalizationProvider.
23
+ * @param _loader Function that loads JSON content given a schema name and locale
24
+ */
25
+ constructor(_loader: (schemaName: string, locale: string) => Promise<SchemaLocalizationJson | undefined>);
26
+ /**
27
+ * Load localization JSON for a given schema and locale.
28
+ */
29
+ getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;
30
+ }
31
+ //# sourceMappingURL=LocalizationProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalizationProvider.d.ts","sourceRoot":"","sources":["../../../src/Localization/LocalizationProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAC;CAClG;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAMpD,OAAO,CAAC,OAAO;IAJ3B;;;OAGG;gBACiB,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAGhH;;OAEG;IACU,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;CAmB9G"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The provider to load the localization JSON files.
3
+ * @beta
4
+ */
5
+ export class LocalizationProvider {
6
+ _loader;
7
+ /**
8
+ * Constructs a LocalizationProvider.
9
+ * @param _loader Function that loads JSON content given a schema name and locale
10
+ */
11
+ constructor(_loader) {
12
+ this._loader = _loader;
13
+ }
14
+ /**
15
+ * Load localization JSON for a given schema and locale.
16
+ */
17
+ async getLocalization(schemaName, locale) {
18
+ const localizationData = await this._loader(schemaName, locale);
19
+ if (localizationData) {
20
+ if (!localizationData.name || !localizationData.locale) {
21
+ throw new Error(`Invalid localization JSON for ${schemaName}:${locale} - missing schema name or locale`);
22
+ }
23
+ if (localizationData.name !== schemaName) {
24
+ throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected schema name "${schemaName}" but got "${localizationData.name}"`);
25
+ }
26
+ if (localizationData.locale !== locale) {
27
+ throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected locale "${locale}" but got "${localizationData.locale}"`);
28
+ }
29
+ }
30
+ return localizationData;
31
+ }
32
+ }
33
+ //# sourceMappingURL=LocalizationProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalizationProvider.js","sourceRoot":"","sources":["../../../src/Localization/LocalizationProvider.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAMX;IAJpB;;;OAGG;IACH,YAAoB,OAA4F;QAA5F,YAAO,GAAP,OAAO,CAAqF;IAChH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB,EAAE,MAAc;QAC7D,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEhE,IAAI,gBAAgB,EAAE,CAAC;YACrB,IAAI,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,IAAI,MAAM,kCAAkC,CAAC,CAAC;YAC3G,CAAC;YAED,IAAI,gBAAgB,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,IAAI,MAAM,4BAA4B,UAAU,cAAc,gBAAgB,CAAC,IAAI,GAAG,CAAC,CAAC;YACtJ,CAAC;YAED,IAAI,gBAAgB,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,IAAI,MAAM,uBAAuB,MAAM,cAAc,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;YAC/I,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF","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 { SchemaLocalizationJson } from \"./LocalizationTypes\";\n\n/**\n * Interface for providing localization JSON files for schemas.\n * @beta\n */\nexport interface ILocalizationProvider {\n /**\n * Load localization JSON for a given schema and locale.\n * @param schemaName The name of the schema\n * @param locale The locale identifier (e.g., \"de\", \"fr\", \"es-CO\")\n * @returns Promise resolving to the localization JSON, or undefined if not found\n */\n getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;\n}\n\n/**\n * The provider to load the localization JSON files.\n * @beta\n */\nexport class LocalizationProvider implements ILocalizationProvider {\n\n /**\n * Constructs a LocalizationProvider.\n * @param _loader Function that loads JSON content given a schema name and locale\n */\n constructor(private _loader: (schemaName: string, locale: string) => Promise<SchemaLocalizationJson | undefined>) {\n }\n\n /**\n * Load localization JSON for a given schema and locale.\n */\n public async getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined> {\n const localizationData = await this._loader(schemaName, locale);\n\n if (localizationData) {\n if (!localizationData.name || !localizationData.locale) {\n throw new Error(`Invalid localization JSON for ${schemaName}:${locale} - missing schema name or locale`);\n }\n\n if (localizationData.name !== schemaName) {\n throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected schema name \"${schemaName}\" but got \"${localizationData.name}\"`);\n }\n\n if (localizationData.locale !== locale) {\n throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected locale \"${locale}\" but got \"${localizationData.locale}\"`);\n }\n }\n\n return localizationData;\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Represents localized label and description for a schema element.
3
+ * @beta
4
+ */
5
+ export interface LocalizedText {
6
+ label?: string;
7
+ description?: string;
8
+ }
9
+ /**
10
+ * Localized text for a schema item
11
+ * @beta
12
+ */
13
+ export interface LocalizedItemText extends LocalizedText {
14
+ /** Localized members keyed by member name */
15
+ members?: {
16
+ [memberName: string]: LocalizedText;
17
+ };
18
+ }
19
+ /**
20
+ * JSON structure for schema localization file.
21
+ * @beta
22
+ */
23
+ export interface SchemaLocalizationJson {
24
+ /** Schema version identifier */
25
+ $schema: string;
26
+ /** Name of the schema this localization applies to */
27
+ name: string;
28
+ /** Version of the schema */
29
+ version: string;
30
+ /** Locale identifier (e.g., "de", "fr", "es-CO") */
31
+ locale: string;
32
+ /** Localized schema label */
33
+ label?: string;
34
+ /** Localized schema description */
35
+ description?: string;
36
+ /** Localized schema items, keyed by item name */
37
+ items?: {
38
+ [itemName: string]: LocalizedItemText;
39
+ };
40
+ }
41
+ //# sourceMappingURL=LocalizationTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalizationTypes.d.ts","sourceRoot":"","sources":["../../../src/Localization/LocalizationTypes.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,6CAA6C;IAC7C,OAAO,CAAC,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,KAAK,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAAA;KAAE,CAAC;CACnD"}
@@ -0,0 +1,6 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ export {};
6
+ //# sourceMappingURL=LocalizationTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalizationTypes.js","sourceRoot":"","sources":["../../../src/Localization/LocalizationTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F","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 * Represents localized label and description for a schema element.\n * @beta\n */\nexport interface LocalizedText {\n label?: string;\n description?: string;\n}\n\n/**\n * Localized text for a schema item\n * @beta\n */\nexport interface LocalizedItemText extends LocalizedText {\n /** Localized members keyed by member name */\n members?: { [memberName: string]: LocalizedText };\n}\n\n/**\n * JSON structure for schema localization file.\n * @beta\n */\nexport interface SchemaLocalizationJson {\n /** Schema version identifier */\n $schema: string;\n /** Name of the schema this localization applies to */\n name: string;\n /** Version of the schema */\n version: string;\n /** Locale identifier (e.g., \"de\", \"fr\", \"es-CO\") */\n locale: string;\n /** Localized schema label */\n label?: string;\n /** Localized schema description */\n description?: string;\n /** Localized schema items, keyed by item name */\n items?: { [itemName: string]: LocalizedItemText };\n}\n"]}
@@ -0,0 +1,94 @@
1
+ import { SchemaKey } from "../SchemaKey";
2
+ import { SchemaView } from "../SchemaView";
3
+ import { Schema } from "../Metadata/Schema";
4
+ import { ECClass } from "../Metadata/Class";
5
+ import { Property } from "../Metadata/Property";
6
+ import { SchemaItem } from "../Metadata/SchemaItem";
7
+ import { ILocalizationProvider } from "./LocalizationProvider";
8
+ import { AnyEnumerator, Enumeration } from "../Metadata/Enumeration";
9
+ import { LocalizedText } from "./LocalizationTypes";
10
+ type SchemaViewItem = SchemaView.Class | SchemaView.Enumeration | SchemaView.KindOfQuantity | SchemaView.PropertyCategory;
11
+ /**
12
+ * Manages schema localization to provide localized labels and descriptions.
13
+ * @beta
14
+ */
15
+ export declare class SchemaLocalization {
16
+ private _provider;
17
+ private _locale;
18
+ private _cache;
19
+ private constructor();
20
+ private get _baseLocale();
21
+ private cacheKey;
22
+ /**
23
+ * Create a SchemaLocalization instance and pre-load localization files for the given schemas.
24
+ * @param provider The localization provider to use for loading localization files
25
+ * @param locale The target locale (e.g., "de", "fr", "es-CO")
26
+ * @param schemas The schemas whose localization should be pre-loaded
27
+ */
28
+ static create(provider: ILocalizationProvider, locale: string, schemaKeys: Iterable<SchemaKey>): Promise<SchemaLocalization>;
29
+ get locale(): string;
30
+ setLocale(locale: string): void;
31
+ /**
32
+ * Get localization provider.
33
+ */
34
+ get provider(): ILocalizationProvider;
35
+ /**
36
+ * Load localizations for the given schema keys.
37
+ * @param schemaKeys The schema keys to load localization for
38
+ */
39
+ loadLocalizations(schemaKeys: Iterable<SchemaKey>): Promise<void>;
40
+ /**
41
+ * Get a localized label for a schema, schema item, or member.
42
+ */
43
+ getLabel(schemaName: string, itemName?: string, memberName?: string): string | undefined;
44
+ /**
45
+ * Get a localized description for a schema, schema item, or member.
46
+ */
47
+ getDescription(schemaName: string, itemName?: string, memberName?: string): string | undefined;
48
+ /**
49
+ * Get localized label and description of a schema.
50
+ * Label fallback: localized label → base locale label → original label → schema name
51
+ * Description fallback: localized description → base locale description → original description
52
+ */
53
+ getLocalizedSchema(schema: Schema | SchemaView.Schema): LocalizedText;
54
+ /**
55
+ * Get localized label and description of a schema item (class, enumeration, unit, etc.).
56
+ * Label fallback: localized label → base locale label → original label → item name
57
+ * Description fallback: localized description → base locale description → original description
58
+ */
59
+ getLocalizedSchemaItem(item: SchemaItem | SchemaViewItem): LocalizedText;
60
+ /**
61
+ * Get localized label and description of a property.
62
+ * Label fallback: localized label → base locale label → original label → property name
63
+ * Description fallback: localized description → base locale description → original description
64
+ */
65
+ getLocalizedProperty(ecClass: ECClass | SchemaView.Class, property: Property | SchemaView.Property): LocalizedText;
66
+ /**
67
+ * Get localized label and description of an enumerator.
68
+ * Label fallback: localized label → base locale label → original label → enumerator name
69
+ * Description fallback: localized description → base locale description → original description
70
+ */
71
+ getLocalizedEnumerator(enumeration: Enumeration | SchemaView.Enumeration, enumerator: AnyEnumerator | SchemaView.Enumerator): LocalizedText;
72
+ /**
73
+ * Load localization information for a specific schema and locale.
74
+ */
75
+ private loadLocalizationInfo;
76
+ /**
77
+ * Get major version from version string
78
+ */
79
+ private getMajorVersion;
80
+ /**
81
+ * Retrieve the cached localization for a locale
82
+ */
83
+ private getCachedLocalization;
84
+ /**
85
+ * Resolve a label from a localization object by item and optional member path.
86
+ */
87
+ private resolveLabel;
88
+ /**
89
+ * Resolve a description from a localization object by item and optional member path.
90
+ */
91
+ private resolveDescription;
92
+ }
93
+ export {};
94
+ //# sourceMappingURL=SchemaLocalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaLocalization.d.ts","sourceRoot":"","sources":["../../../src/Localization/SchemaLocalization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAI5E,KAAK,cAAc,GAAG,UAAU,CAAC,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,UAAU,CAAC,QAAQ,GAAG,aAAa;IAMzH;;;;OAIG;IACI,sBAAsB,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,aAAa,GAAG,UAAU,CAAC,UAAU,GAAG,aAAa;IAMlJ;;OAEG;YACW,oBAAoB;IAkBlC;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;OAEG;IACH,OAAO,CAAC,YAAY;IAWpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAU3B"}
@@ -0,0 +1,193 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { Logger } from "@itwin/core-bentley";
6
+ const loggerCategory = "SchemaLocalization";
7
+ /**
8
+ * Manages schema localization to provide localized labels and descriptions.
9
+ * @beta
10
+ */
11
+ export class SchemaLocalization {
12
+ _provider;
13
+ _locale;
14
+ _cache = new Map();
15
+ constructor(provider, locale) {
16
+ this._provider = provider;
17
+ this._locale = locale;
18
+ }
19
+ get _baseLocale() {
20
+ return this._locale.includes("-") ? this._locale.split("-")[0] : undefined;
21
+ }
22
+ cacheKey(schemaName, locale) {
23
+ return `${schemaName}:${locale}`;
24
+ }
25
+ /**
26
+ * Create a SchemaLocalization instance and pre-load localization files for the given schemas.
27
+ * @param provider The localization provider to use for loading localization files
28
+ * @param locale The target locale (e.g., "de", "fr", "es-CO")
29
+ * @param schemas The schemas whose localization should be pre-loaded
30
+ */
31
+ static async create(provider, locale, schemaKeys) {
32
+ const localization = new SchemaLocalization(provider, locale);
33
+ await localization.loadLocalizations(schemaKeys);
34
+ return localization;
35
+ }
36
+ get locale() {
37
+ return this._locale;
38
+ }
39
+ setLocale(locale) {
40
+ this._locale = locale;
41
+ this._cache.clear();
42
+ }
43
+ /**
44
+ * Get localization provider.
45
+ */
46
+ get provider() {
47
+ return this._provider;
48
+ }
49
+ /**
50
+ * Load localizations for the given schema keys.
51
+ * @param schemaKeys The schema keys to load localization for
52
+ */
53
+ async loadLocalizations(schemaKeys) {
54
+ const promises = [];
55
+ for (const key of schemaKeys) {
56
+ promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._locale));
57
+ if (this._baseLocale !== undefined)
58
+ promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._baseLocale));
59
+ }
60
+ await Promise.all(promises);
61
+ }
62
+ /**
63
+ * Get a localized label for a schema, schema item, or member.
64
+ */
65
+ getLabel(schemaName, itemName, memberName) {
66
+ const localization = this.getCachedLocalization(schemaName, this._locale);
67
+ const label = this.resolveLabel(localization, itemName, memberName);
68
+ if (label)
69
+ return label;
70
+ if (this._baseLocale) {
71
+ const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);
72
+ return this.resolveLabel(baseLocalization, itemName, memberName);
73
+ }
74
+ return undefined;
75
+ }
76
+ /**
77
+ * Get a localized description for a schema, schema item, or member.
78
+ */
79
+ getDescription(schemaName, itemName, memberName) {
80
+ const localization = this.getCachedLocalization(schemaName, this._locale);
81
+ const description = this.resolveDescription(localization, itemName, memberName);
82
+ if (description)
83
+ return description;
84
+ if (this._baseLocale) {
85
+ const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);
86
+ return this.resolveDescription(baseLocalization, itemName, memberName);
87
+ }
88
+ return undefined;
89
+ }
90
+ /**
91
+ * Get localized label and description of a schema.
92
+ * Label fallback: localized label → base locale label → original label → schema name
93
+ * Description fallback: localized description → base locale description → original description
94
+ */
95
+ getLocalizedSchema(schema) {
96
+ const label = this.getLabel(schema.name) ?? (schema.label || schema.name);
97
+ const description = this.getDescription(schema.name) ?? schema.description;
98
+ return { label, description };
99
+ }
100
+ /**
101
+ * Get localized label and description of a schema item (class, enumeration, unit, etc.).
102
+ * Label fallback: localized label → base locale label → original label → item name
103
+ * Description fallback: localized description → base locale description → original description
104
+ */
105
+ getLocalizedSchemaItem(item) {
106
+ const label = this.getLabel(item.schema.name, item.name) ?? (item.label || item.name);
107
+ const description = this.getDescription(item.schema.name, item.name) ?? item.description;
108
+ return { label, description };
109
+ }
110
+ /**
111
+ * Get localized label and description of a property.
112
+ * Label fallback: localized label → base locale label → original label → property name
113
+ * Description fallback: localized description → base locale description → original description
114
+ */
115
+ getLocalizedProperty(ecClass, property) {
116
+ const label = this.getLabel(ecClass.schema.name, ecClass.name, property.name) ?? (property.label || property.name);
117
+ const description = this.getDescription(ecClass.schema.name, ecClass.name, property.name) ?? property.description;
118
+ return { label, description };
119
+ }
120
+ /**
121
+ * Get localized label and description of an enumerator.
122
+ * Label fallback: localized label → base locale label → original label → enumerator name
123
+ * Description fallback: localized description → base locale description → original description
124
+ */
125
+ getLocalizedEnumerator(enumeration, enumerator) {
126
+ const label = this.getLabel(enumeration.schema.name, enumeration.name, enumerator.name) ?? (enumerator.label || enumerator.name);
127
+ const description = this.getDescription(enumeration.schema.name, enumeration.name, enumerator.name) ?? enumerator.description;
128
+ return { label, description };
129
+ }
130
+ /**
131
+ * Load localization information for a specific schema and locale.
132
+ */
133
+ async loadLocalizationInfo(schemaName, readVersion, locale) {
134
+ const cacheKey = this.cacheKey(schemaName, locale);
135
+ if (this._cache.has(cacheKey))
136
+ return;
137
+ const localization = await this._provider.getLocalization(schemaName, locale);
138
+ if (localization?.version) {
139
+ const localizationMajor = this.getMajorVersion(localization.version);
140
+ if (localizationMajor === undefined || readVersion !== localizationMajor) {
141
+ Logger.logWarning(loggerCategory, `Localization version mismatch for schema "${schemaName}". Schema major version is ${readVersion.toString()}, but localization is for major version ${localizationMajor?.toString() ?? "undefined"}.`);
142
+ this._cache.set(cacheKey, undefined);
143
+ return;
144
+ }
145
+ }
146
+ this._cache.set(cacheKey, localization);
147
+ }
148
+ /**
149
+ * Get major version from version string
150
+ */
151
+ getMajorVersion(version) {
152
+ const rawVersion = version.split(".");
153
+ if (rawVersion.length > 0) {
154
+ const majorVersion = parseInt(rawVersion[0], 10);
155
+ return isNaN(majorVersion) ? undefined : majorVersion;
156
+ }
157
+ return undefined;
158
+ }
159
+ /**
160
+ * Retrieve the cached localization for a locale
161
+ */
162
+ getCachedLocalization(schemaName, locale) {
163
+ const cacheKey = this.cacheKey(schemaName, locale);
164
+ return this._cache.get(cacheKey);
165
+ }
166
+ /**
167
+ * Resolve a label from a localization object by item and optional member path.
168
+ */
169
+ resolveLabel(localization, itemName, memberName) {
170
+ if (!localization)
171
+ return undefined;
172
+ if (!itemName)
173
+ return localization.label;
174
+ const item = localization.items?.[itemName];
175
+ if (!memberName)
176
+ return item?.label;
177
+ return item?.members?.[memberName]?.label;
178
+ }
179
+ /**
180
+ * Resolve a description from a localization object by item and optional member path.
181
+ */
182
+ resolveDescription(localization, itemName, memberName) {
183
+ if (!localization)
184
+ return undefined;
185
+ if (!itemName)
186
+ return localization.description;
187
+ const item = localization.items?.[itemName];
188
+ if (!memberName)
189
+ return item?.description;
190
+ return item?.members?.[memberName]?.description;
191
+ }
192
+ }
193
+ //# sourceMappingURL=SchemaLocalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaLocalization.js","sourceRoot":"","sources":["../../../src/Localization/SchemaLocalization.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAM/F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAI5C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,SAAS,CAAwB;IACjC,OAAO,CAAS;IAChB,MAAM,GAAoD,IAAI,GAAG,EAAE,CAAC;IAE5E,YAAoB,QAA+B,EAAE,MAAc;QACjE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC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CAAC;QAClC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU;YACb,OAAO,IAAI,EAAE,WAAW,CAAC;QAC3B,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClD,CAAC;CACF","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 { SchemaKey } from \"../SchemaKey\";\nimport { SchemaView } from \"../SchemaView\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { ECClass } from \"../Metadata/Class\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { Property } from \"../Metadata/Property\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { ILocalizationProvider } from \"./LocalizationProvider\";\nimport { AnyEnumerator, Enumeration } from \"../Metadata/Enumeration\";\nimport { LocalizedText, SchemaLocalizationJson } from \"./LocalizationTypes\";\n\nconst loggerCategory = \"SchemaLocalization\";\n\ntype SchemaViewItem = SchemaView.Class | SchemaView.Enumeration | SchemaView.KindOfQuantity | SchemaView.PropertyCategory;\n\n/**\n * Manages schema localization to provide localized labels and descriptions.\n * @beta\n */\nexport class SchemaLocalization {\n private _provider: ILocalizationProvider;\n private _locale: string;\n private _cache: Map<string, SchemaLocalizationJson | undefined> = new Map();\n\n private constructor(provider: ILocalizationProvider, locale: string) {\n this._provider = provider;\n this._locale = locale;\n }\n\n private get _baseLocale(): string | undefined {\n return this._locale.includes(\"-\") ? this._locale.split(\"-\")[0] : undefined;\n }\n\n private cacheKey(schemaName: string, locale: string): string {\n return `${schemaName}:${locale}`;\n }\n\n /**\n * Create a SchemaLocalization instance and pre-load localization files for the given schemas.\n * @param provider The localization provider to use for loading localization files\n * @param locale The target locale (e.g., \"de\", \"fr\", \"es-CO\")\n * @param schemas The schemas whose localization should be pre-loaded\n */\n public static async create(provider: ILocalizationProvider, locale: string, schemaKeys: Iterable<SchemaKey>): Promise<SchemaLocalization> {\n const localization = new SchemaLocalization(provider, locale);\n await localization.loadLocalizations(schemaKeys);\n return localization;\n }\n\n public get locale(): string {\n return this._locale;\n }\n\n public setLocale(locale: string): void {\n this._locale = locale;\n this._cache.clear();\n }\n\n /**\n * Get localization provider.\n */\n public get provider(): ILocalizationProvider {\n return this._provider;\n }\n\n /**\n * Load localizations for the given schema keys.\n * @param schemaKeys The schema keys to load localization for\n */\n public async loadLocalizations(schemaKeys: Iterable<SchemaKey>): Promise<void> {\n const promises: Promise<void>[] = [];\n for (const key of schemaKeys) {\n promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._locale));\n if (this._baseLocale !== undefined)\n promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._baseLocale));\n }\n await Promise.all(promises);\n }\n\n /**\n * Get a localized label for a schema, schema item, or member.\n */\n public getLabel(schemaName: string, itemName?: string, memberName?: string): string | undefined {\n const localization = this.getCachedLocalization(schemaName, this._locale);\n const label = this.resolveLabel(localization, itemName, memberName);\n if (label)\n return label;\n\n if (this._baseLocale) {\n const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);\n return this.resolveLabel(baseLocalization, itemName, memberName);\n }\n\n return undefined;\n }\n\n /**\n * Get a localized description for a schema, schema item, or member.\n */\n public getDescription(schemaName: string, itemName?: string, memberName?: string): string | undefined {\n const localization = this.getCachedLocalization(schemaName, this._locale);\n const description = this.resolveDescription(localization, itemName, memberName);\n if (description)\n return description;\n\n if (this._baseLocale) {\n const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);\n return this.resolveDescription(baseLocalization, itemName, memberName);\n }\n\n return undefined;\n }\n\n /**\n * Get localized label and description of a schema.\n * Label fallback: localized label → base locale label → original label → schema name\n * Description fallback: localized description → base locale description → original description\n */\n public getLocalizedSchema(schema: Schema | SchemaView.Schema): LocalizedText {\n const label = this.getLabel(schema.name) ?? (schema.label || schema.name);\n const description = this.getDescription(schema.name) ?? schema.description;\n return { label, description };\n }\n\n /**\n * Get localized label and description of a schema item (class, enumeration, unit, etc.).\n * Label fallback: localized label → base locale label → original label → item name\n * Description fallback: localized description → base locale description → original description\n */\n public getLocalizedSchemaItem(item: SchemaItem | SchemaViewItem): LocalizedText {\n const label = this.getLabel(item.schema.name, item.name) ?? (item.label || item.name);\n const description = this.getDescription(item.schema.name, item.name) ?? item.description;\n return { label, description };\n }\n\n /**\n * Get localized label and description of a property.\n * Label fallback: localized label → base locale label → original label → property name\n * Description fallback: localized description → base locale description → original description\n */\n public getLocalizedProperty(ecClass: ECClass | SchemaView.Class, property: Property | SchemaView.Property): LocalizedText {\n const label = this.getLabel(ecClass.schema.name, ecClass.name, property.name) ?? (property.label || property.name);\n const description = this.getDescription(ecClass.schema.name, ecClass.name, property.name) ?? property.description;\n return { label, description };\n }\n\n /**\n * Get localized label and description of an enumerator.\n * Label fallback: localized label → base locale label → original label → enumerator name\n * Description fallback: localized description → base locale description → original description\n */\n public getLocalizedEnumerator(enumeration: Enumeration | SchemaView.Enumeration, enumerator: AnyEnumerator | SchemaView.Enumerator): LocalizedText {\n const label = this.getLabel(enumeration.schema.name, enumeration.name, enumerator.name) ?? (enumerator.label || enumerator.name);\n const description = this.getDescription(enumeration.schema.name, enumeration.name, enumerator.name) ?? enumerator.description;\n return { label, description };\n }\n\n /**\n * Load localization information for a specific schema and locale.\n */\n private async loadLocalizationInfo(schemaName: string, readVersion: number, locale: string): Promise<void> {\n const cacheKey = this.cacheKey(schemaName, locale);\n if (this._cache.has(cacheKey))\n return;\n\n const localization = await this._provider.getLocalization(schemaName, locale);\n if (localization?.version) {\n const localizationMajor = this.getMajorVersion(localization.version);\n if (localizationMajor === undefined || readVersion !== localizationMajor) {\n Logger.logWarning(loggerCategory, `Localization version mismatch for schema \"${schemaName}\". Schema major version is ${readVersion.toString()}, but localization is for major version ${localizationMajor?.toString() ?? \"undefined\"}.`);\n this._cache.set(cacheKey, undefined);\n return;\n }\n }\n\n this._cache.set(cacheKey, localization);\n }\n\n /**\n * Get major version from version string\n */\n private getMajorVersion(version: string): number | undefined {\n const rawVersion = version.split(\".\");\n if (rawVersion.length > 0) {\n const majorVersion = parseInt(rawVersion[0], 10);\n return isNaN(majorVersion) ? undefined : majorVersion;\n }\n return undefined;\n }\n\n /**\n * Retrieve the cached localization for a locale\n */\n private getCachedLocalization(schemaName: string, locale: string): SchemaLocalizationJson | undefined {\n const cacheKey = this.cacheKey(schemaName, locale);\n return this._cache.get(cacheKey);\n }\n\n /**\n * Resolve a label from a localization object by item and optional member path.\n */\n private resolveLabel(localization: SchemaLocalizationJson | undefined, itemName?: string, memberName?: string): string | undefined {\n if (!localization)\n return undefined;\n if (!itemName)\n return localization.label;\n const item = localization.items?.[itemName];\n if (!memberName)\n return item?.label;\n return item?.members?.[memberName]?.label;\n }\n\n /**\n * Resolve a description from a localization object by item and optional member path.\n */\n private resolveDescription(localization: SchemaLocalizationJson | undefined, itemName?: string, memberName?: string): string | undefined {\n if (!localization)\n return undefined;\n if (!itemName)\n return localization.description;\n const item = localization.items?.[itemName];\n if (!memberName)\n return item?.description;\n return item?.members?.[memberName]?.description;\n }\n}\n"]}