@itwin/ecschema-metadata 4.8.0-dev.4 → 4.8.0-dev.40

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 (215) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/lib/cjs/Deserialization/JsonProps.d.ts +4 -0
  3. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  4. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  5. package/lib/cjs/Metadata/Class.d.ts +0 -6
  6. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  7. package/lib/cjs/Metadata/Class.js +0 -8
  8. package/lib/cjs/Metadata/Class.js.map +1 -1
  9. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +7 -3
  10. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  11. package/lib/cjs/Metadata/CustomAttributeClass.js +16 -10
  12. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  13. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  14. package/lib/cjs/Metadata/OverrideFormat.js +3 -1
  15. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  16. package/lib/cjs/Metadata/Schema.d.ts +14 -0
  17. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  18. package/lib/cjs/Metadata/Schema.js +21 -0
  19. package/lib/cjs/Metadata/Schema.js.map +1 -1
  20. package/lib/cjs/Metadata/SchemaItem.d.ts +5 -0
  21. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  22. package/lib/cjs/Metadata/SchemaItem.js +7 -0
  23. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  24. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +1 -1
  25. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +1 -1
  26. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  27. package/lib/esm/Constants.d.ts +24 -0
  28. package/lib/esm/Constants.d.ts.map +1 -0
  29. package/lib/esm/Constants.js +30 -0
  30. package/lib/esm/Constants.js.map +1 -0
  31. package/lib/esm/Context.d.ts +219 -0
  32. package/lib/esm/Context.d.ts.map +1 -0
  33. package/lib/esm/Context.js +321 -0
  34. package/lib/esm/Context.js.map +1 -0
  35. package/lib/esm/DelayedPromise.d.ts +89 -0
  36. package/lib/esm/DelayedPromise.d.ts.map +1 -0
  37. package/lib/esm/DelayedPromise.js +88 -0
  38. package/lib/esm/DelayedPromise.js.map +1 -0
  39. package/lib/esm/Deserialization/AbstractParser.d.ts +46 -0
  40. package/lib/esm/Deserialization/AbstractParser.d.ts.map +1 -0
  41. package/lib/esm/Deserialization/AbstractParser.js +8 -0
  42. package/lib/esm/Deserialization/AbstractParser.js.map +1 -0
  43. package/lib/esm/Deserialization/Helper.d.ts +263 -0
  44. package/lib/esm/Deserialization/Helper.d.ts.map +1 -0
  45. package/lib/esm/Deserialization/Helper.js +871 -0
  46. package/lib/esm/Deserialization/Helper.js.map +1 -0
  47. package/lib/esm/Deserialization/JsonParser.d.ts +166 -0
  48. package/lib/esm/Deserialization/JsonParser.d.ts.map +1 -0
  49. package/lib/esm/Deserialization/JsonParser.js +677 -0
  50. package/lib/esm/Deserialization/JsonParser.js.map +1 -0
  51. package/lib/esm/Deserialization/JsonProps.d.ts +273 -0
  52. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -0
  53. package/lib/esm/Deserialization/JsonProps.js +9 -0
  54. package/lib/esm/Deserialization/JsonProps.js.map +1 -0
  55. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts +35 -0
  56. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts.map +1 -0
  57. package/lib/esm/Deserialization/SchemaGraphUtil.js +74 -0
  58. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -0
  59. package/lib/esm/Deserialization/XmlParser.d.ts +86 -0
  60. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -0
  61. package/lib/esm/Deserialization/XmlParser.js +970 -0
  62. package/lib/esm/Deserialization/XmlParser.js.map +1 -0
  63. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +55 -0
  64. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -0
  65. package/lib/esm/Deserialization/XmlSerializationUtils.js +172 -0
  66. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -0
  67. package/lib/esm/ECName.d.ts +31 -0
  68. package/lib/esm/ECName.d.ts.map +1 -0
  69. package/lib/esm/ECName.js +82 -0
  70. package/lib/esm/ECName.js.map +1 -0
  71. package/lib/esm/ECObjects.d.ts +166 -0
  72. package/lib/esm/ECObjects.d.ts.map +1 -0
  73. package/lib/esm/ECObjects.js +422 -0
  74. package/lib/esm/ECObjects.js.map +1 -0
  75. package/lib/esm/Exception.d.ts +45 -0
  76. package/lib/esm/Exception.d.ts.map +1 -0
  77. package/lib/esm/Exception.js +82 -0
  78. package/lib/esm/Exception.js.map +1 -0
  79. package/lib/esm/Interfaces.d.ts +79 -0
  80. package/lib/esm/Interfaces.d.ts.map +1 -0
  81. package/lib/esm/Interfaces.js +9 -0
  82. package/lib/esm/Interfaces.js.map +1 -0
  83. package/lib/esm/Metadata/Class.d.ts +245 -0
  84. package/lib/esm/Metadata/Class.d.ts.map +1 -0
  85. package/lib/esm/Metadata/Class.js +552 -0
  86. package/lib/esm/Metadata/Class.js.map +1 -0
  87. package/lib/esm/Metadata/Constant.d.ts +65 -0
  88. package/lib/esm/Metadata/Constant.d.ts.map +1 -0
  89. package/lib/esm/Metadata/Constant.js +119 -0
  90. package/lib/esm/Metadata/Constant.js.map +1 -0
  91. package/lib/esm/Metadata/CustomAttribute.d.ts +24 -0
  92. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -0
  93. package/lib/esm/Metadata/CustomAttribute.js +24 -0
  94. package/lib/esm/Metadata/CustomAttribute.js.map +1 -0
  95. package/lib/esm/Metadata/CustomAttributeClass.d.ts +44 -0
  96. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -0
  97. package/lib/esm/Metadata/CustomAttributeClass.js +70 -0
  98. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -0
  99. package/lib/esm/Metadata/EntityClass.d.ts +78 -0
  100. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -0
  101. package/lib/esm/Metadata/EntityClass.js +224 -0
  102. package/lib/esm/Metadata/EntityClass.js.map +1 -0
  103. package/lib/esm/Metadata/Enumeration.d.ts +87 -0
  104. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -0
  105. package/lib/esm/Metadata/Enumeration.js +155 -0
  106. package/lib/esm/Metadata/Enumeration.js.map +1 -0
  107. package/lib/esm/Metadata/Format.d.ts +99 -0
  108. package/lib/esm/Metadata/Format.d.ts.map +1 -0
  109. package/lib/esm/Metadata/Format.js +238 -0
  110. package/lib/esm/Metadata/Format.js.map +1 -0
  111. package/lib/esm/Metadata/InvertedUnit.d.ts +50 -0
  112. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -0
  113. package/lib/esm/Metadata/InvertedUnit.js +93 -0
  114. package/lib/esm/Metadata/InvertedUnit.js.map +1 -0
  115. package/lib/esm/Metadata/KindOfQuantity.d.ts +72 -0
  116. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -0
  117. package/lib/esm/Metadata/KindOfQuantity.js +229 -0
  118. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -0
  119. package/lib/esm/Metadata/Mixin.d.ts +55 -0
  120. package/lib/esm/Metadata/Mixin.d.ts.map +1 -0
  121. package/lib/esm/Metadata/Mixin.js +109 -0
  122. package/lib/esm/Metadata/Mixin.js.map +1 -0
  123. package/lib/esm/Metadata/OverrideFormat.d.ts +68 -0
  124. package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -0
  125. package/lib/esm/Metadata/OverrideFormat.js +124 -0
  126. package/lib/esm/Metadata/OverrideFormat.js.map +1 -0
  127. package/lib/esm/Metadata/Phenomenon.d.ts +34 -0
  128. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -0
  129. package/lib/esm/Metadata/Phenomenon.js +55 -0
  130. package/lib/esm/Metadata/Phenomenon.js.map +1 -0
  131. package/lib/esm/Metadata/Property.d.ts +247 -0
  132. package/lib/esm/Metadata/Property.d.ts.map +1 -0
  133. package/lib/esm/Metadata/Property.js +565 -0
  134. package/lib/esm/Metadata/Property.js.map +1 -0
  135. package/lib/esm/Metadata/PropertyCategory.d.ts +40 -0
  136. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -0
  137. package/lib/esm/Metadata/PropertyCategory.js +57 -0
  138. package/lib/esm/Metadata/PropertyCategory.js.map +1 -0
  139. package/lib/esm/Metadata/RelationshipClass.d.ts +170 -0
  140. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -0
  141. package/lib/esm/Metadata/RelationshipClass.js +380 -0
  142. package/lib/esm/Metadata/RelationshipClass.js.map +1 -0
  143. package/lib/esm/Metadata/Schema.d.ts +330 -0
  144. package/lib/esm/Metadata/Schema.d.ts.map +1 -0
  145. package/lib/esm/Metadata/Schema.js +570 -0
  146. package/lib/esm/Metadata/Schema.js.map +1 -0
  147. package/lib/esm/Metadata/SchemaItem.d.ts +67 -0
  148. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -0
  149. package/lib/esm/Metadata/SchemaItem.js +140 -0
  150. package/lib/esm/Metadata/SchemaItem.js.map +1 -0
  151. package/lib/esm/Metadata/Unit.d.ts +77 -0
  152. package/lib/esm/Metadata/Unit.d.ts.map +1 -0
  153. package/lib/esm/Metadata/Unit.js +158 -0
  154. package/lib/esm/Metadata/Unit.js.map +1 -0
  155. package/lib/esm/Metadata/UnitSystem.d.ts +21 -0
  156. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -0
  157. package/lib/esm/Metadata/UnitSystem.js +25 -0
  158. package/lib/esm/Metadata/UnitSystem.js.map +1 -0
  159. package/lib/esm/PropertyTypes.d.ts +50 -0
  160. package/lib/esm/PropertyTypes.d.ts.map +1 -0
  161. package/lib/esm/PropertyTypes.js +88 -0
  162. package/lib/esm/PropertyTypes.js.map +1 -0
  163. package/lib/esm/SchemaJsonLocater.d.ts +42 -0
  164. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -0
  165. package/lib/esm/SchemaJsonLocater.js +54 -0
  166. package/lib/esm/SchemaJsonLocater.js.map +1 -0
  167. package/lib/esm/SchemaKey.d.ts +111 -0
  168. package/lib/esm/SchemaKey.d.ts.map +1 -0
  169. package/lib/esm/SchemaKey.js +214 -0
  170. package/lib/esm/SchemaKey.js.map +1 -0
  171. package/lib/esm/SchemaLoader.d.ts +32 -0
  172. package/lib/esm/SchemaLoader.d.ts.map +1 -0
  173. package/lib/esm/SchemaLoader.js +53 -0
  174. package/lib/esm/SchemaLoader.js.map +1 -0
  175. package/lib/esm/SchemaPartVisitorDelegate.d.ts +275 -0
  176. package/lib/esm/SchemaPartVisitorDelegate.d.ts.map +1 -0
  177. package/lib/esm/SchemaPartVisitorDelegate.js +209 -0
  178. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -0
  179. package/lib/esm/UnitConversion/Graph.d.ts +35 -0
  180. package/lib/esm/UnitConversion/Graph.d.ts.map +1 -0
  181. package/lib/esm/UnitConversion/Graph.js +80 -0
  182. package/lib/esm/UnitConversion/Graph.js.map +1 -0
  183. package/lib/esm/UnitConversion/Parser.d.ts +9 -0
  184. package/lib/esm/UnitConversion/Parser.d.ts.map +1 -0
  185. package/lib/esm/UnitConversion/Parser.js +39 -0
  186. package/lib/esm/UnitConversion/Parser.js.map +1 -0
  187. package/lib/esm/UnitConversion/UnitConversion.d.ts +46 -0
  188. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -0
  189. package/lib/esm/UnitConversion/UnitConversion.js +74 -0
  190. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -0
  191. package/lib/esm/UnitConversion/UnitConverter.d.ts +40 -0
  192. package/lib/esm/UnitConversion/UnitConverter.d.ts.map +1 -0
  193. package/lib/esm/UnitConversion/UnitConverter.js +113 -0
  194. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -0
  195. package/lib/esm/UnitConversion/UnitTree.d.ts +44 -0
  196. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -0
  197. package/lib/esm/UnitConversion/UnitTree.js +165 -0
  198. package/lib/esm/UnitConversion/UnitTree.js.map +1 -0
  199. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts +78 -0
  200. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -0
  201. package/lib/esm/UnitProvider/SchemaUnitProvider.js +231 -0
  202. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -0
  203. package/lib/esm/Validation/SchemaWalker.d.ts +24 -0
  204. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -0
  205. package/lib/esm/Validation/SchemaWalker.js +50 -0
  206. package/lib/esm/Validation/SchemaWalker.js.map +1 -0
  207. package/lib/esm/ecschema-metadata.d.ts +52 -0
  208. package/lib/esm/ecschema-metadata.d.ts.map +1 -0
  209. package/lib/esm/ecschema-metadata.js +55 -0
  210. package/lib/esm/ecschema-metadata.js.map +1 -0
  211. package/lib/esm/utils/SchemaGraph.d.ts +44 -0
  212. package/lib/esm/utils/SchemaGraph.d.ts.map +1 -0
  213. package/lib/esm/utils/SchemaGraph.js +111 -0
  214. package/lib/esm/utils/SchemaGraph.js.map +1 -0
  215. package/package.json +9 -7
