@itwin/ecschema-metadata 5.1.0-dev.9 → 5.1.0

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 (268) hide show
  1. package/CHANGELOG.md +88 -1
  2. package/lib/cjs/Constants.js.map +1 -1
  3. package/lib/cjs/Context.d.ts +1 -1
  4. package/lib/cjs/Context.js +1 -1
  5. package/lib/cjs/Context.js.map +1 -1
  6. package/lib/cjs/DelayedPromise.js.map +1 -1
  7. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  8. package/lib/cjs/Deserialization/Helper.d.ts +30 -11
  9. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  10. package/lib/cjs/Deserialization/Helper.js +124 -96
  11. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  12. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  13. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  14. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +12 -3
  15. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts.map +1 -1
  16. package/lib/cjs/Deserialization/SchemaGraphUtil.js +36 -23
  17. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  18. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  19. package/lib/cjs/Deserialization/XmlParser.js +14 -5
  20. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  21. package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
  22. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  23. package/lib/cjs/ECName.js +1 -1
  24. package/lib/cjs/ECName.js.map +1 -1
  25. package/lib/cjs/ECObjects.d.ts +1 -1
  26. package/lib/cjs/ECObjects.js +2 -2
  27. package/lib/cjs/ECObjects.js.map +1 -1
  28. package/lib/cjs/Exception.js.map +1 -1
  29. package/lib/cjs/IncrementalLoading/ClassParsers.d.ts +60 -0
  30. package/lib/cjs/IncrementalLoading/ClassParsers.d.ts.map +1 -0
  31. package/lib/cjs/IncrementalLoading/ClassParsers.js +111 -0
  32. package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -0
  33. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts +211 -0
  34. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -0
  35. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +387 -0
  36. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -0
  37. package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts +14 -0
  38. package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -0
  39. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +609 -0
  40. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -0
  41. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +109 -0
  42. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -0
  43. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +219 -0
  44. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -0
  45. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts +36 -0
  46. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -0
  47. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +77 -0
  48. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -0
  49. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts +60 -0
  50. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts.map +1 -0
  51. package/lib/cjs/IncrementalLoading/PerformanceLogger.js +82 -0
  52. package/lib/cjs/IncrementalLoading/PerformanceLogger.js.map +1 -0
  53. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +51 -0
  54. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -0
  55. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +122 -0
  56. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -0
  57. package/lib/cjs/IncrementalLoading/SchemaItemQueries.d.ts +16 -0
  58. package/lib/cjs/IncrementalLoading/SchemaItemQueries.d.ts.map +1 -0
  59. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +308 -0
  60. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -0
  61. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +42 -0
  62. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -0
  63. package/lib/cjs/IncrementalLoading/SchemaParser.js +109 -0
  64. package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -0
  65. package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts +12 -0
  66. package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -0
  67. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +365 -0
  68. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -0
  69. package/lib/cjs/Interfaces.js.map +1 -1
  70. package/lib/cjs/Metadata/Class.d.ts +5 -16
  71. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  72. package/lib/cjs/Metadata/Class.js +68 -68
  73. package/lib/cjs/Metadata/Class.js.map +1 -1
  74. package/lib/cjs/Metadata/Constant.js.map +1 -1
  75. package/lib/cjs/Metadata/CustomAttribute.d.ts +7 -1
  76. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  77. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  78. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +1 -1
  79. package/lib/cjs/Metadata/CustomAttributeClass.js +1 -1
  80. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  81. package/lib/cjs/Metadata/EntityClass.d.ts +6 -6
  82. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  83. package/lib/cjs/Metadata/EntityClass.js +48 -26
  84. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  85. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  86. package/lib/cjs/Metadata/Format.d.ts +5 -0
  87. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  88. package/lib/cjs/Metadata/Format.js +7 -0
  89. package/lib/cjs/Metadata/Format.js.map +1 -1
  90. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  91. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  92. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  93. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  94. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  95. package/lib/cjs/Metadata/Property.js.map +1 -1
  96. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  97. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  98. package/lib/cjs/Metadata/Schema.d.ts +10 -0
  99. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  100. package/lib/cjs/Metadata/Schema.js +13 -0
  101. package/lib/cjs/Metadata/Schema.js.map +1 -1
  102. package/lib/cjs/Metadata/SchemaItem.d.ts +10 -0
  103. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  104. package/lib/cjs/Metadata/SchemaItem.js +13 -0
  105. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  106. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  107. package/lib/cjs/PropertyTypes.js.map +1 -1
  108. package/lib/cjs/SchemaFormatsProvider.d.ts +4 -3
  109. package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -1
  110. package/lib/cjs/SchemaFormatsProvider.js +60 -17
  111. package/lib/cjs/SchemaFormatsProvider.js.map +1 -1
  112. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  113. package/lib/cjs/SchemaKey.js.map +1 -1
  114. package/lib/cjs/SchemaLoader.d.ts +4 -1
  115. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  116. package/lib/cjs/SchemaLoader.js +4 -1
  117. package/lib/cjs/SchemaLoader.js.map +1 -1
  118. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  119. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  120. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  121. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  122. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  123. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  124. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  125. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  126. package/lib/cjs/ecschema-metadata.d.ts +2 -0
  127. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  128. package/lib/cjs/ecschema-metadata.js +2 -0
  129. package/lib/cjs/ecschema-metadata.js.map +1 -1
  130. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  131. package/lib/cjs/utils/SchemaLoadingController.d.ts +37 -0
  132. package/lib/cjs/utils/SchemaLoadingController.d.ts.map +1 -0
  133. package/lib/cjs/utils/SchemaLoadingController.js +65 -0
  134. package/lib/cjs/utils/SchemaLoadingController.js.map +1 -0
  135. package/lib/esm/Constants.js.map +1 -1
  136. package/lib/esm/Context.d.ts +1 -1
  137. package/lib/esm/Context.js +1 -1
  138. package/lib/esm/Context.js.map +1 -1
  139. package/lib/esm/DelayedPromise.js.map +1 -1
  140. package/lib/esm/Deserialization/AbstractParser.js.map +1 -1
  141. package/lib/esm/Deserialization/Helper.d.ts +30 -11
  142. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  143. package/lib/esm/Deserialization/Helper.js +124 -96
  144. package/lib/esm/Deserialization/Helper.js.map +1 -1
  145. package/lib/esm/Deserialization/JsonParser.js.map +1 -1
  146. package/lib/esm/Deserialization/JsonProps.js.map +1 -1
  147. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts +12 -3
  148. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts.map +1 -1
  149. package/lib/esm/Deserialization/SchemaGraphUtil.js +36 -23
  150. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  151. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  152. package/lib/esm/Deserialization/XmlParser.js +14 -5
  153. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  154. package/lib/esm/Deserialization/XmlSerializationUtils.js +1 -1
  155. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  156. package/lib/esm/ECName.js +1 -1
  157. package/lib/esm/ECName.js.map +1 -1
  158. package/lib/esm/ECObjects.d.ts +1 -1
  159. package/lib/esm/ECObjects.js +2 -2
  160. package/lib/esm/ECObjects.js.map +1 -1
  161. package/lib/esm/Exception.js.map +1 -1
  162. package/lib/esm/IncrementalLoading/ClassParsers.d.ts +60 -0
  163. package/lib/esm/IncrementalLoading/ClassParsers.d.ts.map +1 -0
  164. package/lib/esm/IncrementalLoading/ClassParsers.js +104 -0
  165. package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -0
  166. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts +211 -0
  167. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -0
  168. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +383 -0
  169. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -0
  170. package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts +14 -0
  171. package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -0
  172. package/lib/esm/IncrementalLoading/FullSchemaQueries.js +606 -0
  173. package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -0
  174. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +109 -0
  175. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -0
  176. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +215 -0
  177. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -0
  178. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts +36 -0
  179. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -0
  180. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +73 -0
  181. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -0
  182. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts +60 -0
  183. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts.map +1 -0
  184. package/lib/esm/IncrementalLoading/PerformanceLogger.js +78 -0
  185. package/lib/esm/IncrementalLoading/PerformanceLogger.js.map +1 -0
  186. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +51 -0
  187. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -0
  188. package/lib/esm/IncrementalLoading/SchemaItemParsers.js +117 -0
  189. package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -0
  190. package/lib/esm/IncrementalLoading/SchemaItemQueries.d.ts +16 -0
  191. package/lib/esm/IncrementalLoading/SchemaItemQueries.d.ts.map +1 -0
  192. package/lib/esm/IncrementalLoading/SchemaItemQueries.js +305 -0
  193. package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -0
  194. package/lib/esm/IncrementalLoading/SchemaParser.d.ts +42 -0
  195. package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -0
  196. package/lib/esm/IncrementalLoading/SchemaParser.js +104 -0
  197. package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -0
  198. package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts +12 -0
  199. package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -0
  200. package/lib/esm/IncrementalLoading/SchemaStubQueries.js +359 -0
  201. package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -0
  202. package/lib/esm/Interfaces.js.map +1 -1
  203. package/lib/esm/Metadata/Class.d.ts +5 -16
  204. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  205. package/lib/esm/Metadata/Class.js +68 -68
  206. package/lib/esm/Metadata/Class.js.map +1 -1
  207. package/lib/esm/Metadata/Constant.js.map +1 -1
  208. package/lib/esm/Metadata/CustomAttribute.d.ts +7 -1
  209. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
  210. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  211. package/lib/esm/Metadata/CustomAttributeClass.d.ts +1 -1
  212. package/lib/esm/Metadata/CustomAttributeClass.js +1 -1
  213. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  214. package/lib/esm/Metadata/EntityClass.d.ts +6 -6
  215. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  216. package/lib/esm/Metadata/EntityClass.js +48 -26
  217. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  218. package/lib/esm/Metadata/Enumeration.js.map +1 -1
  219. package/lib/esm/Metadata/Format.d.ts +5 -0
  220. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  221. package/lib/esm/Metadata/Format.js +7 -0
  222. package/lib/esm/Metadata/Format.js.map +1 -1
  223. package/lib/esm/Metadata/InvertedUnit.js.map +1 -1
  224. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  225. package/lib/esm/Metadata/Mixin.js.map +1 -1
  226. package/lib/esm/Metadata/OverrideFormat.js.map +1 -1
  227. package/lib/esm/Metadata/Phenomenon.js.map +1 -1
  228. package/lib/esm/Metadata/Property.js.map +1 -1
  229. package/lib/esm/Metadata/PropertyCategory.js.map +1 -1
  230. package/lib/esm/Metadata/RelationshipClass.js.map +1 -1
  231. package/lib/esm/Metadata/Schema.d.ts +10 -0
  232. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  233. package/lib/esm/Metadata/Schema.js +13 -0
  234. package/lib/esm/Metadata/Schema.js.map +1 -1
  235. package/lib/esm/Metadata/SchemaItem.d.ts +10 -0
  236. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  237. package/lib/esm/Metadata/SchemaItem.js +13 -0
  238. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  239. package/lib/esm/Metadata/UnitSystem.js.map +1 -1
  240. package/lib/esm/PropertyTypes.js.map +1 -1
  241. package/lib/esm/SchemaFormatsProvider.d.ts +4 -3
  242. package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -1
  243. package/lib/esm/SchemaFormatsProvider.js +61 -18
  244. package/lib/esm/SchemaFormatsProvider.js.map +1 -1
  245. package/lib/esm/SchemaJsonLocater.js.map +1 -1
  246. package/lib/esm/SchemaKey.js.map +1 -1
  247. package/lib/esm/SchemaLoader.d.ts +4 -1
  248. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  249. package/lib/esm/SchemaLoader.js +4 -1
  250. package/lib/esm/SchemaLoader.js.map +1 -1
  251. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -1
  252. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  253. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  254. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  255. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -1
  256. package/lib/esm/UnitConversion/UnitTree.js.map +1 -1
  257. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -1
  258. package/lib/esm/Validation/SchemaWalker.js.map +1 -1
  259. package/lib/esm/ecschema-metadata.d.ts +2 -0
  260. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  261. package/lib/esm/ecschema-metadata.js +2 -0
  262. package/lib/esm/ecschema-metadata.js.map +1 -1
  263. package/lib/esm/utils/SchemaGraph.js.map +1 -1
  264. package/lib/esm/utils/SchemaLoadingController.d.ts +37 -0
  265. package/lib/esm/utils/SchemaLoadingController.d.ts.map +1 -0
  266. package/lib/esm/utils/SchemaLoadingController.js +61 -0
  267. package/lib/esm/utils/SchemaLoadingController.js.map +1 -0
  268. package/package.json +15 -10
