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

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 (210) hide show
  1. package/CHANGELOG.md +74 -1
  2. package/lib/cjs/Context.d.ts +1 -1
  3. package/lib/cjs/Context.js +1 -1
  4. package/lib/cjs/Context.js.map +1 -1
  5. package/lib/cjs/Deserialization/Helper.d.ts +30 -11
  6. package/lib/cjs/Deserialization/Helper.d.ts.map +1 -1
  7. package/lib/cjs/Deserialization/Helper.js +124 -96
  8. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  9. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +12 -3
  10. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts.map +1 -1
  11. package/lib/cjs/Deserialization/SchemaGraphUtil.js +36 -23
  12. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  13. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  14. package/lib/cjs/Deserialization/XmlParser.js +14 -5
  15. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  16. package/lib/cjs/Deserialization/XmlSerializationUtils.js +1 -1
  17. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  18. package/lib/cjs/ECName.js +1 -1
  19. package/lib/cjs/ECName.js.map +1 -1
  20. package/lib/cjs/ECObjects.d.ts +1 -1
  21. package/lib/cjs/ECObjects.js +2 -2
  22. package/lib/cjs/ECObjects.js.map +1 -1
  23. package/lib/cjs/IncrementalLoading/ClassParsers.d.ts +60 -0
  24. package/lib/cjs/IncrementalLoading/ClassParsers.d.ts.map +1 -0
  25. package/lib/cjs/IncrementalLoading/ClassParsers.js +111 -0
  26. package/lib/cjs/IncrementalLoading/ClassParsers.js.map +1 -0
  27. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts +211 -0
  28. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -0
  29. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +387 -0
  30. package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -0
  31. package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts +14 -0
  32. package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -0
  33. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +609 -0
  34. package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -0
  35. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +109 -0
  36. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -0
  37. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +219 -0
  38. package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -0
  39. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts +36 -0
  40. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -0
  41. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +77 -0
  42. package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -0
  43. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts +60 -0
  44. package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts.map +1 -0
  45. package/lib/cjs/IncrementalLoading/PerformanceLogger.js +82 -0
  46. package/lib/cjs/IncrementalLoading/PerformanceLogger.js.map +1 -0
  47. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +51 -0
  48. package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -0
  49. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +122 -0
  50. package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -0
  51. package/lib/cjs/IncrementalLoading/SchemaItemQueries.d.ts +16 -0
  52. package/lib/cjs/IncrementalLoading/SchemaItemQueries.d.ts.map +1 -0
  53. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +308 -0
  54. package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -0
  55. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +42 -0
  56. package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -0
  57. package/lib/cjs/IncrementalLoading/SchemaParser.js +109 -0
  58. package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -0
  59. package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts +12 -0
  60. package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -0
  61. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +365 -0
  62. package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -0
  63. package/lib/cjs/Metadata/Class.d.ts +5 -16
  64. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  65. package/lib/cjs/Metadata/Class.js +68 -68
  66. package/lib/cjs/Metadata/Class.js.map +1 -1
  67. package/lib/cjs/Metadata/CustomAttribute.d.ts +7 -1
  68. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  69. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  70. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +1 -1
  71. package/lib/cjs/Metadata/CustomAttributeClass.js +1 -1
  72. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  73. package/lib/cjs/Metadata/EntityClass.d.ts +6 -6
  74. package/lib/cjs/Metadata/EntityClass.d.ts.map +1 -1
  75. package/lib/cjs/Metadata/EntityClass.js +48 -26
  76. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  77. package/lib/cjs/Metadata/Format.d.ts +5 -0
  78. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  79. package/lib/cjs/Metadata/Format.js +7 -0
  80. package/lib/cjs/Metadata/Format.js.map +1 -1
  81. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  82. package/lib/cjs/Metadata/Schema.d.ts +10 -0
  83. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  84. package/lib/cjs/Metadata/Schema.js +13 -0
  85. package/lib/cjs/Metadata/Schema.js.map +1 -1
  86. package/lib/cjs/Metadata/SchemaItem.d.ts +10 -0
  87. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  88. package/lib/cjs/Metadata/SchemaItem.js +13 -0
  89. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  90. package/lib/cjs/SchemaFormatsProvider.d.ts +4 -3
  91. package/lib/cjs/SchemaFormatsProvider.d.ts.map +1 -1
  92. package/lib/cjs/SchemaFormatsProvider.js +60 -17
  93. package/lib/cjs/SchemaFormatsProvider.js.map +1 -1
  94. package/lib/cjs/SchemaLoader.d.ts +4 -1
  95. package/lib/cjs/SchemaLoader.d.ts.map +1 -1
  96. package/lib/cjs/SchemaLoader.js +4 -1
  97. package/lib/cjs/SchemaLoader.js.map +1 -1
  98. package/lib/cjs/ecschema-metadata.d.ts +2 -0
  99. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  100. package/lib/cjs/ecschema-metadata.js +2 -0
  101. package/lib/cjs/ecschema-metadata.js.map +1 -1
  102. package/lib/cjs/utils/SchemaLoadingController.d.ts +37 -0
  103. package/lib/cjs/utils/SchemaLoadingController.d.ts.map +1 -0
  104. package/lib/cjs/utils/SchemaLoadingController.js +65 -0
  105. package/lib/cjs/utils/SchemaLoadingController.js.map +1 -0
  106. package/lib/esm/Context.d.ts +1 -1
  107. package/lib/esm/Context.js +1 -1
  108. package/lib/esm/Context.js.map +1 -1
  109. package/lib/esm/Deserialization/Helper.d.ts +30 -11
  110. package/lib/esm/Deserialization/Helper.d.ts.map +1 -1
  111. package/lib/esm/Deserialization/Helper.js +124 -96
  112. package/lib/esm/Deserialization/Helper.js.map +1 -1
  113. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts +12 -3
  114. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts.map +1 -1
  115. package/lib/esm/Deserialization/SchemaGraphUtil.js +36 -23
  116. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -1
  117. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -1
  118. package/lib/esm/Deserialization/XmlParser.js +14 -5
  119. package/lib/esm/Deserialization/XmlParser.js.map +1 -1
  120. package/lib/esm/Deserialization/XmlSerializationUtils.js +1 -1
  121. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -1
  122. package/lib/esm/ECName.js +1 -1
  123. package/lib/esm/ECName.js.map +1 -1
  124. package/lib/esm/ECObjects.d.ts +1 -1
  125. package/lib/esm/ECObjects.js +2 -2
  126. package/lib/esm/ECObjects.js.map +1 -1
  127. package/lib/esm/IncrementalLoading/ClassParsers.d.ts +60 -0
  128. package/lib/esm/IncrementalLoading/ClassParsers.d.ts.map +1 -0
  129. package/lib/esm/IncrementalLoading/ClassParsers.js +104 -0
  130. package/lib/esm/IncrementalLoading/ClassParsers.js.map +1 -0
  131. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts +211 -0
  132. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -0
  133. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +383 -0
  134. package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -0
  135. package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts +14 -0
  136. package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -0
  137. package/lib/esm/IncrementalLoading/FullSchemaQueries.js +606 -0
  138. package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -0
  139. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +109 -0
  140. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -0
  141. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +215 -0
  142. package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -0
  143. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts +36 -0
  144. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -0
  145. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +73 -0
  146. package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -0
  147. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts +60 -0
  148. package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts.map +1 -0
  149. package/lib/esm/IncrementalLoading/PerformanceLogger.js +78 -0
  150. package/lib/esm/IncrementalLoading/PerformanceLogger.js.map +1 -0
  151. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +51 -0
  152. package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -0
  153. package/lib/esm/IncrementalLoading/SchemaItemParsers.js +117 -0
  154. package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -0
  155. package/lib/esm/IncrementalLoading/SchemaItemQueries.d.ts +16 -0
  156. package/lib/esm/IncrementalLoading/SchemaItemQueries.d.ts.map +1 -0
  157. package/lib/esm/IncrementalLoading/SchemaItemQueries.js +305 -0
  158. package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -0
  159. package/lib/esm/IncrementalLoading/SchemaParser.d.ts +42 -0
  160. package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -0
  161. package/lib/esm/IncrementalLoading/SchemaParser.js +104 -0
  162. package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -0
  163. package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts +12 -0
  164. package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -0
  165. package/lib/esm/IncrementalLoading/SchemaStubQueries.js +359 -0
  166. package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -0
  167. package/lib/esm/Metadata/Class.d.ts +5 -16
  168. package/lib/esm/Metadata/Class.d.ts.map +1 -1
  169. package/lib/esm/Metadata/Class.js +68 -68
  170. package/lib/esm/Metadata/Class.js.map +1 -1
  171. package/lib/esm/Metadata/CustomAttribute.d.ts +7 -1
  172. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -1
  173. package/lib/esm/Metadata/CustomAttribute.js.map +1 -1
  174. package/lib/esm/Metadata/CustomAttributeClass.d.ts +1 -1
  175. package/lib/esm/Metadata/CustomAttributeClass.js +1 -1
  176. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -1
  177. package/lib/esm/Metadata/EntityClass.d.ts +6 -6
  178. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -1
  179. package/lib/esm/Metadata/EntityClass.js +48 -26
  180. package/lib/esm/Metadata/EntityClass.js.map +1 -1
  181. package/lib/esm/Metadata/Format.d.ts +5 -0
  182. package/lib/esm/Metadata/Format.d.ts.map +1 -1
  183. package/lib/esm/Metadata/Format.js +7 -0
  184. package/lib/esm/Metadata/Format.js.map +1 -1
  185. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
  186. package/lib/esm/Metadata/Schema.d.ts +10 -0
  187. package/lib/esm/Metadata/Schema.d.ts.map +1 -1
  188. package/lib/esm/Metadata/Schema.js +13 -0
  189. package/lib/esm/Metadata/Schema.js.map +1 -1
  190. package/lib/esm/Metadata/SchemaItem.d.ts +10 -0
  191. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -1
  192. package/lib/esm/Metadata/SchemaItem.js +13 -0
  193. package/lib/esm/Metadata/SchemaItem.js.map +1 -1
  194. package/lib/esm/SchemaFormatsProvider.d.ts +4 -3
  195. package/lib/esm/SchemaFormatsProvider.d.ts.map +1 -1
  196. package/lib/esm/SchemaFormatsProvider.js +61 -18
  197. package/lib/esm/SchemaFormatsProvider.js.map +1 -1
  198. package/lib/esm/SchemaLoader.d.ts +4 -1
  199. package/lib/esm/SchemaLoader.d.ts.map +1 -1
  200. package/lib/esm/SchemaLoader.js +4 -1
  201. package/lib/esm/SchemaLoader.js.map +1 -1
  202. package/lib/esm/ecschema-metadata.d.ts +2 -0
  203. package/lib/esm/ecschema-metadata.d.ts.map +1 -1
  204. package/lib/esm/ecschema-metadata.js +2 -0
  205. package/lib/esm/ecschema-metadata.js.map +1 -1
  206. package/lib/esm/utils/SchemaLoadingController.d.ts +37 -0
  207. package/lib/esm/utils/SchemaLoadingController.d.ts.map +1 -0
  208. package/lib/esm/utils/SchemaLoadingController.js +61 -0
  209. package/lib/esm/utils/SchemaLoadingController.js.map +1 -0
  210. package/package.json +15 -10
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaFormatsProvider.d.ts","sourceRoot":"","sources":["../../src/SchemaFormatsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAe,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIvG;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,iBAAiB,CAA0B;IAC5C,gBAAgB,iBAAsB,kBAAkB,KAAK,IAAI,EAAI;IAC5E;;;;;;OAMG;gBACS,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa;IAUvE,IAAW,OAAO,kBAA4B;IAC9C,IAAW,UAAU,IAEa,aAAa,CAFK;IAEpD,IAAW,UAAU,CAAC,UAAU,EAAE,aAAa,EAG9C;IAED,OAAO,CAAC,KAAK;YAMC,iCAAiC;IA0C/C;;;;;;OAMG;IACU,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAkBjF"}
1
+ {"version":3,"file":"SchemaFormatsProvider.d.ts","sourceRoot":"","sources":["../../src/SchemaFormatsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1D,OAAO,EAAE,OAAO,EAAU,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,gBAAgB,EAAe,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMzH;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,iBAAiB,CAA0B;IAC5C,gBAAgB,iBAAsB,kBAAkB,KAAK,IAAI,EAAI;IAC5E;;;;;;OAMG;gBACS,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa;IAUvE,IAAW,OAAO,kBAA4B;IAC9C,IAAW,UAAU,IAEa,aAAa,CAFK;IAEpD,IAAW,UAAU,CAAC,UAAU,EAAE,aAAa,EAG9C;IAED,OAAO,CAAC,KAAK;IAMb,0HAA0H;IAC1H,OAAO,CAAC,yBAAyB;YAenB,iCAAiC;IAmD/C;;;;;;OAMG;IACU,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;CA8B5E"}
@@ -15,6 +15,7 @@ const Format_1 = require("./Metadata/Format");
15
15
  const core_bentley_1 = require("@itwin/core-bentley");
16
16
  const KindOfQuantity_1 = require("./Metadata/KindOfQuantity");
17
17
  const OverrideFormat_1 = require("./Metadata/OverrideFormat");
18
+ const loggerCategory = "SchemaFormatsProvider";
18
19
  /**
19
20
  * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.
20
21
  * @beta
@@ -52,41 +53,65 @@ class SchemaFormatsProvider {
52
53
  this._formatsRetrieved.clear();
53
54
  this.onFormatsChanged.raiseEvent({ formatsChanged });
54
55
  }
56
+ /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */
57
+ convertToFormatDefinition(format, kindOfQuantity) {
58
+ // Destructure all properties except 'rest'
59
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
+ const { name, label, description, $schema, schema, schemaVersion, schemaItemType,
61
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
62
+ customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;
63
+ return {
64
+ ...rest,
65
+ name: kindOfQuantity.fullName,
66
+ label: kindOfQuantity.label ?? format.label,
67
+ description: kindOfQuantity.description ?? format.description,
68
+ };
69
+ }
55
70
  async getKindOfQuantityFormatFromSchema(itemKey) {
56
- const kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity_1.KindOfQuantity);
71
+ let kindOfQuantity;
72
+ try {
73
+ kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity_1.KindOfQuantity);
74
+ }
75
+ catch {
76
+ core_bentley_1.Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);
77
+ return undefined;
78
+ }
57
79
  if (!kindOfQuantity) {
58
80
  return undefined;
59
81
  }
