@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
@@ -9,9 +9,10 @@ import { SchemaContext } from "./Context";
9
9
  import { SchemaItemKey, SchemaKey } from "./SchemaKey";
10
10
  import { SchemaItem } from "./Metadata/SchemaItem";
11
11
  import { Format } from "./Metadata/Format";
12
- import { BeEvent } from "@itwin/core-bentley";
12
+ import { BeEvent, Logger } from "@itwin/core-bentley";
13
13
  import { KindOfQuantity } from "./Metadata/KindOfQuantity";
14
14
  import { getFormatProps } from "./Metadata/OverrideFormat";
15
+ const loggerCategory = "SchemaFormatsProvider";
15
16
  /**
16
17
  * Provides default formats and kind of quantities from a given SchemaContext or SchemaLocater.
17
18
  * @beta
@@ -49,41 +50,65 @@ export class SchemaFormatsProvider {
49
50
  this._formatsRetrieved.clear();
50
51
  this.onFormatsChanged.raiseEvent({ formatsChanged });
51
52
  }
53
+ /** When using a presentation unit from a KindOfQuantity, the label and description should come from the KindOfQuantity */
54
+ convertToFormatDefinition(format, kindOfQuantity) {
55
+ // Destructure all properties except 'rest'
56
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
+ const { name, label, description, $schema, schema, schemaVersion, schemaItemType,
58
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
+ customAttributes, originalECSpecMajorVersion, originalECSpecMinorVersion, ...rest } = format;
60
+ return {
61
+ ...rest,
62
+ name: kindOfQuantity.fullName,
63
+ label: kindOfQuantity.label ?? format.label,
64
+ description: kindOfQuantity.description ?? format.description,
65
+ };
66
+ }
52
67
  async getKindOfQuantityFormatFromSchema(itemKey) {
53
- const kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);
68
+ let kindOfQuantity;
69
+ try {
70
+ kindOfQuantity = await this._context.getSchemaItem(itemKey, KindOfQuantity);
71
+ }
72
+ catch {
73
+ Logger.logError(loggerCategory, `Failed to find KindOfQuantity ${itemKey.fullName}`);
74
+ return undefined;
75
+ }
54
76
  if (!kindOfQuantity) {
55
77
  return undefined;
56
78
  }
57
79
  // Find the first presentation format that matches the provided unit system.
58
- const unitSystemGroupNames = getUnitSystemGroupNames(this._unitSystem);
80
+ const unitSystemMatchers = getUnitSystemGroupMatchers(this._unitSystem);
59
81
  const presentationFormats = kindOfQuantity.presentationFormats;
60
- for (const system of unitSystemGroupNames) {
82
+ for (const matcher of unitSystemMatchers) {
61
83
  for (const lazyFormat of presentationFormats) {
62
84
  const format = await lazyFormat;
63
85
  const unit = await (format.units && format.units[0][0]);
64
86
  if (!unit) {
65
87
  continue;
66
88
  }
67
- const currentUnitSystem = unit.unitSystem;
68
- if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system) {
89
+ const currentUnitSystem = await unit.unitSystem;
90
+ if (currentUnitSystem && matcher(currentUnitSystem)) {
69
91
  this._formatsRetrieved.add(itemKey.fullName);
70
- return getFormatProps(format);
92
+ const props = getFormatProps(format);
93
+ return this.convertToFormatDefinition(props, kindOfQuantity);
71
94
  }
72
95
  }
73
96
  }
74
97
  // If no matching presentation format was found, use persistence unit format if it matches unit system.
75
98
  const persistenceUnit = await kindOfQuantity.persistenceUnit;
76
99
  const persistenceUnitSystem = await persistenceUnit?.unitSystem;
77
- if (persistenceUnitSystem && unitSystemGroupNames.includes(persistenceUnitSystem.name.toUpperCase())) {
100
+ if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
78
101
  this._formatsRetrieved.add(itemKey.fullName);
79
- return getPersistenceUnitFormatProps(persistenceUnit);
102
+ const props = getPersistenceUnitFormatProps(persistenceUnit);
103
+ return this.convertToFormatDefinition(props, kindOfQuantity);
80
104
  }
81
105
  const defaultFormat = kindOfQuantity.defaultPresentationFormat;
82
106
  if (!defaultFormat) {
83
107
  return undefined;
84
108
  }
85
109
  this._formatsRetrieved.add(itemKey.fullName);
86
- return getFormatProps(await defaultFormat);
110
+ const defaultProps = getFormatProps(await defaultFormat);
111
+ return this.convertToFormatDefinition(defaultProps, kindOfQuantity);
87
112
  }