@@ -0,0 +1,211 @@
1
+ import { SchemaContext } from "../Context";
2
+ import { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemUnitProps, SchemaProps, StructClassProps, UnitSystemProps } from "../Deserialization/JsonProps";
3
+ import { SchemaInfo } from "../Interfaces";
4
+ import { SchemaKey } from "../SchemaKey";
5
+ import { IncrementalSchemaLocater, SchemaLocaterOptions } from "./IncrementalSchemaLocater";
6
+ import { PerformanceLogger } from "./PerformanceLogger";
7
+ interface QueryParameters {
8
+ [parameterName: string]: string | number;
9
+ }
10
+ /**
11
+ * Query options used by the ECSqlSchemaLocater.
12
+ * @internal
13
+ */
14
+ export interface ECSqlQueryOptions {
15
+ parameters?: QueryParameters;
16
+ limit?: number;
17
+ }
18
+ /**
19
+ * Defines the [[ECSqlSchemaLocater]] options which determine how each
20
+ * schema is to be loaded. All options are optional.
21
+ * @internal
22
+ */
23
+ export interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {
24
+ /** Query for Schemas using multiple queries. Defaults to false. */
25
+ readonly useMultipleQueries?: boolean;
26
+ /** Collects query execution performance data. Defaults to false. */
27
+ readonly performanceLogger?: PerformanceLogger;
28
+ }
29
+ /**
30
+ * An abstract [[IncrementalSchemaLocater]] implementation for loading
31
+ * EC [Schema] instances from an iModelDb using ECSql queries.
32
+ * @internal
33
+ */
34
+ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {
35
+ /**
36
+ * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.
37
+ */
38
+ protected get options(): ECSqlSchemaLocaterOptions;
39
+ /**
40
+ * Initializes a new ECSqlSchemaLocater instance.
41
+ * @param options The options used by this Schema locater.
42
+ */
43
+ constructor(options?: ECSqlSchemaLocaterOptions);
44
+ /**
45
+ * Executes the given ECSql query and returns the resulting rows.
46
+ * @param query The ECSql query to execute.
47
+ * @param options Optional arguments to control the query result.
48
+ * @returns A promise that resolves to the resulting rows.
49
+ */
50
+ protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;
51
+ /**
52
+ * Gets the [[SchemaProps]] for the given schema key.
53
+ * @param schemaKey The schema key of the schema to be resolved.
54
+ */
55
+ protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>;
56
+ /**
57
+ * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined
58
+ * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.
59
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
60
+ * @param context The [[SchemaContext]] to use for resolving references.
61
+ * @internal
62
+ */
63
+ getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined>;
64
+ /**
65
+ * Gets the [[SchemaProps]] without schemaItems.
66
+ */
67
+ /**
68
+ * Gets the [[SchemaProps]] without schemaItems for the given schema name.
69
+ * @param schemaName The name of the Schema.
70
+ * @param context The [[SchemaContext]] to use for resolving references.
71
+ * @returns
72
+ * @internal
73
+ */
74
+ getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined>;
75
+ /**
76
+ * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
77
+ * @param context The schema context to lookup the meta schema.
78
+ * @returns true if the context has a supported meta schema version, false otherwise.
79
+ */
80
+ protected supportPartialSchemaLoading(context: SchemaContext): Promise<boolean>;
81
+ /**
82
+ * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.
83
+ * @param schemaName The name of the Schema.
84
+ * @param context The [[SchemaContext]] to which the schema belongs.
85
+ * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.
86
+ * @internal
87
+ */
88
+ getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]>;
89
+ /**
90
+ * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.
91
+ * @param schemaName The name of the Schema.
92
+ * @param context The SchemaContext to which the schema belongs.
93
+ * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.
94
+ * @internal
95
+ */
96
+ getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]>;
97
+ /**
98
+ * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.
99
+ * @param schemaName The name of the Schema.
100
+ * @param context The SchemaContext to which the schema belongs.
101
+ * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.
102
+ * @internal
103
+ */
104
+ getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]>;
105
+ /**
106
+ * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.
107
+ * @param schemaName The name of the Schema.
108
+ * @param context The SchemaContext to which the schema belongs.
109
+ * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.
110
+ * @internal
111
+ */
112
+ getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]>;
113
+ /**
114
+ * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.
115
+ * @param schemaName The name of the Schema.
116
+ * @param context The SchemaContext to which the schema belongs.
117
+ * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.
118
+ * @internal
119
+ */
120
+ getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]>;
121
+ /**
122
+ * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.
123
+ * @param schema The name of the Schema.
124
+ * @param context The SchemaContext to which the schema belongs.
125
+ * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.
126
+ * @internal
127
+ */
128
+ getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]>;
129
+ /**
130
+ * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.
131
+ * @param schema The name of the Schema.
132
+ * @param context The SchemaContext to which the schema belongs.
133
+ * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.
134
+ * @internal
135
+ */
136
+ getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]>;
137
+ /**
138
+ * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.
139
+ * @param schema The name of the Schema.
140
+ * @param context The SchemaContext to which the schema belongs.
141
+ * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.
142
+ * @internal
143
+ */
144
+ getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]>;
145
+ /**
146
+ * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.
147
+ * @param schema The name of the Schema.
148
+ * @param context The SchemaContext to which the schema belongs.
149
+ * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.
150
+ * @internal
151
+ */
152
+ getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]>;
153
+ /**
154
+ * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.
155
+ * @param schema The name of the Schema.
156
+ * @param context The SchemaContext to which the schema belongs.
157
+ * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.
158
+ * @internal
159
+ */
160
+ getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]>;
161
+ /**
162
+ * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.
163
+ * @param schema The name of the Schema.
164
+ * @param context The SchemaContext to which the schema belongs.
165
+ * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.
166
+ * @internal
167
+ */
168
+ getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]>;
169
+ /**
170
+ * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.
171
+ * @param schema The name of the Schema.
172
+ * @param context The SchemaContext to which the schema belongs.
173
+ * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.
174
+ * @internal
175
+ */
176
+ getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]>;
177
+ /**
178
+ * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.
179
+ * @param schema The name of the Schema.
180
+ * @param context The SchemaContext to which the schema belongs.
181
+ * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.
182
+ * @internal
183
+ */
184
+ getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]>;
185
+ /**
186
+ * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.
187
+ * @param schema The name of the Schema.
188
+ * @param context The SchemaContext to which the schema belongs.
189
+ * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.
190
+ * @internal
191
+ */
192
+ getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]>;
193
+ /**
194
+ * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.
195
+ * @internal
196
+ */
197
+ loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>>;
198
+ /**
199
+ * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy
200
+ * can be included in the initial fetch.
201
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
202
+ * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].
203
+ * @internal
204
+ */
205
+ getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined>;
206
+ private querySchemaItem;
207
+ private getFullSchema;
208
+ private getFullSchemaMultipleQueries;
209
+ }
210
+ export {};
211
+ //# sourceMappingURL=ECSqlSchemaLocater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ECSqlSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ECSqlSchemaLocater = void 0;
8
+ const ECObjects_1 = require("../ECObjects");
9
+ const SchemaKey_1 = require("../SchemaKey");
10
+ const FullSchemaQueries_1 = require("./FullSchemaQueries");
11
+ const IncrementalSchemaLocater_1 = require("./IncrementalSchemaLocater");
12
+ const SchemaItemQueries_1 = require("./SchemaItemQueries");
13
+ const SchemaParser_1 = require("./SchemaParser");
14
+ const SchemaStubQueries_1 = require("./SchemaStubQueries");
15
+ /**
16
+ * An abstract [[IncrementalSchemaLocater]] implementation for loading
17
+ * EC [Schema] instances from an iModelDb using ECSql queries.
18
+ * @internal
19
+ */
20
+ class ECSqlSchemaLocater extends IncrementalSchemaLocater_1.IncrementalSchemaLocater {
21
+ /**
22
+ * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.
23
+ */
24
+ get options() {
25
+ return super.options;
26
+ }
27
+ /**
28
+ * Initializes a new ECSqlSchemaLocater instance.
29
+ * @param options The options used by this Schema locater.
30
+ */
31
+ constructor(options) {
32
+ super(options);
33
+ }
34
+ /**
35
+ * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined
36
+ * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.
37
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
38
+ * @param context The [[SchemaContext]] to use for resolving references.
39
+ * @internal
40
+ */
41
+ async getSchemaJson(schemaKey, context) {
42
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
43
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
44
+ // to fetch the whole schema json.
45
+ if (!await this.supportPartialSchemaLoading(context))
46
+ return this.getSchemaProps(schemaKey);
47
+ const start = Date.now();
48
+ const schemaProps = this.options.useMultipleQueries
49
+ ? await this.getFullSchemaMultipleQueries(schemaKey, context)
50
+ : await this.getFullSchema(schemaKey, context);
51
+ this.options.performanceLogger?.logSchema(start, schemaKey.name);
52
+ return schemaProps;
53
+ }
54
+ ;
55
+ /**
56
+ * Gets the [[SchemaProps]] without schemaItems.
57
+ */
58
+ /**
59
+ * Gets the [[SchemaProps]] without schemaItems for the given schema name.
60
+ * @param schemaName The name of the Schema.
61
+ * @param context The [[SchemaContext]] to use for resolving references.
62
+ * @returns
63
+ * @internal
64
+ */
65
+ async getSchemaNoItems(schemaName, context) {
66
+ const schemaRows = await this.executeQuery(FullSchemaQueries_1.FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });
67
+ const schemaRow = schemaRows[0];
68
+ if (schemaRow === undefined)
69
+ return undefined;
70
+ const schema = JSON.parse(schemaRow.schema);
71
+ return SchemaParser_1.SchemaParser.parse(schema, context);
72
+ }
73
+ /**
74
+ * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
75
+ * @param context The schema context to lookup the meta schema.
76
+ * @returns true if the context has a supported meta schema version, false otherwise.
77
+ */
78
+ async supportPartialSchemaLoading(context) {
79
+ const metaSchemaKey = new SchemaKey_1.SchemaKey("ECDbMeta", 4, 0, 3);
80
+ const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, ECObjects_1.SchemaMatchType.LatestWriteCompatible);
81
+ return metaSchemaInfo !== undefined;
82
+ }
83
+ ;
84
+ /**
85
+ * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.
86
+ * @param schemaName The name of the Schema.
87
+ * @param context The [[SchemaContext]] to which the schema belongs.
88
+ * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.
89
+ * @internal
90
+ */
91
+ async getEntities(schema, context, queryOverride) {
92
+ const query = queryOverride ?? FullSchemaQueries_1.FullSchemaQueries.entityQuery;
93
+ return this.querySchemaItem(context, schema, query, "EntityClass");
94
+ }
95
+ /**
96
+ * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.
97
+ * @param schemaName The name of the Schema.
98
+ * @param context The SchemaContext to which the schema belongs.
99
+ * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.
100
+ * @internal
101
+ */
102
+ async getMixins(schema, context, queryOverride) {
103
+ const query = queryOverride ?? FullSchemaQueries_1.FullSchemaQueries.mixinQuery;
104
+ return this.querySchemaItem(context, schema, query, "Mixin");
105
+ }
106
+ /**
107
+ * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.
108
+ * @param schemaName The name of the Schema.
109
+ * @param context The SchemaContext to which the schema belongs.
110
+ * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.
111
+ * @internal
112
+ */
113
+ async getRelationships(schema, context, queryOverride) {
114
+ const query = queryOverride ?? FullSchemaQueries_1.FullSchemaQueries.relationshipClassQuery;
115
+ return this.querySchemaItem(context, schema, query, "RelationshipClass");
116
+ }
117
+ /**
118
+ * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.
119
+ * @param schemaName The name of the Schema.
120
+ * @param context The SchemaContext to which the schema belongs.
121
+ * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.
122
+ * @internal
123
+ */
124
+ async getCustomAttributeClasses(schema, context, queryOverride) {
125
+ const query = queryOverride ?? FullSchemaQueries_1.FullSchemaQueries.customAttributeQuery;
126
+ return this.querySchemaItem(context, schema, query, "CustomAttributeClass");
127
+ }
128
+ /**
129
+ * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.
130
+ * @param schemaName The name of the Schema.
131
+ * @param context The SchemaContext to which the schema belongs.
132
+ * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.
133
+ * @internal
134
+ */
135
+ async getStructs(schema, context, queryOverride) {
136
+ const query = queryOverride ?? FullSchemaQueries_1.FullSchemaQueries.structQuery;
137
+ return this.querySchemaItem(context, schema, query, "StructClass");
138
+ }
139
+ /**
140
+ * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.
141
+ * @param schema The name of the Schema.
142
+ * @param context The SchemaContext to which the schema belongs.
143
+ * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.
144
+ * @internal
145
+ */
146
+ async getKindOfQuantities(schema, context) {
147
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.kindOfQuantity(true), "KindOfQuantity");
148
+ }
149
+ /**
150
+ * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.
151
+ * @param schema The name of the Schema.
152
+ * @param context The SchemaContext to which the schema belongs.
153
+ * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.
154
+ * @internal
155
+ */
156
+ async getPropertyCategories(schema, context) {
157
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.propertyCategory(true), "PropertyCategory");
158
+ }
159
+ /**
160
+ * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.
161
+ * @param schema The name of the Schema.
162
+ * @param context The SchemaContext to which the schema belongs.
163
+ * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.
164
+ * @internal
165
+ */
166
+ async getEnumerations(schema, context) {
167
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.enumeration(true), "Enumeration");
168
+ }
169
+ /**
170
+ * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.
171
+ * @param schema The name of the Schema.
172
+ * @param context The SchemaContext to which the schema belongs.
173
+ * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.
174
+ * @internal
175
+ */
176
+ async getUnits(schema, context) {
177
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.unit(true), "Unit");
178
+ }
179
+ /**
180
+ * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.
181
+ * @param schema The name of the Schema.
182
+ * @param context The SchemaContext to which the schema belongs.
183
+ * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.
184
+ * @internal
185
+ */
186
+ async getInvertedUnits(schema, context) {
187
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.invertedUnit(true), "InvertedUnit");
188
+ }
189
+ /**
190
+ * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.
191
+ * @param schema The name of the Schema.
192
+ * @param context The SchemaContext to which the schema belongs.
193
+ * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.
194
+ * @internal
195
+ */
196
+ async getConstants(schema, context) {
197
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.constant(true), "Constant");
198
+ }
199
+ /**
200
+ * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.
201
+ * @param schema The name of the Schema.
202
+ * @param context The SchemaContext to which the schema belongs.
203
+ * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.
204
+ * @internal
205
+ */
206
+ async getUnitSystems(schema, context) {
207
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.unitSystem(true), "UnitSystem");
208
+ }
209
+ /**
210
+ * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.
211
+ * @param schema The name of the Schema.
212
+ * @param context The SchemaContext to which the schema belongs.
213
+ * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.
214
+ * @internal
215
+ */
216
+ async getPhenomenon(schema, context) {
217
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.phenomenon(true), "Phenomenon");
218
+ }
219
+ /**
220
+ * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.
221
+ * @param schema The name of the Schema.
222
+ * @param context The SchemaContext to which the schema belongs.
223
+ * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.
224
+ * @internal
225
+ */
226
+ async getFormats(schema, context) {
227
+ return this.querySchemaItem(context, schema, SchemaItemQueries_1.SchemaItemQueries.format(true), "Format");
228
+ }
229
+ /**
230
+ * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.
231
+ * @internal
232
+ */
233
+ async loadSchemaInfos() {
234
+ const schemaRows = await this.executeQuery(SchemaStubQueries_1.ecsqlQueries.schemaInfoQuery);
235
+ return schemaRows.map((schemaRow) => ({
236
+ alias: schemaRow.alias,
237
+ schemaKey: SchemaKey_1.SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),
238
+ references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),
239
+ }));
240
+ }
241
+ /**
242
+ * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy
243
+ * can be included in the initial fetch.
244
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
245
+ * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].
246
+ * @internal
247
+ */
248
+ async getSchemaPartials(schemaKey, context) {
249
+ const [schemaRow] = await this.executeQuery(SchemaStubQueries_1.ecsqlQueries.schemaStubQuery, {
250
+ parameters: { schemaName: schemaKey.name },
251
+ limit: 1
252
+ });
253
+ if (!schemaRow)
254
+ return undefined;
255
+ const schemaPartials = [];
256
+ const addSchema = async (key) => {
257
+ const stub = await this.createSchemaProps(key, context);
258
+ schemaPartials.push(stub);
259
+ if (stub.references) {
260
+ for (const referenceProps of stub.references) {
261
+ if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {
262
+ await addSchema(SchemaKey_1.SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));
263
+ }
264
+ }
265
+ }
266
+ return stub;
267
+ };
268
+ const addItems = async (schemaName, itemInfo) => {
269
+ let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);
270
+ if (!schemaStub) {
271
+ schemaStub = await addSchema(SchemaKey_1.SchemaKey.parseString(`${schemaName}.0.0.0`));
272
+ }
273
+ if (!schemaStub.items) {
274
+ Object.assign(schemaStub, { items: {} });
275
+ }
276
+ const existingItem = schemaStub.items[itemInfo.name] || {};
277
+ Object.assign(schemaStub.items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });
278
+ };
279
+ const reviver = (_key, value) => {
280
+ if (value === null) {
281
+ return undefined;
282
+ }
283
+ return value;
284
+ };
285
+ await addSchema(schemaKey);
286
+ await parseSchemaItemStubs(schemaKey.name, context, JSON.parse(schemaRow.items, reviver), addItems);
287
+ return schemaPartials;
288
+ }
289
+ async querySchemaItem(context, schemaName, query, schemaType) {
290
+ const start = Date.now();
291
+ const itemRows = await this.executeQuery(query, { parameters: { schemaName } });
292
+ this.options.performanceLogger?.logSchemaItem(start, schemaName, schemaType, itemRows.length);
293
+ if (itemRows.length === 0)
294
+ return [];
295
+ const items = itemRows.map((itemRow) => {
296
+ return "string" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;
297
+ });
298
+ return await SchemaParser_1.SchemaParser.parseSchemaItems(items, schemaName, context) ?? [];
299
+ }
300
+ async getFullSchema(schemaKey, context) {
301
+ const schemaRows = await this.executeQuery(FullSchemaQueries_1.FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });
302
+ const schemaRow = schemaRows[0];
303
+ if (schemaRow === undefined)
304
+ return undefined;
305
+ // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.
306
+ const schema = JSON.parse(schemaRow.schema);
307
+ if (schema.items) {
308
+ schema.items = schema.items.map((itemRow) => { return itemRow.item; });
309
+ }
310
+ return SchemaParser_1.SchemaParser.parse(schema, context);
311
+ }
312
+ async getFullSchemaMultipleQueries(schemaKey, context) {
313
+ const schema = await this.getSchemaNoItems(schemaKey.name, context);
314
+ if (!schema)
315
+ return undefined;
316
+ schema.items = {};
317
+ await Promise.all([
318
+ this.getEntities(schemaKey.name, context),
319
+ this.getMixins(schemaKey.name, context),
320
+ this.getStructs(schemaKey.name, context),
321
+ this.getRelationships(schemaKey.name, context),
322
+ this.getCustomAttributeClasses(schemaKey.name, context),
323
+ this.getKindOfQuantities(schemaKey.name, context),
324
+ this.getPropertyCategories(schemaKey.name, context),
325
+ this.getEnumerations(schemaKey.name, context),
326
+ this.getUnits(schemaKey.name, context),
327
+ this.getInvertedUnits(schemaKey.name, context),
328
+ this.getUnitSystems(schemaKey.name, context),
329
+ this.getConstants(schemaKey.name, context),
330
+ this.getPhenomenon(schemaKey.name, context),
331
+ this.getFormats(schemaKey.name, context)
332
+ ]).then((itemResults) => {
333
+ const flatItemList = itemResults.reduce((acc, item) => acc.concat(item));
334
+ flatItemList.forEach((schemaItem) => {
335
+ schema.items[schemaItem.name] = schemaItem;
336
+ });
337
+ });
338
+ return schema;
339
+ }
340
+ }
341
+ exports.ECSqlSchemaLocater = ECSqlSchemaLocater;
342
+ function parseSchemaReference(referenceName) {
343
+ return { schemaKey: SchemaKey_1.SchemaKey.parseString(referenceName) };
344
+ }
345
+ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandler) {
346
+ if (!itemRows || itemRows.length === 0) {
347
+ return;
348
+ }
349
+ const parseBaseClasses = async (baseClasses) => {
350
+ if (!baseClasses || baseClasses.length < 2)
351
+ return;
352
+ for (let index = baseClasses.length - 1; index >= 0;) {
353
+ const currentItem = baseClasses[index--];
354
+ const baseClassItem = baseClasses[index];
355
+ const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;
356
+ const schemaItem = await SchemaParser_1.SchemaParser.parseItem(currentItem, currentItem.schema, context);
357
+ await addItemsHandler(currentItem.schema, {
358
+ ...schemaItem,
359
+ name: schemaItem.name,
360
+ schemaItemType: (0, ECObjects_1.parseSchemaItemType)(schemaItem.schemaItemType),
361
+ baseClass: baseClassName,
362
+ });
363
+ }
364
+ };
365
+ for (const itemRow of itemRows) {
366
+ const schemaItem = await SchemaParser_1.SchemaParser.parseItem(itemRow, schemaName, context);
367
+ await addItemsHandler(schemaName, {
368
+ ...schemaItem,
369
+ name: schemaItem.name,
370
+ schemaItemType: (0, ECObjects_1.parseSchemaItemType)(schemaItem.schemaItemType),
371
+ mixins: itemRow.mixins
372
+ ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })
373
+ : undefined,
374
+ });
375
+ await parseBaseClasses(itemRow.baseClasses);
376
+ for (const mixinRow of itemRow.mixins || []) {
377
+ const mixinItem = await SchemaParser_1.SchemaParser.parseItem(mixinRow, mixinRow.schema, context);
378
+ await addItemsHandler(mixinRow.schema, {
379
+ ...mixinItem,
380
+ name: mixinItem.name,
381
+ schemaItemType: (0, ECObjects_1.parseSchemaItemType)(mixinItem.schemaItemType),
382
+ });
383
+ await parseBaseClasses(mixinRow.baseClasses);
384
+ }
385
+ }
386
+ }
387
+ //# sourceMappingURL=ECSqlSchemaLocater.js.map