60
82
  // Find the first presentation format that matches the provided unit system.
61
- const unitSystemGroupNames = getUnitSystemGroupNames(this._unitSystem);
83
+ const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);
62
84
  const presentationFormats = kindOfQuantity.presentationFormats;
63
- for (const system of unitSystemGroupNames) {
85
+ for (const matcher of unitSystemMatchers) {
64
86
  for (const lazyFormat of presentationFormats) {
65
87
  const format = await lazyFormat;
66
88
  const unit = await (format.units && format.units[0][0]);
67
89
  if (!unit) {
68
90
  continue;
69
91
  }
70
- const currentUnitSystem = unit.unitSystem;
71
- if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {
92
+ const currentUnitSystem = await unit.unitSystem;
93
+ if (currentUnitSystem && matcher(currentUnitSystem)) {
72
94
  this._formatsRetrieved.add(itemKey.fullName);
73
- return (0, OverrideFormat_1.getFormatProps)(format);
95
+ const props = (0, OverrideFormat_1.getFormatProps)(format);
96
+ return this.convertToFormatDefinition(props, kindOfQuantity);
74
97
  }
75
98
  }
76
99
  }
77
100
  // If no matching presentation format was found, use persistence unit format if it matches unit system.
78
101
  const persistenceUnit = await kindOfQuantity.persistenceUnit;
79
102
  const persistenceUnitSystem = await persistenceUnit?.unitSystem;
80
- if (persistenceUnitSystem && unitSystemGroupNames.includes(persistenceUnitSystem.name.toUpperCase())) {
103
+ if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
81
104
  this._formatsRetrieved.add(itemKey.fullName);
82
- return getPersistenceUnitFormatProps(persistenceUnit);
105
+ const props = getPersistenceUnitFormatProps(persistenceUnit);
106
+ return this.convertToFormatDefinition(props, kindOfQuantity);
83
107
  }
84
108
  const defaultFormat = kindOfQuantity.defaultPresentationFormat;
85
109
  if (!defaultFormat) {
86
110
  return undefined;
87
111
  }
88
112
  this._formatsRetrieved.add(itemKey.fullName);
89
- return (0, OverrideFormat_1.getFormatProps)(await defaultFormat);
113
+ const defaultProps = (0, OverrideFormat_1.getFormatProps)(await defaultFormat);
114
+ return this.convertToFormatDefinition(defaultProps, kindOfQuantity);
90
115
  }
91
116
  /**
92
117
  * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.
@@ -98,13 +123,27 @@ class SchemaFormatsProvider {
98
123
  async getFormat(name) {
99
124
  const [schemaName, schemaItemName] = SchemaItem_1.SchemaItem.parseFullName(name);
100
125
  const schemaKey = new SchemaKey_1.SchemaKey(schemaName);
101
- const schema = await this._context.getSchema(schemaKey);
126
+ let schema;
127
+ try {
128
+ schema = await this._context.getSchema(schemaKey);
129
+ }
130
+ catch {
131
+ core_bentley_1.Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);
132
+ return undefined;
133
+ }
102
134
  if (!schema) {
103
135
  return undefined;
104
136
  }
105
137
  const itemKey = new SchemaKey_1.SchemaItemKey(schemaItemName, schema.schemaKey);
106
138
  if (schema.name === "Formats") {
107
- const format = await this._context.getSchemaItem(itemKey, Format_1.Format);
139
+ let format;
140
+ try {
141
+ format = await this._context.getSchemaItem(itemKey, Format_1.Format);
142
+ }
143
+ catch {
144
+ core_bentley_1.Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);
145
+ return undefined;
146
+ }
108
147
  if (!format) {
109
148
  return undefined;
110
149
  }
@@ -114,16 +153,20 @@ class SchemaFormatsProvider {
114
153
  }
115
154
  }
116
155
  exports.SchemaFormatsProvider = SchemaFormatsProvider;
117
- function getUnitSystemGroupNames(unitSystem) {
118
- switch (unitSystem) {
156
+ function getUnitSystemGroupMatchers(groupKey) {
157
+ function createMatcher(name) {
158
+ const names = Array.isArray(name) ? name : [name];
159
+ return (unitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());
160
+ }
161
+ switch (groupKey) {
119
162
  case "imperial":
120
- return ["IMPERIAL", "USCUSTOM", "INTERNATIONAL", "FINANCE"];
163
+ return ["IMPERIAL", "USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
121
164
  case "metric":
122
- return ["SI", "METRIC", "INTERNATIONAL", "FINANCE"];
165
+ return [["SI", "METRIC"], "INTERNATIONAL", "FINANCE"].map(createMatcher);
123
166
  case "usCustomary":
124
- return ["USCUSTOM", "INTERNATIONAL", "FINANCE"];
167
+ return ["USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
125
168
  case "usSurvey":
126
- return ["USSURVEY", "USCUSTOM", "INTERNATIONAL", "FINANCE"];
169
+ return ["USSURVEY", "USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
127
170
  }
128
171
  return [];
129
172
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../src/SchemaFormatsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAA0D;AAC1D,2CAAuD;AACvD,sDAAmD;AACnD,8CAA2C;AAE3C,sDAA8C;AAC9C,8DAA2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,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\nimport { Format } from \"./Metadata/Format\";\nimport { SchemaItemFormatProps } from \"./Deserialization/JsonProps\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nimport { getFormatProps } from \"./Metadata/OverrideFormat\";\nimport { FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport { Unit } from \"./Metadata/Unit\";\nimport { InvertedUnit } from \"./Metadata/InvertedUnit\";\n\n/**\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\n * @beta\n */\nexport class SchemaFormatsProvider implements FormatsProvider {\n private _context: SchemaContext;\n private _unitSystem: UnitSystemKey;\n private _formatsRetrieved: Set<string> = new Set();\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\n /**\n *\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\n * created and the locater will be added.\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\n */\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\n if (contextOrLocater instanceof SchemaContext) {\n this._context = contextOrLocater;\n } else {\n this._context = new SchemaContext();\n this._context.addLocater(contextOrLocater);\n }\n this._unitSystem = unitSystem;\n }\n\n public get context() { return this._context; }\n public get unitSystem() { return this._unitSystem; }\n\n public set unitSystem(unitSystem: UnitSystemKey) {\n this._unitSystem = unitSystem;\n this.clear();\n }\n\n private clear(): void {\n const formatsChanged = Array.from(this._formatsRetrieved);\n this._formatsRetrieved.clear();\n this.onFormatsChanged.raiseEvent({ formatsChanged });\n }\n\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<SchemaItemFormatProps | undefined> {\n const kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\n\n if (!kindOfQuantity) {\n return undefined;\n }\n\n // Find the first presentation format that matches the provided unit system.\n const unitSystemGroupNames = getUnitSystemGroupNames(this._unitSystem);\n const presentationFormats = kindOfQuantity.presentationFormats;\n for (const system of unitSystemGroupNames) {\n for (const lazyFormat of presentationFormats) {\n const format = await lazyFormat;\n const unit = await (format.units && format.units[0][0]);\n if (!unit) {\n continue;\n }\n const currentUnitSystem = unit.unitSystem;\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {\n this._formatsRetrieved.add(itemKey.fullName);\n return getFormatProps(format);\n }\n }\n }\n\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\n if (persistenceUnitSystem && unitSystemGroupNames.includes(persistenceUnitSystem.name.toUpperCase())) {\n this._formatsRetrieved.add(itemKey.fullName);\n return getPersistenceUnitFormatProps(persistenceUnit!);\n }\n\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\n if (!defaultFormat) {\n return undefined;\n }\n this._formatsRetrieved.add(itemKey.fullName);\n return getFormatProps(await defaultFormat);\n }\n\n\n /**\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\n * Else, the default presentation format will be retrieved.\n * @param name The full name of the Format or KindOfQuantity.\n * @returns\n */\n public async getFormat(name: string): Promise<SchemaItemFormatProps | undefined> {\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\n const schemaKey = new SchemaKey(schemaName);\n const schema = await this._context.getSchema(schemaKey);\n if (!schema) {\n return undefined;\n }\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n\n if (schema.name === \"Formats\") {\n const format = await this._context.getSchemaItem(itemKey, Format);\n if (!format) {\n return undefined;\n }\n return format.toJSON(true);\n }\n return this.getKindOfQuantityFormatFromSchema(itemKey);\n }\n}\n\nfunction getUnitSystemGroupNames(unitSystem?: UnitSystemKey) {\n switch (unitSystem) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"metric\":\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\n }\n return [];\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}"]}
1
+ {"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../src/SchemaFormatsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAA0D;AAC1D,2CAAuD;AACvD,sDAAmD;AACnD,8CAA2C;AAE3C,sDAAsD;AACtD,8DAA2D;AAC3D,8DAA2D;AAM3D,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C;;;GAGG;AACH,MAAa,qBAAqB;IACxB,QAAQ,CAAgB;IACxB,WAAW,CAAgB;IAC3B,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC5C,gBAAgB,GAAG,IAAI,sBAAO,EAAsC,CAAC;IAC5E;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAE,UAAyB;QACrE,IAAI,gBAAgB,YAAY,uBAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,IAAW,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAW,UAAU,KAAK,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAEpD,IAAW,UAAU,CAAC,UAAyB;QAC7C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAE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6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Metadata\n */\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\nimport { Format } from \"./Metadata/Format\";\nimport { SchemaItemFormatProps } from \"./Deserialization/JsonProps\";\nimport { BeEvent, Logger } from \"@itwin/core-bentley\";\nimport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nimport { getFormatProps } from \"./Metadata/OverrideFormat\";\nimport { FormatDefinition, FormatProps, FormatsChangedArgs, FormatsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport { Unit } from \"./Metadata/Unit\";\nimport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { UnitSystem } from \"./Metadata/UnitSystem\";\nconst loggerCategory = \"SchemaFormatsProvider\";\n/**\n * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.\n * @beta\n */\nexport class SchemaFormatsProvider implements FormatsProvider {\n private _context: SchemaContext;\n private _unitSystem: UnitSystemKey;\n private _formatsRetrieved: Set<string> = new Set();\n public onFormatsChanged = new BeEvent<(args: FormatsChangedArgs) => void>();\n /**\n *\n * @param contextOrLocater The SchemaContext or a different ISchemaLocater implementation used to retrieve the schema. The SchemaContext\n * class implements the ISchemaLocater interface. If the provided locater is not a SchemaContext instance a new SchemaContext will be\n * created and the locater will be added.\n * @param unitSystem Used to lookup a default format through a schema specific algorithm, when the format retrieved is associated with a KindOfQuantity.\n */\n constructor(contextOrLocater: ISchemaLocater, unitSystem: UnitSystemKey) {\n if (contextOrLocater instanceof SchemaContext) {\n this._context = contextOrLocater;\n } else {\n this._context = new SchemaContext();\n this._context.addLocater(contextOrLocater);\n }\n this._unitSystem = unitSystem;\n }\n\n public get context() { return this._context; }\n public get unitSystem() { return this._unitSystem; }\n\n public set unitSystem(unitSystem: UnitSystemKey) {\n this._unitSystem = unitSystem;\n this.clear();\n }\n\n private clear(): void {\n const formatsChanged = Array.from(this._formatsRetrieved);\n this._formatsRetrieved.clear();\n this.onFormatsChanged.raiseEvent({ formatsChanged });\n }\n\n /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */\n private convertToFormatDefinition(format: SchemaItemFormatProps, kindOfQuantity: KindOfQuantity): FormatDefinition {\n // Destructure all properties except 'rest'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { name, label, description, $schema, schema, schemaVersion, schemaItemType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;\n\n return {\n ...rest,\n name: kindOfQuantity.fullName,\n label: kindOfQuantity.label ?? format.label,\n description: kindOfQuantity.description ?? format.description,\n }\n }\n\n private async getKindOfQuantityFormatFromSchema(itemKey: SchemaItemKey): Promise<FormatDefinition | undefined> {\n let kindOfQuantity: KindOfQuantity | undefined;\n try {\n kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);\n } catch {\n Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);\n return undefined;\n }\n\n if (!kindOfQuantity) {\n return undefined;\n }\n\n // Find the first presentation format that matches the provided unit system.\n const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);\n const presentationFormats = kindOfQuantity.presentationFormats;\n for (const matcher of unitSystemMatchers) {\n for (const lazyFormat of presentationFormats) {\n const format = await lazyFormat;\n const unit = await (format.units && format.units[0][0]);\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && matcher(currentUnitSystem)) {\n this._formatsRetrieved.add(itemKey.fullName);\n const props = getFormatProps(format);\n return this.convertToFormatDefinition(props, kindOfQuantity);\n }\n }\n }\n\n // If no matching presentation format was found, use persistence unit format if it matches unit system.\n const persistenceUnit = await kindOfQuantity.persistenceUnit;\n const persistenceUnitSystem = await persistenceUnit?.unitSystem;\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\n this._formatsRetrieved.add(itemKey.fullName);\n const props = getPersistenceUnitFormatProps(persistenceUnit!);\n return this.convertToFormatDefinition(props, kindOfQuantity);\n }\n\n const defaultFormat = kindOfQuantity.defaultPresentationFormat;\n if (!defaultFormat) {\n return undefined;\n }\n this._formatsRetrieved.add(itemKey.fullName);\n const defaultProps = getFormatProps(await defaultFormat);\n return this.convertToFormatDefinition(defaultProps, kindOfQuantity);\n }\n\n\n /**\n * Retrieves a Format from a SchemaContext. If the format is part of a KindOfQuantity, the first presentation format in the KindOfQuantity that matches the current unit system will be retrieved.\n * If no presentation format matches the current unit system, the persistence unit format will be retrieved if it matches the current unit system.\n * Else, the default presentation format will be retrieved.\n * @param name The full name of the Format or KindOfQuantity.\n * @returns\n */\n public async getFormat(name: string): Promise<FormatDefinition | undefined> {\n const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);\n const schemaKey = new SchemaKey(schemaName);\n let schema: Schema | undefined;\n try {\n schema = await this._context.getSchema(schemaKey);\n } catch {\n Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);\n return undefined;\n }\n if (!schema) {\n return undefined;\n }\n const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);\n\n if (schema.name === \"Formats\") {\n let format: Format | undefined;\n try {\n format = await this._context.getSchemaItem(itemKey, Format);\n } catch {\n Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);\n return undefined;\n }\n if (!format) {\n return undefined;\n }\n return format.toJSON(true);\n }\n return this.getKindOfQuantityFormatFromSchema(itemKey);\n }\n}\n\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\n function createMatcher(name: string | string[]) {\n const names = Array.isArray(name) ? name : [name];\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\n }\n switch (groupKey) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"metric\":\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n }\n return [];\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}"]}
@@ -7,11 +7,14 @@ import { SchemaPropsGetter } from "./SchemaJsonLocater";
7
7
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
8
8
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
9
9
  *
10
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
11
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
12
+ *
10
13
  * ** Example **
11
14
  * ```ts
12
15
  * [[include:IModelSchemas.loadFromDb]]
13
16
  * ```
14
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
17
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
15
18
  */
16
19
  export declare class SchemaLoader {
17
20
  private _context;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.d.ts","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgB;gBAEb,SAAS,EAAE,iBAAiB;IAM/C;;;OAGG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ5C;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAO3D,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
1
+ {"version":3,"file":"SchemaLoader.d.ts","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgB;gBAEb,SAAS,EAAE,iBAAiB;IAM/C;;;OAGG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ5C;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAO3D,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
@@ -16,11 +16,14 @@ const SchemaKey_1 = require("./SchemaKey");
16
16
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
17
17
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
18
18
  *
19
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
20
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
21
+ *
19
22
  * ** Example **
20
23
  * ```ts
21
24
  * [[include:IModelSchemas.loadFromDb]]
22
25
  * ```
23
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
26
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
24
27
  */
25
28
  class SchemaLoader {
26
29
  _context;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA4D;AAE5D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,MAAa,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,qBAAS,CAAC,UAAU,EAAE,IAAI,qBAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AApCD,oCAoCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA4D;AAE5D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;;;;;;;;;GAcG;AACH,MAAa,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,qBAAS,CAAC,UAAU,EAAE,IAAI,qBAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AApCD,oCAoCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * Since the development of this class, the IModelDb class has been enhanced to include a schema context.\n * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
@@ -37,6 +37,8 @@ export * from "./UnitProvider/SchemaUnitProvider";
37
37
  export * from "./Validation/SchemaWalker";
38
38
  export * from "./SchemaPartVisitorDelegate";
39
39
  export * from "./SchemaFormatsProvider";
40
+ export * from "./IncrementalLoading/ECSqlSchemaLocater";
41
+ export * from "./IncrementalLoading/IncrementalSchemaLocater";
40
42
  export { CustomAttribute, CustomAttributeContainerProps } from "./Metadata/CustomAttribute";
41
43
  export { SchemaGraph } from "./utils/SchemaGraph";
42
44
  /** @docs-package-description
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-metadata.d.ts","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":"AAKA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB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AO,EACL,QAAQ,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,cAAc,EACxF,mBAAmB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,sBAAsB,EAC3G,oBAAoB,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,2BAA2B,GACjG,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAC,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG"}
@@ -86,6 +86,8 @@ __exportStar(require("./UnitProvider/SchemaUnitProvider"), exports);
86
86
  __exportStar(require("./Validation/SchemaWalker"), exports);
87
87
  __exportStar(require("./SchemaPartVisitorDelegate"), exports);
88
88
  __exportStar(require("./SchemaFormatsProvider"), exports);
89
+ __exportStar(require("./IncrementalLoading/ECSqlSchemaLocater"), exports);
90
+ __exportStar(require("./IncrementalLoading/IncrementalSchemaLocater"), exports);
89
91
  var SchemaGraph_1 = require("./utils/SchemaGraph");
90
92
  Object.defineProperty(exports, "SchemaGraph", { enumerable: true, get: function () { return SchemaGraph_1.SchemaGraph; } });
91
93
  /** @docs-package-description
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;AAE/F,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,8DAA4C;AAC5C,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,0CAAwD;AAA/C,gGAAA,OAAO,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC7B,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAC7B,sDAAqD;AAA5C,0GAAA,WAAW,OAAA;AACpB,sDAAgF;AAAxD,0GAAA,WAAW,OAAA;AACnC,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,0CAAyC;AAAhC,8FAAA,KAAK,OAAA;AACd,4DAA0C;AAC1C,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,gDAI6B;AAH3B,oGAAA,QAAQ,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,0GAAA,cAAc,OAAA;AACxF,+GAAA,mBAAmB,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACX,yGAAA,aAAa,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAElG,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,kEAAmH;AAA1G,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAAE,6HAAA,wBAAwB,OAAA;AAC5E,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAsC;AACtC,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,kDAAgC;AAChC,sDAAoC;AACpC,8CAA4B;AAC5B,iDAA+B;AAC/B,kEAAgD;AAChD,iEAA+C;AAC/C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAC5C,0DAAwC;AAExC,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./Constants\";\nexport * from \"./Context\";\nexport * from \"./DelayedPromise\";\nexport * from \"./Deserialization/SchemaGraphUtil\";\nexport * from \"./Deserialization/JsonProps\";\nexport * from \"./Deserialization/Helper\";\nexport * from \"./Deserialization/XmlParser\";\nexport * from \"./ECName\";\nexport * from \"./ECObjects\";\nexport * from \"./Exception\";\nexport * from \"./Interfaces\";\nexport { ECClass, StructClass } from \"./Metadata/Class\";\nexport { Constant } from \"./Metadata/Constant\";\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\nexport { EntityClass } from \"./Metadata/EntityClass\";\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\nexport { Format } from \"./Metadata/Format\";\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nexport { Mixin } from \"./Metadata/Mixin\";\nexport * from \"./Metadata/OverrideFormat\";\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\nexport {\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\n} from \"./Metadata/Property\";\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\nexport { Schema } from \"./Metadata/Schema\";\nexport * from \"./Metadata/SchemaItem\";\nexport { Unit } from \"./Metadata/Unit\";\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\nexport * from \"./PropertyTypes\";\nexport * from \"./SchemaJsonLocater\";\nexport * from \"./SchemaKey\";\nexport * from \"./SchemaLoader\";\nexport * from \"./UnitConversion/UnitConversion\";\nexport * from \"./UnitConversion/UnitConverter\";\nexport * from \"./UnitProvider/SchemaUnitProvider\";\nexport * from \"./Validation/SchemaWalker\";\nexport * from \"./SchemaPartVisitorDelegate\";\nexport * from \"./SchemaFormatsProvider\";\nexport { CustomAttribute, CustomAttributeContainerProps} from \"./Metadata/CustomAttribute\";\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\n\n/** @docs-package-description\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\n */\n/**\n * @docs-group-description Metadata\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\n */\n/**\n * @docs-group-description Utils\n * A set of utility classes used throughout the package.\n */\n"]}
1
+ {"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;AAE/F,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,oEAAkD;AAClD,8DAA4C;AA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,8DAA4C;AAC5C,0DAAwC;AACxC,0EAAwD;AACxD,gFAA8D;AAE9D,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./Constants\";\nexport * from \"./Context\";\nexport * from \"./DelayedPromise\";\nexport * from \"./Deserialization/SchemaGraphUtil\";\nexport * from \"./Deserialization/JsonProps\";\nexport * from \"./Deserialization/Helper\";\nexport * from \"./Deserialization/XmlParser\";\nexport * from \"./ECName\";\nexport * from \"./ECObjects\";\nexport * from \"./Exception\";\nexport * from \"./Interfaces\";\nexport { ECClass, StructClass } from \"./Metadata/Class\";\nexport { Constant } from \"./Metadata/Constant\";\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\nexport { EntityClass } from \"./Metadata/EntityClass\";\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\nexport { Format } from \"./Metadata/Format\";\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\nexport { Mixin } from \"./Metadata/Mixin\";\nexport * from \"./Metadata/OverrideFormat\";\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\nexport {\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\n} from \"./Metadata/Property\";\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\nexport { Schema } from \"./Metadata/Schema\";\nexport * from \"./Metadata/SchemaItem\";\nexport { Unit } from \"./Metadata/Unit\";\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\nexport * from \"./PropertyTypes\";\nexport * from \"./SchemaJsonLocater\";\nexport * from \"./SchemaKey\";\nexport * from \"./SchemaLoader\";\nexport * from \"./UnitConversion/UnitConversion\";\nexport * from \"./UnitConversion/UnitConverter\";\nexport * from \"./UnitProvider/SchemaUnitProvider\";\nexport * from \"./Validation/SchemaWalker\";\nexport * from \"./SchemaPartVisitorDelegate\";\nexport * from \"./SchemaFormatsProvider\";\nexport * from \"./IncrementalLoading/ECSqlSchemaLocater\";\nexport * from \"./IncrementalLoading/IncrementalSchemaLocater\";\nexport { CustomAttribute, CustomAttributeContainerProps} from \"./Metadata/CustomAttribute\";\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\n\n/** @docs-package-description\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\n */\n/**\n * @docs-group-description Metadata\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\n */\n/**\n * @docs-group-description Utils\n * A set of utility classes used throughout the package.\n */\n"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this
3
+ * class is set in Schema and SchemaItem instances.
4
+ * @internal
5
+ */
6
+ export declare class SchemaLoadingController {
7
+ private _complete;
8
+ private _inProgress;
9
+ private _promise?;
10
+ /**
11
+ * Indicates of the Schema or SchemaItem has been fully loaded.
12
+ */
13
+ get isComplete(): boolean;
14
+ /**
15
+ * Marks that a Schema or SchemaItem has been fully loaded.
16
+ */
17
+ set isComplete(value: boolean);
18
+ /**
19
+ * Indicates that the loading of a Schema or SchemaItem is still in progress
20
+ */
21
+ get inProgress(): boolean;
22
+ /**
23
+ * Initializes a new SchemaLoadingController instance.
24
+ */
25
+ constructor();
26
+ /**
27
+ * Call this method when starting to load a Schema or SchemaItem
28
+ * @param promise The promise used to update the controller state when the promise is resolved.
29
+ */
30
+ start(promise: Promise<void>): void;
31
+ /**
32
+ * Waits on the Promise given in SchemaLoadingController.start().
33
+ * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.
34
+ */
35
+ wait(): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=SchemaLoadingController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaLoadingController.d.ts","sourceRoot":"","sources":["../../../src/utils/SchemaLoadingController.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,SAAS,CAAC;IAClB,OAAO,CAAC,WAAW,CAAC;IACpB,OAAO,CAAC,QAAQ,CAAC,CAAgB;IAEjC;;OAEG;IACH,IAAW,UAAU,IAOQ,OAAO,CALnC;IAED;;OAEG;IACH,IAAW,UAAU,CAAC,KAAK,EAAE,OAAO,EAEnC;IAED;;OAEG;IACH,IAAW,UAAU,YAEpB;IAED;;OAEG;;IAMH;;;OAGG;IACI,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC;IASnC;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAKnC"}
@@ -0,0 +1,65 @@
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.SchemaLoadingController = void 0;
8
+ /**
9
+ * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this
10
+ * class is set in Schema and SchemaItem instances.
11
+ * @internal
12
+ */
13
+ class SchemaLoadingController {
14
+ _complete;
15
+ _inProgress;
16
+ _promise;
17
+ /**
18
+ * Indicates of the Schema or SchemaItem has been fully loaded.
19
+ */
20
+ get isComplete() {
21
+ return this._complete;
22
+ }
23
+ /**
24
+ * Marks that a Schema or SchemaItem has been fully loaded.
25
+ */
26
+ set isComplete(value) {
27
+ this._complete = value;
28
+ }
29
+ /**
30
+ * Indicates that the loading of a Schema or SchemaItem is still in progress
31
+ */
32
+ get inProgress() {
33
+ return this._inProgress;
34
+ }
35
+ /**
36
+ * Initializes a new SchemaLoadingController instance.
37
+ */
38
+ constructor() {
39
+ this._complete = false;
40
+ this._inProgress = false;
41
+ }
42
+ /**
43
+ * Call this method when starting to load a Schema or SchemaItem
44
+ * @param promise The promise used to update the controller state when the promise is resolved.
45
+ */
46
+ start(promise) {
47
+ this._inProgress = true;
48
+ void promise.then(() => {
49
+ this._complete = true;
50
+ this._inProgress = false;
51
+ });
52
+ this._promise = promise;
53
+ }
54
+ /**
55
+ * Waits on the Promise given in SchemaLoadingController.start().
56
+ * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.
57
+ */
58
+ async wait() {
59
+ if (!this._promise)
60
+ throw new Error("LoadingController 'start' must be called before 'wait'");
61
+ return this._promise;
62
+ }
63
+ }
64
+ exports.SchemaLoadingController = SchemaLoadingController;
65
+ //# sourceMappingURL=SchemaLoadingController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaLoadingController.js","sourceRoot":"","sources":["../../../src/utils/SchemaLoadingController.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;;GAIG;AACH,MAAa,uBAAuB;IAC1B,SAAS,CAAC;IACV,WAAW,CAAC;IACZ,QAAQ,CAAiB;IAEjC;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,UAAU,CAAC,KAAc;QAClC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH;QACE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAsB;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,IAAI;QACf,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAxDD,0DAwDC","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 * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this\n * class is set in Schema and SchemaItem instances.\n * @internal\n */\nexport class SchemaLoadingController {\n private _complete;\n private _inProgress;\n private _promise?: Promise<void>;\n\n /**\n * Indicates of the Schema or SchemaItem has been fully loaded.\n */\n public get isComplete() {\n return this._complete;\n }\n\n /**\n * Marks that a Schema or SchemaItem has been fully loaded.\n */\n public set isComplete(value: boolean) {\n this._complete = value;\n }\n\n /**\n * Indicates that the loading of a Schema or SchemaItem is still in progress\n */\n public get inProgress() {\n return this._inProgress;\n }\n\n /**\n * Initializes a new SchemaLoadingController instance.\n */\n constructor() {\n this._complete = false;\n this._inProgress = false;\n }\n\n /**\n * Call this method when starting to load a Schema or SchemaItem\n * @param promise The promise used to update the controller state when the promise is resolved.\n */\n public start(promise: Promise<void>) {\n this._inProgress = true;\n void promise.then(() => {\n this._complete = true;\n this._inProgress = false;\n });\n this._promise = promise;\n }\n\n /**\n * Waits on the Promise given in SchemaLoadingController.start().\n * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.\n */\n public async wait(): Promise<void> {\n if (!this._promise)\n throw new Error(\"LoadingController 'start' must be called before 'wait'\");\n return this._promise;\n }\n}"]}
@@ -146,7 +146,7 @@ export declare class SchemaContext {
146
146
  /**
147
147
  * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and
148
148
  * @param schemaItem The SchemaItem to add
149
- * @deprecated in 4.0 use ecschema-editing package
149
+ * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use ecschema-editing package
150
150
  */
151
151
  addSchemaItem(schemaItem: SchemaItem): Promise<void>;
152
152
  /**
@@ -219,7 +219,7 @@ export class SchemaContext {
219
219
  /**
220
220
  * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and
221
221
  * @param schemaItem The SchemaItem to add
222
- * @deprecated in 4.0 use ecschema-editing package
222
+ * @deprecated in 4.0 - will not be removed until after 2026-06-13. Use ecschema-editing package
223
223
  */
224
224
  async addSchemaItem(schemaItem) {
225
225
  const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);