@@ -0,0 +1,214 @@
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
+ /** @packageDocumentation
6
+ * @module Metadata
7
+ */
8
+ import { SchemaMatchType } from "./ECObjects";
9
+ import { ECObjectsError, ECObjectsStatus } from "./Exception";
10
+ import { ECName } from "./ECName";
11
+ /**
12
+ * @beta
13
+ */
14
+ export class ECVersion {
15
+ /**
16
+ * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.
17
+ * @param read Can support up to 999.
18
+ * @param write Can support up to 999.
19
+ * @param minor Can support up to 9999999.
20
+ *
21
+ */
22
+ constructor(read, write, minor) {
23
+ this._read = 0;
24
+ this._write = 0;
25
+ this._minor = 0;
26
+ if (undefined !== read)
27
+ this._read = read;
28
+ if (undefined !== write)
29
+ this._write = write;
30
+ if (undefined !== minor)
31
+ this._minor = minor;
32
+ if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)
33
+ throw new ECObjectsError(ECObjectsStatus.InvalidECVersion);
34
+ }
35
+ get read() { return this._read; }
36
+ get write() { return this._write; }
37
+ get minor() { return this._minor; }
38
+ /**
39
+ * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.
40
+ * @note The default is to pad with zeroes.
41
+ * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.
42
+ */
43
+ toString(padZeroes = true) {
44
+ if (!padZeroes)
45
+ return `${this.read}.${this.write}.${this.minor}`;
46
+ const padWithZeroes = (num) => {
47
+ return (num < 10 ? "0" : "") + num;
48
+ };
49
+ return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;
50
+ }
51
+ /**
52
+ * Given a valid version string the
53
+ * @param versionString A valid version string of the format, 'RR.ww.mm'.
54
+ */
55
+ static fromString(versionString) {
56
+ const [read, write, minor] = versionString.split(".");
57
+ if (!read)
58
+ throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
59
+ if (!write)
60
+ throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);
61
+ if (!minor)
62
+ throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
63
+ return new ECVersion(+read, +write, +minor);
64
+ }
65
+ /**
66
+ * Compares two schema versions.
67
+ * @param rhs The schema to compare.
68
+ * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
69
+ */
70
+ compare(rhv) {
71
+ if (this.read !== rhv.read)
72
+ return this.read - rhv.read;
73
+ if (this.write !== rhv.write)
74
+ return this.write - rhv.write;
75
+ return this.minor - rhv.minor;
76
+ }
77
+ }
78
+ /**
79
+ * The SchemaKey contains a Schemas name and version.
80
+ * @beta
81
+ */
82
+ export class SchemaKey {
83
+ constructor(name, readOrVersion, writeVersion, minorVersion) {
84
+ this._name = new ECName(name);
85
+ if (readOrVersion !== undefined && typeof (readOrVersion) !== "number")
86
+ this._version = readOrVersion;
87
+ else
88
+ this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);
89
+ }
90
+ get version() { return this._version; }
91
+ get name() { return this._name.name; }
92
+ get readVersion() { return this.version.read; }
93
+ get writeVersion() { return this.version.write; }
94
+ get minorVersion() { return this.version.minor; }
95
+ /**
96
+ * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.
97
+ * @note The default is to pad the full name with zeroes.
98
+ * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.
99
+ */
100
+ toString(padZeroes = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }
101
+ static parseString(fullName) {
102
+ const keyPieces = fullName.split(".");
103
+ if (keyPieces.length !== 4)
104
+ throw new ECObjectsError(ECObjectsStatus.InvalidECName);
105
+ const schemaName = keyPieces[0];
106
+ const readVer = Number(keyPieces[1]);
107
+ const writeVer = Number(keyPieces[2]);
108
+ const minorVer = Number(keyPieces[3]);
109
+ return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));
110
+ }
111
+ /**
112
+ * Compares two schema names, case-insensitive.
113
+ * @return True if they match; otherwise, false.
114
+ */
115
+ compareByName(rhs) {
116
+ if (undefined === rhs)
117
+ return false;
118
+ if (typeof (rhs) === "string")
119
+ return rhs.toLowerCase() === this.name.toLowerCase();
120
+ return rhs.name.toLowerCase() === this.name.toLowerCase();
121
+ }
122
+ /**
123
+ * Compares two schema versions.
124
+ * @param rhs The schema to compare.
125
+ * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.
126
+ */
127
+ compareByVersion(rhs) {
128
+ return this.version.compare(rhs.version);
129
+ }
130
+ /**
131
+ *
132
+ * @param rhs The SchemaKey to compare with
133
+ * @param matchType The match type to use for comparison.
134
+ */
135
+ matches(rhs, matchType = SchemaMatchType.Identical) {
136
+ switch (matchType) {
137
+ case SchemaMatchType.Identical:
138
+ // TODO: if (this.checksum && rhs.checksum)
139
+ // TODO: return this.checksum === rhs.checksum;
140
+ return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
141
+ this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;
142
+ case SchemaMatchType.Exact:
143
+ return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
144
+ this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;
145
+ case SchemaMatchType.LatestReadCompatible:
146
+ if (!this.compareByName(rhs.name))
147
+ return false;
148
+ if (rhs.readVersion !== this.readVersion)
149
+ return false;
150
+ if (this.writeVersion === rhs.writeVersion)
151
+ return this.minorVersion >= rhs.minorVersion;
152
+ return this.writeVersion > rhs.writeVersion;
153
+ case SchemaMatchType.LatestWriteCompatible:
154
+ return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&
155
+ this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;
156
+ case SchemaMatchType.Latest:
157
+ return this.compareByName(rhs.name);
158
+ default:
159
+ return false;
160
+ }
161
+ }
162
+ /**
163
+ * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.
164
+ * @param props SchemaKeyProps
165
+ * @returns A SchemaKey object.
166
+ */
167
+ static fromJSON(props) {
168
+ return new SchemaKey(props.name, props.read, props.write, props.minor);
169
+ }
170
+ /**
171
+ * Save this SchemaKey's properties to an object for serializing to JSON.
172
+ */
173
+ toJSON() {
174
+ return {
175
+ name: this.name,
176
+ read: this.readVersion,
177
+ write: this.writeVersion,
178
+ minor: this.minorVersion,
179
+ };
180
+ }
181
+ }
182
+ /**
183
+ * The SchemaItemKey contains a SchemaItem's name and SchemaKey.
184
+ * @beta
185
+ */
186
+ export class SchemaItemKey {
187
+ constructor(name, schema) {
188
+ this._name = new ECName(name);
189
+ this._schemaKey = schema;
190
+ }
191
+ get schemaKey() { return this._schemaKey; }
192
+ get name() { return this._name.name; }
193
+ get schemaName() { return this.schemaKey.name; }
194
+ /** Returns the name in the format, {schemaName}.{name}. */
195
+ get fullName() { return `${this.schemaName}.${this.name}`; }
196
+ /**
197
+ * Checks whether this SchemaItemKey matches the one provided.
198
+ * @param rhs The SchemaItemKey to compare to this.
199
+ */
200
+ // TODO: Need to add a match type
201
+ matches(rhs) {
202
+ if (rhs.name !== this.name)
203
+ return false;
204
+ if (!rhs.schemaKey.matches(this.schemaKey, SchemaMatchType.Latest))
205
+ return false;
206
+ return true;
207
+ }
208
+ matchesFullName(name) {
209
+ const schemaVersion = this.schemaKey.version.toString().replace(/\./g, "\\.");
210
+ const fullNameRegex = new RegExp(`^${this.schemaName}(\\.${schemaVersion})?[.:]${this.name}$`, "i");
211
+ return fullNameRegex.test(name);
212
+ }
213
+ }
214
+ //# sourceMappingURL=SchemaKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaKey.js","sourceRoot":"","sources":["../../src/SchemaKey.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,MAAM,OAAO,SAAS;IAKpB;;;;;;OAMG;IACH,YAAY,IAAa,EAAE,KAAc,EAAE,KAAc;QAXjD,UAAK,GAAW,CAAC,CAAC;QAClB,WAAM,GAAW,CAAC,CAAC;QACnB,WAAM,GAAW,CAAC,CAAC;QAUzB,I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ED,IAAW,SAAS,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAClD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAE7C,IAAW,UAAU,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvD,2DAA2D;IAC3D,IAAW,QAAQ,KAAK,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEnE;;;OAGG;IACH,iCAAiC;IAC1B,OAAO,CAAC,GAAkB;QAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;YACxB,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC;YAChE,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,eAAe,CAAC,IAAY;QACjC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,OAAO,aAAa,SAAS,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;QACpG,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Metadata\r\n */\r\n\r\nimport { SchemaKeyProps } from \"./Deserialization/JsonProps\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { ECName } from \"./ECName\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class ECVersion {\r\n private _read: number = 0;\r\n private _write: number = 0;\r\n private _minor: number = 0;\r\n\r\n /**\r\n * The constructor will throw an ECObjectsError if any of the parameters below are above the threshold.\r\n * @param read Can support up to 999.\r\n * @param write Can support up to 999.\r\n * @param minor Can support up to 9999999.\r\n *\r\n */\r\n constructor(read?: number, write?: number, minor?: number) {\r\n if (undefined !== read)\r\n this._read = read;\r\n if (undefined !== write)\r\n this._write = write;\r\n if (undefined !== minor)\r\n this._minor = minor;\r\n\r\n if (this._read > 999 || this._read < 0 || this._write > 999 || this._write < 0 || this._minor > 9999999 || this._minor < 0)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion);\r\n }\r\n\r\n public get read() { return this._read; }\r\n public get write() { return this._write; }\r\n public get minor() { return this._minor; }\r\n\r\n /**\r\n * Creates a string, in the format 'RR.ww.mm', representing this ECVersion.\r\n * @note The default is to pad with zeroes.\r\n * @param padZeroes If true, the returned string will strictly follow `RR.ww.mm` and add leading zeroes if necessary.\r\n */\r\n public toString(padZeroes: boolean = true): string {\r\n if (!padZeroes)\r\n return `${this.read}.${this.write}.${this.minor}`;\r\n\r\n const padWithZeroes = (num: number) => {\r\n return (num < 10 ? \"0\" : \"\") + num;\r\n };\r\n\r\n return `${padWithZeroes(this.read)}.${padWithZeroes(this.write)}.${padWithZeroes(this.minor)}`;\r\n }\r\n\r\n /**\r\n * Given a valid version string the\r\n * @param versionString A valid version string of the format, 'RR.ww.mm'.\r\n */\r\n public static fromString(versionString: string): ECVersion {\r\n const [read, write, minor] = versionString.split(\".\");\r\n if (!read)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\r\n\r\n if (!write)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The write version is missing from version string, ${versionString}`);\r\n\r\n if (!minor)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\r\n\r\n return new ECVersion(+read, +write, +minor);\r\n }\r\n\r\n /**\r\n * Compares two schema versions.\r\n * @param rhs The schema to compare.\r\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\r\n */\r\n public compare(rhv: ECVersion): number {\r\n if (this.read !== rhv.read)\r\n return this.read - rhv.read;\r\n\r\n if (this.write !== rhv.write)\r\n return this.write - rhv.write;\r\n\r\n return this.minor - rhv.minor;\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaKey contains a Schemas name and version.\r\n * @beta\r\n */\r\nexport class SchemaKey {\r\n private _name: ECName;\r\n protected _version: ECVersion;\r\n // public checksum: number;\r\n // TODO: need to add a checksum\r\n\r\n constructor(name: string, version: ECVersion);\r\n constructor(name: string, readVersion?: number, writeVersion?: number, minorVersion?: number);\r\n constructor(name: string, readOrVersion?: number | ECVersion, writeVersion?: number, minorVersion?: number) {\r\n this._name = new ECName(name);\r\n if (readOrVersion !== undefined && typeof (readOrVersion) !== \"number\")\r\n this._version = readOrVersion;\r\n else\r\n this._version = new ECVersion(readOrVersion, writeVersion, minorVersion);\r\n }\r\n\r\n public get version() { return this._version; }\r\n public get name() { return this._name.name; }\r\n public get readVersion() { return this.version.read; }\r\n public get writeVersion() { return this.version.write; }\r\n public get minorVersion() { return this.version.minor; }\r\n\r\n /**\r\n * Creates a string, in the format 'RR.ww.mm', representing this SchemaKey.\r\n * @note The default is to pad the full name with zeroes.\r\n * @param padZeroes If true, the returned string will strictly follow `Name.RR.ww.mm` and add leading zeroes if necessary.\r\n */\r\n public toString(padZeroes: boolean = true) { return `${this.name}.${this.version.toString(padZeroes)}`; }\r\n\r\n public static parseString(fullName: string) {\r\n const keyPieces = fullName.split(\".\");\r\n if (keyPieces.length !== 4)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECName);\r\n\r\n const schemaName = keyPieces[0];\r\n const readVer = Number(keyPieces[1]);\r\n const writeVer = Number(keyPieces[2]);\r\n const minorVer = Number(keyPieces[3]);\r\n return new SchemaKey(schemaName, new ECVersion(readVer, writeVer, minorVer));\r\n }\r\n\r\n /**\r\n * Compares two schema names, case-insensitive.\r\n * @return True if they match; otherwise, false.\r\n */\r\n public compareByName(rhs: SchemaKey | string | undefined): boolean {\r\n if (undefined === rhs)\r\n return false;\r\n\r\n if (typeof (rhs) === \"string\")\r\n return rhs.toLowerCase() === this.name.toLowerCase();\r\n\r\n return rhs.name.toLowerCase() === this.name.toLowerCase();\r\n }\r\n\r\n /**\r\n * Compares two schema versions.\r\n * @param rhs The schema to compare.\r\n * @return A negative number if this schema version is less than the given version, a positive number if greater, and 0 if are equivalent.\r\n */\r\n public compareByVersion(rhs: SchemaKey): number {\r\n return this.version.compare(rhs.version);\r\n }\r\n\r\n /**\r\n *\r\n * @param rhs The SchemaKey to compare with\r\n * @param matchType The match type to use for comparison.\r\n */\r\n public matches(rhs: Readonly<SchemaKey>, matchType: SchemaMatchType = SchemaMatchType.Identical): boolean {\r\n switch (matchType) {\r\n case SchemaMatchType.Identical:\r\n // TODO: if (this.checksum && rhs.checksum)\r\n // TODO: return this.checksum === rhs.checksum;\r\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\r\n this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;\r\n case SchemaMatchType.Exact:\r\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\r\n this.writeVersion === rhs.writeVersion && this.minorVersion === rhs.minorVersion;\r\n case SchemaMatchType.LatestReadCompatible:\r\n if (!this.compareByName(rhs.name))\r\n return false;\r\n\r\n if (rhs.readVersion !== this.readVersion)\r\n return false;\r\n\r\n if (this.writeVersion === rhs.writeVersion)\r\n return this.minorVersion >= rhs.minorVersion;\r\n\r\n return this.writeVersion > rhs.writeVersion;\r\n case SchemaMatchType.LatestWriteCompatible:\r\n return this.compareByName(rhs.name) && this.readVersion === rhs.readVersion &&\r\n this.writeVersion === rhs.writeVersion && this.minorVersion >= rhs.minorVersion;\r\n case SchemaMatchType.Latest:\r\n return this.compareByName(rhs.name);\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Deserializes a SchemaKeyProps JSON object into a SchemaKey object.\r\n * @param props SchemaKeyProps\r\n * @returns A SchemaKey object.\r\n */\r\n public static fromJSON(props: SchemaKeyProps): SchemaKey {\r\n return new SchemaKey(props.name, props.read, props.write, props.minor);\r\n }\r\n\r\n /**\r\n * Save this SchemaKey's properties to an object for serializing to JSON.\r\n */\r\n public toJSON(): SchemaKeyProps {\r\n return {\r\n name: this.name,\r\n read: this.readVersion,\r\n write: this.writeVersion,\r\n minor: this.minorVersion,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaItemKey contains a SchemaItem's name and SchemaKey.\r\n * @beta\r\n */\r\nexport class SchemaItemKey {\r\n private _name: ECName;\r\n protected _schemaKey: SchemaKey;\r\n\r\n constructor(name: string, schema: SchemaKey) {\r\n this._name = new ECName(name);\r\n this._schemaKey = schema;\r\n }\r\n\r\n public get schemaKey() { return this._schemaKey; }\r\n public get name() { return this._name.name; }\r\n\r\n public get schemaName() { return this.schemaKey.name; }\r\n\r\n /** Returns the name in the format, {schemaName}.{name}. */\r\n public get fullName() { return `${this.schemaName}.${this.name}`; }\r\n\r\n /**\r\n * Checks whether this SchemaItemKey matches the one provided.\r\n * @param rhs The SchemaItemKey to compare to this.\r\n */\r\n // TODO: Need to add a match type\r\n public matches(rhs: SchemaItemKey): boolean {\r\n if (rhs.name !== this.name)\r\n return false;\r\n\r\n if (!rhs.schemaKey.matches(this.schemaKey, SchemaMatchType.Latest))\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n public matchesFullName(name: string): boolean {\r\n const schemaVersion = this.schemaKey.version.toString().replace(/\\./g, \"\\\\.\");\r\n const fullNameRegex = new RegExp(`^${this.schemaName}(\\\\.${schemaVersion})?[.:]${this.name}$`, \"i\");\r\n return fullNameRegex.test(name);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,32 @@
1
+ import { SchemaContext } from "./Context";
2
+ import { Schema } from "./Metadata/Schema";
3
+ import { SchemaPropsGetter } from "./SchemaJsonLocater";
4
+ /**
5
+ * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.
6
+ * Loaded schemas are held in memory within a schema context managed by SchemaLoader.
7
+ * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
8
+ * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
9
+ *
10
+ * ** Example **
11
+ * ```ts
12
+ * [[include:IModelSchemas.loadFromDb]]
13
+ * ```
14
+ * @beta
15
+ */
16
+ export declare class SchemaLoader {
17
+ private _context;
18
+ constructor(getSchema: SchemaPropsGetter);
19
+ /** Get a schema by name
20
+ * @param schemaName a string with the name of the schema to load.
21
+ * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.
22
+ */
23
+ getSchema<T extends Schema>(schemaName: string): T;
24
+ /** Attempts to get a schema by name
25
+ * @param schemaName a string with the name of the schema to load.
26
+ * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
27
+ */
28
+ tryGetSchema<T extends Schema>(schemaName: string): T | undefined;
29
+ /** Gets the SchemaContext used by the loader. */
30
+ get context(): SchemaContext;
31
+ }
32
+ //# sourceMappingURL=SchemaLoader.d.ts.map
@@ -0,0 +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,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;IAQzD;;;OAGG;IACI,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAOxE,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
@@ -0,0 +1,53 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { SchemaContext } from "./Context";
6
+ import { SchemaMatchType } from "./ECObjects";
7
+ import { ECObjectsError, ECObjectsStatus } from "./Exception";
8
+ import { SchemaJsonLocater } from "./SchemaJsonLocater";
9
+ import { ECVersion, SchemaKey } from "./SchemaKey";
10
+ /**
11
+ * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.
12
+ * Loaded schemas are held in memory within a schema context managed by SchemaLoader.
13
+ * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
14
+ * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
15
+ *
16
+ * ** Example **
17
+ * ```ts
18
+ * [[include:IModelSchemas.loadFromDb]]
19
+ * ```
20
+ * @beta
21
+ */
22
+ export class SchemaLoader {
23
+ constructor(getSchema) {
24
+ this._context = new SchemaContext();
25
+ const locater = new SchemaJsonLocater(getSchema);
26
+ this._context.addLocater(locater);
27
+ }
28
+ /** Get a schema by name
29
+ * @param schemaName a string with the name of the schema to load.
30
+ * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.
31
+ */
32
+ getSchema(schemaName) {
33
+ const schema = this.tryGetSchema(schemaName);
34
+ if (!schema)
35
+ throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);
36
+ return schema;
37
+ }
38
+ /** Attempts to get a schema by name
39
+ * @param schemaName a string with the name of the schema to load.
40
+ * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
41
+ */
42
+ tryGetSchema(schemaName) {
43
+ // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.
44
+ const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));
45
+ const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);
46
+ return schema;
47
+ }
48
+ /** Gets the SchemaContext used by the loader. */
49
+ get context() {
50
+ return this._context;
51
+ }
52
+ }
53
+ //# sourceMappingURL=SchemaLoader.js.map
@@ -0,0 +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,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IAGvB,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,CAAmB,UAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAEjG,OAAO,MAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAmB,UAAkB;QACtD,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,MAAW,CAAC;IACrB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaContext } from \"./Context\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\r\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\r\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\r\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\r\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\r\n *\r\n * ** Example **\r\n * ```ts\r\n * [[include:IModelSchemas.loadFromDb]]\r\n * ```\r\n * @beta\r\n */\r\nexport class SchemaLoader {\r\n private _context: SchemaContext;\r\n\r\n public constructor(getSchema: SchemaPropsGetter) {\r\n this._context = new SchemaContext();\r\n const locater = new SchemaJsonLocater(getSchema);\r\n this._context.addLocater(locater);\r\n }\r\n\r\n /** Get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.\r\n */\r\n public getSchema<T extends Schema>(schemaName: string): T {\r\n const schema = this.tryGetSchema(schemaName);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\r\n\r\n return schema as T;\r\n }\r\n\r\n /** Attempts to get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public tryGetSchema<T extends Schema>(schemaName: string): T | undefined {\r\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\r\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\r\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema as T;\r\n }\r\n\r\n /** Gets the SchemaContext used by the loader. */\r\n public get context(): SchemaContext {\r\n return this._context;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,275 @@
1
+ import { AnyClass, AnyECType } from "./Interfaces";
2
+ import { StructClass } from "./Metadata/Class";
3
+ import { Constant } from "./Metadata/Constant";
4
+ import { CustomAttributeContainerProps } from "./Metadata/CustomAttribute";
5
+ import { CustomAttributeClass } from "./Metadata/CustomAttributeClass";
6
+ import { EntityClass } from "./Metadata/EntityClass";
7
+ import { Enumeration } from "./Metadata/Enumeration";
8
+ import { Format } from "./Metadata/Format";
9
+ import { InvertedUnit } from "./Metadata/InvertedUnit";
10
+ import { KindOfQuantity } from "./Metadata/KindOfQuantity";
11
+ import { Mixin } from "./Metadata/Mixin";
12
+ import { Phenomenon } from "./Metadata/Phenomenon";
13
+ import { AnyProperty } from "./Metadata/Property";
14
+ import { PropertyCategory } from "./Metadata/PropertyCategory";
15
+ import { RelationshipClass, RelationshipConstraint } from "./Metadata/RelationshipClass";
16
+ import { Schema } from "./Metadata/Schema";
17
+ import { SchemaItem } from "./Metadata/SchemaItem";
18
+ import { Unit } from "./Metadata/Unit";
19
+ import { UnitSystem } from "./Metadata/UnitSystem";
20
+ /**
21
+ * Interface to allow schema traversal/deserialization workflows to visit
22
+ * each part, item, class, etc. that exists in a given schema.
23
+ * @beta
24
+ */
25
+ export interface ISchemaPartVisitor {
26
+ /**
27
+ * Called for a partially loaded schema. During deserialization, this would
28
+ * be after a schema and all its references are deserialized, but _before_
29
+ * any of its items or custom attributes have been deserialized.
30
+ * @param schema A partially-loaded Schema.
31
+ */
32
+ visitEmptySchema?: (schema: Schema) => Promise<void>;
33
+ /**
34
+ * Called for a partially loaded schema. During deserialization, this would
35
+ * be after a schema and all its references are deserialized, but _before_
36
+ * any of its items or custom attributes have been deserialized.
37
+ * @param schema A partially-loaded Schema.
38
+ */
39
+ visitEmptySchemaSync?: (schema: Schema) => void;
40
+ /**
41
+ * Called for a fully loaded schema.
42
+ * @param schema A fully-loaded Schema.
43
+ */
44
+ visitFullSchema?: (schema: Schema) => Promise<void>;
45
+ /**
46
+ * Called for a fully loaded schema.
47
+ * @param schema A fully-loaded Schema.
48
+ */
49
+ visitFullSchemaSync?: (schema: Schema) => void;
50
+ /**
51
+ * Called for each [[SchemaItem]] instance.
52
+ * @param schemaItem a SchemaItem object.
53
+ */
54
+ visitSchemaItem?: (schemaItem: SchemaItem) => Promise<void>;
55
+ /**
56
+ * Called for each [[SchemaItem]] instance.
57
+ * @param schemaItem a SchemaItem object.
58
+ */
59
+ visitSchemaItemSync?: (schemaItem: SchemaItem) => void;
60
+ /**
61
+ * Called for each [[AnyClass]] instance.
62
+ * @param ecClass an ECClass object.
63
+ */
64
+ visitClass?: (ecClass: AnyClass) => Promise<void>;
65
+ /**
66
+ * Called for each [[AnyClass]] instance.
67
+ * @param ecClass an ECClass object.
68
+ */
69
+ visitClassSync?: (ecClass: AnyClass) => void;
70
+ /**
71
+ * Called for each [[AnyProperty]] instance of an ECClass.
72
+ * @param property an AnyProperty object.
73
+ */
74
+ visitProperty?: (property: AnyProperty) => Promise<void>;
75
+ /**
76
+ * Called for each [[AnyProperty]] instance of an ECClass.
77
+ * @param property an AnyProperty object.
78
+ */
79
+ visitPropertySync?: (property: AnyProperty) => void;
80
+ /**
81
+ * Called for each [[EntityClass]] instance.
82
+ * @param entityClass an EntityClass object.
83
+ */
84
+ visitEntityClass?: (entityClass: EntityClass) => Promise<void>;
85
+ /**
86
+ * Called for each [[EntityClass]] instance.
87
+ * @param entityClass an EntityClass object.
88
+ */
89
+ visitEntityClassSync?: (entityClass: EntityClass) => void;
90
+ /**
91
+ * Called for each [[StructClass]] instance.
92
+ * @param structClass a StructClass object.
93
+ */
94
+ visitStructClass?: (structClass: StructClass) => Promise<void>;
95
+ /**
96
+ * Called for each [[StructClass]] instance.
97
+ * @param structClass a StructClass object.
98
+ */
99
+ visitStructClassSync?: (structClass: StructClass) => void;
100
+ /**
101
+ * Called for each [[Mixin]] instance.
102
+ * @param mixin a Mixin object.
103
+ */
104
+ visitMixin?: (mixin: Mixin) => Promise<void>;
105
+ /**
106
+ * Called for each [[Mixin]] instance.
107
+ * @param mixin a Mixin object.
108
+ */
109
+ visitMixinSync?: (mixin: Mixin) => void;
110
+ /**
111
+ * Called for each [[RelationshipClass]] instance.
112
+ * @param relationshipClass a RelationshipClass object.
113
+ */
114
+ visitRelationshipClass?: (relationshipClass: RelationshipClass) => Promise<void>;
115
+ /**
116
+ * Called for each [[RelationshipClass]] instance.
117
+ * @param relationshipClass a RelationshipClass object.
118
+ */
119
+ visitRelationshipClassSync?: (relationshipClass: RelationshipClass) => void;
120
+ /**
121
+ * Called for each [[RelationshipConstraint]] of each RelationshipClass.
122
+ * @param relationshipConstraint a RelationshipConstraint object.
123
+ */
124
+ visitRelationshipConstraint?: (relationshipConstraint: RelationshipConstraint) => Promise<void>;
125
+ /**
126
+ * Called for each [[RelationshipConstraint]] of each RelationshipClass.
127
+ * @param relationshipConstraint a RelationshipConstraint object.
128
+ */
129
+ visitRelationshipConstraintSync?: (relationshipConstraint: RelationshipConstraint) => void;
130
+ /**
131
+ * Called for each [[CustomAttributeClass]] instance.
132
+ * @param customAttributeClass a CustomAttributeClass object.
133
+ */
134
+ visitCustomAttributeClass?: (customAttributeClass: CustomAttributeClass) => Promise<void>;
135
+ /**
136
+ * Called for each [[CustomAttributeClass]] instance.
137
+ * @param customAttributeClass a CustomAttributeClass object.
138
+ */
139
+ visitCustomAttributeClassSync?: (customAttributeClass: CustomAttributeClass) => void;
140
+ /**
141
+ * Called for each CustomAttribute container in the schema.
142
+ * @param customAttributeContainer a CustomAttributeContainerProps object.
143
+ */
144
+ visitCustomAttributeContainer?: (customAttributeContainer: CustomAttributeContainerProps) => Promise<void>;
145
+ /**
146
+ * Called for each CustomAttribute container in the schema.
147
+ * @param customAttributeContainer a CustomAttributeContainerProps object.
148
+ */
149
+ visitCustomAttributeContainerSync?: (customAttributeContainer: CustomAttributeContainerProps) => void;
150
+ /**
151
+ * Called for each [[Enumeration]] instance.
152
+ * @param enumeration an Enumeration object.
153
+ */
154
+ visitEnumeration?: (enumeration: Enumeration) => Promise<void>;
155
+ /**
156
+ * Called for each [[Enumeration]] instance.
157
+ * @param enumeration an Enumeration object.
158
+ */
159
+ visitEnumerationSync?: (enumeration: Enumeration) => void;
160
+ /**
161
+ * Called for each [[KindOfQuantity]] instance.
162
+ * @param koq a KindOfQuantity object.
163
+ */
164
+ visitKindOfQuantity?: (koq: KindOfQuantity) => Promise<void>;
165
+ /**
166
+ * Called for each [[KindOfQuantity]] instance.
167
+ * @param koq a KindOfQuantity object.
168
+ */
169
+ visitKindOfQuantitySync?: (koq: KindOfQuantity) => void;
170
+ /**
171
+ * Called for each [[PropertyCategory]] instance.
172
+ * @param category a PropertyCategory object.
173
+ */
174
+ visitPropertyCategory?: (category: PropertyCategory) => Promise<void>;
175
+ /**
176
+ * Called for each [[PropertyCategory]] instance.
177
+ * @param category a PropertyCategory object.
178
+ */
179
+ visitPropertyCategorySync?: (category: PropertyCategory) => void;
180
+ /**
181
+ * Called for each [[Format]] instance.
182
+ * @param format a Format object.
183
+ */
184
+ visitFormat?: (format: Format) => Promise<void>;
185
+ /**
186
+ * Called for each [[Format]] instance.
187
+ * @param format a Format object.
188
+ */
189
+ visitFormatSync?: (format: Format) => void;
190
+ /**
191
+ * Called for each [[Unit]] instance.
192
+ * @param unit a Unit object.
193
+ */
194
+ visitUnit?: (unit: Unit) => Promise<void>;
195
+ /**
196
+ * Called for each [[Unit]] instance.
197
+ * @param unit a Unit object.
198
+ */
199
+ visitUnitSync?: (unit: Unit) => void;
200
+ /**
201
+ * Called for each [[InvertedUnit]] instance.
202
+ * @param invertedUnit an InvertedUnit object.
203
+ */
204
+ visitInvertedUnit?: (invertedUnit: InvertedUnit) => Promise<void>;
205
+ /**
206
+ * Called for each [[InvertedUnit]] instance.
207
+ * @param invertedUnit an InvertedUnit object.
208
+ */
209
+ visitInvertedUnitSync?: (invertedUnit: InvertedUnit) => void;
210
+ /**
211
+ * Called for each [[UnitSystem]] instance.
212
+ * @param unitSystem a UnitSystem object.
213
+ */
214
+ visitUnitSystem?: (unitSystem: UnitSystem) => Promise<void>;
215
+ /**
216
+ * Called for each [[UnitSystem]] instance.
217
+ * @param unitSystem a UnitSystem object.
218
+ */
219
+ visitUnitSystemSync?: (unitSystem: UnitSystem) => void;
220
+ /**
221
+ * Called for each [[Phenomenon]] instance.
222
+ * @param phenomena a Phenomenon object.
223
+ */
224
+ visitPhenomenon?: (phenomena: Phenomenon) => Promise<void>;
225
+ /**
226
+ * Called for each [[Phenomenon]] instance.
227
+ * @param phenomena a Phenomenon object.
228
+ */
229
+ visitPhenomenonSync?: (phenomena: Phenomenon) => void;
230
+ /**
231
+ * Called for each [[Constant]] instance.
232
+ * @param constant a Constant object.
233
+ */
234
+ visitConstant?: (constant: Constant) => Promise<void>;
235
+ /**
236
+ * Called for each [[Constant]] instance.
237
+ * @param constant a Constant object.
238
+ */
239
+ visitConstantSync?: (constant: Constant) => void;
240
+ }
241
+ /**
242
+ * A helper class to call methods on the provided [[ISchemaPartVisitor]].
243
+ * @beta
244
+ */
245
+ export declare class SchemaPartVisitorDelegate {
246
+ private _visitor;
247
+ constructor(visitor: ISchemaPartVisitor);
248
+ /**
249
+ * Calls (async) visitEmptySchema or visitFullSchema on the configured [[ISchemaPartVisitor]].
250
+ * @param schema The schema to pass to the visitor.
251
+ * @param fullSchema Indicates if the schema is partially or fully-loaded.
252
+ */
253
+ visitSchema(schema: Schema, fullSchema?: boolean): Promise<void>;
254
+ /**
255
+ * Calls (synchronously) visitEmptySchema or visitFullSchema on the configured [[ISchemaPartVisitor]].
256
+ * @param schema The schema to pass to the visitor.
257
+ * @param fullSchema Indicates if the schema is partially or fully-loaded.
258
+ */
259
+ visitSchemaSync(schema: Schema, fullSchema?: boolean): void;
260
+ /**
261
+ * Calls (async) the appropriate visit methods on the configured [[ISchemaPartVisitor]]
262
+ * based on the type of the part specified.
263
+ * @param schemaPart The schema part to pass to the visitor methods.
264
+ */
265
+ visitSchemaPart(schemaPart: AnyECType): Promise<void>;
266
+ /**
267
+ * Calls (synchronously) the appropriate visit methods on the configured [[ISchemaPartVisitor]]
268
+ * based on the type of the part specified.
269
+ * @param schemaPart The schema part to pass to the visitor methods.
270
+ */
271
+ visitSchemaPartSync(schemaPart: AnyECType): void;
272
+ private visitSchemaItem;
273
+ private visitSchemaItemSync;
274
+ }
275
+ //# sourceMappingURL=SchemaPartVisitorDelegate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaPartVisitorDelegate.d.ts","sourceRoot":"","sources":["../../src/SchemaPartVisitorDelegate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAW,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC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