88
113
  /**
89
114
  * 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.
@@ -95,13 +120,27 @@ export class SchemaFormatsProvider {
95
120
  async getFormat(name) {
96
121
  const [schemaName, schemaItemName] = SchemaItem.parseFullName(name);
97
122
  const schemaKey = new SchemaKey(schemaName);
98
- const schema = await this._context.getSchema(schemaKey);
123
+ let schema;
124
+ try {
125
+ schema = await this._context.getSchema(schemaKey);
126
+ }
127
+ catch {
128
+ Logger.logError(loggerCategory, `Failed to find schema ${schemaName}`);
129
+ return undefined;
130
+ }
99
131
  if (!schema) {
100
132
  return undefined;
101
133
  }
102
134
  const itemKey = new SchemaItemKey(schemaItemName, schema.schemaKey);
103
135
  if (schema.name === "Formats") {
104
- const format = await this._context.getSchemaItem(itemKey, Format);
136
+ let format;
137
+ try {
138
+ format = await this._context.getSchemaItem(itemKey, Format);
139
+ }
140
+ catch {
141
+ Logger.logError(loggerCategory, `Failed to find Format ${itemKey.fullName}`);
142
+ return undefined;
143
+ }
105
144
  if (!format) {
106
145
  return undefined;
107
146
  }
@@ -110,16 +149,20 @@ export class SchemaFormatsProvider {
110
149
  return this.getKindOfQuantityFormatFromSchema(itemKey);
111
150
  }
112
151
  }
113
- function getUnitSystemGroupNames(unitSystem) {
114
- switch (unitSystem) {
152
+ function getUnitSystemGroupMatchers(groupKey) {
153
+ function createMatcher(name) {
154
+ const names = Array.isArray(name) ? name : [name];
155
+ return (unitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());
156
+ }
157
+ switch (groupKey) {
115
158
  case "imperial":
116
- return ["IMPERIAL", "USCUSTOM", "INTERNATIONAL", "FINANCE"];
159
+ return ["IMPERIAL", "USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
117
160
  case "metric":
118
- return ["SI", "METRIC", "INTERNATIONAL", "FINANCE"];
161
+ return [["SI", "METRIC"], "INTERNATIONAL", "FINANCE"].map(createMatcher);
119
162
  case "usCustomary":
120
- return ["USCUSTOM", "INTERNATIONAL", "FINANCE"];
163
+ return ["USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
121
164
  case "usSurvey":
122
- return ["USSURVEY", "USCUSTOM", "INTERNATIONAL", "FINANCE"];
165
+ return ["USSURVEY", "USCUSTOM", "INTERNATIONAL", "FINANCE"].map(createMatcher);
123
166
  }
124
167
  return [];
125
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaFormatsProvider.js","sourceRoot":"","sources":["../../src/SchemaFormatsProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACxB,QAAQ,CAAgB;IACxB,WAAW,CAAgB;IAC3B,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC5C,gBAAgB,GAAG,IAAI,OAAO,EAAsC,CAAC;IAC5E;;;;;;OAMG;IACH,YAAY,gBAAgC,EAAE,UAAyB;QACrE,IAAI,gBAAgB,YAAY,aAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,QAAQ,GAAG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AkB,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,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AA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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"}
@@ -13,11 +13,14 @@ import { ECVersion, SchemaKey } from "./SchemaKey";
13
13
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
14
14
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
15
15
  *
16
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
17
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
18
+ *
16
19
  * ** Example **
17
20
  * ```ts
18
21
  * [[include:IModelSchemas.loadFromDb]]
19
22
  * ```
20
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
23
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
21
24
  */
22
25
  export class SchemaLoader {
23
26
  _context;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAiB,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,aAAa,CAAC,cAAc,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,SAAS,CAAC,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { 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,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAiB,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,aAAa,CAAC,cAAc,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,SAAS,CAAC,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { 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,mC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AqB,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG"}
@@ -41,6 +41,8 @@ export * from "./UnitProvider/SchemaUnitProvider";
41
41
  export * from "./Validation/SchemaWalker";
42
42
  export * from "./SchemaPartVisitorDelegate";
43
43
  export * from "./SchemaFormatsProvider";
44
+ export * from "./IncrementalLoading/ECSqlSchemaLocater";
45
+ export * from "./IncrementalLoading/IncrementalSchemaLocater";
44
46
  export { SchemaGraph } from "./utils/SchemaGraph";
45
47
  /** @docs-package-description
46
48
  * 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).
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,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,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAiB,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,QAAQ,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,cAAc,EACxF,mBAAmB,EAAE,wBAAwB,EAAE,kBAAkB,EACX,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;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;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,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,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAiB,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,QAAQ,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,cAAc,EACxF,mBAAmB,EAAE,wBAAwB,EAAE,kBAAkB,EACX,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;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;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,61 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this
7
+ * class is set in Schema and SchemaItem instances.
8
+ * @internal
9
+ */
10
+ export class SchemaLoadingController {
11
+ _complete;
12
+ _inProgress;
13
+ _promise;
14
+ /**
15
+ * Indicates of the Schema or SchemaItem has been fully loaded.
16
+ */
17
+ get isComplete() {
18
+ return this._complete;
19
+ }
20
+ /**
21
+ * Marks that a Schema or SchemaItem has been fully loaded.
22
+ */
23
+ set isComplete(value) {
24
+ this._complete = value;
25
+ }
26
+ /**
27
+ * Indicates that the loading of a Schema or SchemaItem is still in progress
28
+ */
29
+ get inProgress() {
30
+ return this._inProgress;
31
+ }
32
+ /**
33
+ * Initializes a new SchemaLoadingController instance.
34
+ */
35
+ constructor() {
36
+ this._complete = false;
37
+ this._inProgress = false;
38
+ }
39
+ /**
40
+ * Call this method when starting to load a Schema or SchemaItem
41
+ * @param promise The promise used to update the controller state when the promise is resolved.
42
+ */
43
+ start(promise) {
44
+ this._inProgress = true;
45
+ void promise.then(() => {
46
+ this._complete = true;
47
+ this._inProgress = false;
48
+ });
49
+ this._promise = promise;
50
+ }
51
+ /**
52
+ * Waits on the Promise given in SchemaLoadingController.start().
53
+ * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.
54
+ */
55
+ async wait() {
56
+ if (!this._promise)
57
+ throw new Error("LoadingController 'start' must be called before 'wait'");
58
+ return this._promise;
59
+ }
60
+ }
61
+ //# 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,MAAM,OAAO,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","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}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "5.1.0-dev.9",
3
+ "version": "5.2.0-dev.2",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -23,10 +23,14 @@
23
23
  "url": "http://www.bentley.com"
24
24
  },
25
25
  "devDependencies": {
26
- "@bentley/units-schema": "^1.0.8",
27
- "@bentley/formats-schema": "^1.0.0",
28
26
  "@bentley/aec-units-schema": "^1.0.3",
29
- "@itwin/eslint-plugin": "5.0.0-dev.1",
27
+ "@bentley/bis-custom-attributes-schema": "^1.0.0",
28
+ "@bentley/cif-units-schema": "^1.0.7",
29
+ "@bentley/core-custom-attributes-schema": "^1.0.4",
30
+ "@bentley/formats-schema": "^1.0.0",
31
+ "@bentley/road-rail-units-schema": "^1.0.3",
32
+ "@bentley/units-schema": "^1.0.9",
33
+ "@itwin/eslint-plugin": "5.2.2-dev.2",
30
34
  "@types/benchmark": "^2.1.0",
31
35
  "@types/chai": "4.3.1",
32
36
  "@types/chai-as-promised": "^7",
@@ -38,19 +42,19 @@
38
42
  "chai": "^4.3.10",
39
43
  "chai-as-promised": "^7.1.1",
40
44
  "cpx2": "^8.0.0",
41
- "eslint": "^9.13.0",
45
+ "eslint": "^9.31.0",
42
46
  "mocha": "^11.1.0",
43
47
  "nyc": "^17.1.0",
44
48
  "rimraf": "^6.0.1",
45
49
  "sinon": "^17.0.2",
46
50
  "typescript": "~5.6.2",
47
- "@itwin/build-tools": "5.1.0-dev.9",
48
- "@itwin/core-quantity": "5.1.0-dev.9",
49
- "@itwin/core-bentley": "5.1.0-dev.9"
51
+ "@itwin/build-tools": "5.2.0-dev.2",
52
+ "@itwin/core-bentley": "5.2.0-dev.2",
53
+ "@itwin/core-quantity": "5.2.0-dev.2"
50
54
  },
51
55
  "peerDependencies": {
52
- "@itwin/core-bentley": "5.1.0-dev.9",
53
- "@itwin/core-quantity": "5.1.0-dev.9"
56
+ "@itwin/core-bentley": "5.2.0-dev.2",
57
+ "@itwin/core-quantity": "5.2.0-dev.2"
54
58
  },
55
59
  "nyc": {
56
60
  "extends": "./node_modules/@itwin/build-tools/.nycrc"
@@ -63,6 +67,7 @@
63
67
  "copy:test-assets": "cpx \"./src/test/assets/**/*\" ./lib/cjs/test/assets",
64
68
  "extract-api": "betools extract-api --entry=ecschema-metadata",
65
69
  "lint": "eslint \"./src/**/*.ts\" 1>&2",
70
+ "lint-deprecation": "eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \"./src/**/*.ts\"",
66
71
  "test": "mocha",
67
72
  "docs": "betools docs --json=../../generated-docs/core/ecschema-metadata/file.json --tsIndexFile=./ecschema-metadata.ts --onlyJson",
68
73
  "cover": "nyc npm -s test",