@itwin/ecschema-metadata 4.8.0-dev.9 → 4.9.0-dev.1

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 (251) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Constants.js.map +1 -1
  3. package/lib/cjs/DelayedPromise.js.map +1 -1
  4. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  5. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  6. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  7. package/lib/cjs/Deserialization/JsonProps.d.ts +4 -0
  8. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  9. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  10. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  11. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  12. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  13. package/lib/cjs/ECName.js.map +1 -1
  14. package/lib/cjs/ECObjects.js.map +1 -1
  15. package/lib/cjs/Exception.js.map +1 -1
  16. package/lib/cjs/Interfaces.js.map +1 -1
  17. package/lib/cjs/Metadata/Class.d.ts +0 -6
  18. package/lib/cjs/Metadata/Class.d.ts.map +1 -1
  19. package/lib/cjs/Metadata/Class.js +0 -8
  20. package/lib/cjs/Metadata/Class.js.map +1 -1
  21. package/lib/cjs/Metadata/Constant.js.map +1 -1
  22. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  23. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +7 -3
  24. package/lib/cjs/Metadata/CustomAttributeClass.d.ts.map +1 -1
  25. package/lib/cjs/Metadata/CustomAttributeClass.js +16 -10
  26. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  27. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  28. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  29. package/lib/cjs/Metadata/Format.js.map +1 -1
  30. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  31. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  32. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  33. package/lib/cjs/Metadata/OverrideFormat.d.ts.map +1 -1
  34. package/lib/cjs/Metadata/OverrideFormat.js +3 -1
  35. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  36. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  37. package/lib/cjs/Metadata/Property.js.map +1 -1
  38. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  39. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  40. package/lib/cjs/Metadata/Schema.d.ts +14 -0
  41. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  42. package/lib/cjs/Metadata/Schema.js +21 -0
  43. package/lib/cjs/Metadata/Schema.js.map +1 -1
  44. package/lib/cjs/Metadata/SchemaItem.d.ts +5 -0
  45. package/lib/cjs/Metadata/SchemaItem.d.ts.map +1 -1
  46. package/lib/cjs/Metadata/SchemaItem.js +7 -0
  47. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  48. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  49. package/lib/cjs/PropertyTypes.js.map +1 -1
  50. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  51. package/lib/cjs/SchemaKey.js.map +1 -1
  52. package/lib/cjs/SchemaLoader.js.map +1 -1
  53. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  54. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  55. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  56. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  57. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  58. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  59. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  60. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  61. package/lib/cjs/ecschema-metadata.js.map +1 -1
  62. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  63. package/lib/esm/Constants.d.ts +24 -0
  64. package/lib/esm/Constants.d.ts.map +1 -0
  65. package/lib/esm/Constants.js +30 -0
  66. package/lib/esm/Constants.js.map +1 -0
  67. package/lib/esm/Context.d.ts +219 -0
  68. package/lib/esm/Context.d.ts.map +1 -0
  69. package/lib/esm/Context.js +321 -0
  70. package/lib/esm/Context.js.map +1 -0
  71. package/lib/esm/DelayedPromise.d.ts +89 -0
  72. package/lib/esm/DelayedPromise.d.ts.map +1 -0
  73. package/lib/esm/DelayedPromise.js +88 -0
  74. package/lib/esm/DelayedPromise.js.map +1 -0
  75. package/lib/esm/Deserialization/AbstractParser.d.ts +46 -0
  76. package/lib/esm/Deserialization/AbstractParser.d.ts.map +1 -0
  77. package/lib/esm/Deserialization/AbstractParser.js +8 -0
  78. package/lib/esm/Deserialization/AbstractParser.js.map +1 -0
  79. package/lib/esm/Deserialization/Helper.d.ts +263 -0
  80. package/lib/esm/Deserialization/Helper.d.ts.map +1 -0
  81. package/lib/esm/Deserialization/Helper.js +871 -0
  82. package/lib/esm/Deserialization/Helper.js.map +1 -0
  83. package/lib/esm/Deserialization/JsonParser.d.ts +166 -0
  84. package/lib/esm/Deserialization/JsonParser.d.ts.map +1 -0
  85. package/lib/esm/Deserialization/JsonParser.js +677 -0
  86. package/lib/esm/Deserialization/JsonParser.js.map +1 -0
  87. package/lib/esm/Deserialization/JsonProps.d.ts +273 -0
  88. package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -0
  89. package/lib/esm/Deserialization/JsonProps.js +9 -0
  90. package/lib/esm/Deserialization/JsonProps.js.map +1 -0
  91. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts +35 -0
  92. package/lib/esm/Deserialization/SchemaGraphUtil.d.ts.map +1 -0
  93. package/lib/esm/Deserialization/SchemaGraphUtil.js +74 -0
  94. package/lib/esm/Deserialization/SchemaGraphUtil.js.map +1 -0
  95. package/lib/esm/Deserialization/XmlParser.d.ts +86 -0
  96. package/lib/esm/Deserialization/XmlParser.d.ts.map +1 -0
  97. package/lib/esm/Deserialization/XmlParser.js +970 -0
  98. package/lib/esm/Deserialization/XmlParser.js.map +1 -0
  99. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts +55 -0
  100. package/lib/esm/Deserialization/XmlSerializationUtils.d.ts.map +1 -0
  101. package/lib/esm/Deserialization/XmlSerializationUtils.js +172 -0
  102. package/lib/esm/Deserialization/XmlSerializationUtils.js.map +1 -0
  103. package/lib/esm/ECName.d.ts +31 -0
  104. package/lib/esm/ECName.d.ts.map +1 -0
  105. package/lib/esm/ECName.js +82 -0
  106. package/lib/esm/ECName.js.map +1 -0
  107. package/lib/esm/ECObjects.d.ts +166 -0
  108. package/lib/esm/ECObjects.d.ts.map +1 -0
  109. package/lib/esm/ECObjects.js +422 -0
  110. package/lib/esm/ECObjects.js.map +1 -0
  111. package/lib/esm/Exception.d.ts +45 -0
  112. package/lib/esm/Exception.d.ts.map +1 -0
  113. package/lib/esm/Exception.js +82 -0
  114. package/lib/esm/Exception.js.map +1 -0
  115. package/lib/esm/Interfaces.d.ts +79 -0
  116. package/lib/esm/Interfaces.d.ts.map +1 -0
  117. package/lib/esm/Interfaces.js +9 -0
  118. package/lib/esm/Interfaces.js.map +1 -0
  119. package/lib/esm/Metadata/Class.d.ts +245 -0
  120. package/lib/esm/Metadata/Class.d.ts.map +1 -0
  121. package/lib/esm/Metadata/Class.js +552 -0
  122. package/lib/esm/Metadata/Class.js.map +1 -0
  123. package/lib/esm/Metadata/Constant.d.ts +65 -0
  124. package/lib/esm/Metadata/Constant.d.ts.map +1 -0
  125. package/lib/esm/Metadata/Constant.js +119 -0
  126. package/lib/esm/Metadata/Constant.js.map +1 -0
  127. package/lib/esm/Metadata/CustomAttribute.d.ts +24 -0
  128. package/lib/esm/Metadata/CustomAttribute.d.ts.map +1 -0
  129. package/lib/esm/Metadata/CustomAttribute.js +24 -0
  130. package/lib/esm/Metadata/CustomAttribute.js.map +1 -0
  131. package/lib/esm/Metadata/CustomAttributeClass.d.ts +44 -0
  132. package/lib/esm/Metadata/CustomAttributeClass.d.ts.map +1 -0
  133. package/lib/esm/Metadata/CustomAttributeClass.js +70 -0
  134. package/lib/esm/Metadata/CustomAttributeClass.js.map +1 -0
  135. package/lib/esm/Metadata/EntityClass.d.ts +78 -0
  136. package/lib/esm/Metadata/EntityClass.d.ts.map +1 -0
  137. package/lib/esm/Metadata/EntityClass.js +224 -0
  138. package/lib/esm/Metadata/EntityClass.js.map +1 -0
  139. package/lib/esm/Metadata/Enumeration.d.ts +87 -0
  140. package/lib/esm/Metadata/Enumeration.d.ts.map +1 -0
  141. package/lib/esm/Metadata/Enumeration.js +155 -0
  142. package/lib/esm/Metadata/Enumeration.js.map +1 -0
  143. package/lib/esm/Metadata/Format.d.ts +99 -0
  144. package/lib/esm/Metadata/Format.d.ts.map +1 -0
  145. package/lib/esm/Metadata/Format.js +238 -0
  146. package/lib/esm/Metadata/Format.js.map +1 -0
  147. package/lib/esm/Metadata/InvertedUnit.d.ts +50 -0
  148. package/lib/esm/Metadata/InvertedUnit.d.ts.map +1 -0
  149. package/lib/esm/Metadata/InvertedUnit.js +93 -0
  150. package/lib/esm/Metadata/InvertedUnit.js.map +1 -0
  151. package/lib/esm/Metadata/KindOfQuantity.d.ts +72 -0
  152. package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -0
  153. package/lib/esm/Metadata/KindOfQuantity.js +229 -0
  154. package/lib/esm/Metadata/KindOfQuantity.js.map +1 -0
  155. package/lib/esm/Metadata/Mixin.d.ts +55 -0
  156. package/lib/esm/Metadata/Mixin.d.ts.map +1 -0
  157. package/lib/esm/Metadata/Mixin.js +109 -0
  158. package/lib/esm/Metadata/Mixin.js.map +1 -0
  159. package/lib/esm/Metadata/OverrideFormat.d.ts +68 -0
  160. package/lib/esm/Metadata/OverrideFormat.d.ts.map +1 -0
  161. package/lib/esm/Metadata/OverrideFormat.js +124 -0
  162. package/lib/esm/Metadata/OverrideFormat.js.map +1 -0
  163. package/lib/esm/Metadata/Phenomenon.d.ts +34 -0
  164. package/lib/esm/Metadata/Phenomenon.d.ts.map +1 -0
  165. package/lib/esm/Metadata/Phenomenon.js +55 -0
  166. package/lib/esm/Metadata/Phenomenon.js.map +1 -0
  167. package/lib/esm/Metadata/Property.d.ts +247 -0
  168. package/lib/esm/Metadata/Property.d.ts.map +1 -0
  169. package/lib/esm/Metadata/Property.js +565 -0
  170. package/lib/esm/Metadata/Property.js.map +1 -0
  171. package/lib/esm/Metadata/PropertyCategory.d.ts +40 -0
  172. package/lib/esm/Metadata/PropertyCategory.d.ts.map +1 -0
  173. package/lib/esm/Metadata/PropertyCategory.js +57 -0
  174. package/lib/esm/Metadata/PropertyCategory.js.map +1 -0
  175. package/lib/esm/Metadata/RelationshipClass.d.ts +170 -0
  176. package/lib/esm/Metadata/RelationshipClass.d.ts.map +1 -0
  177. package/lib/esm/Metadata/RelationshipClass.js +380 -0
  178. package/lib/esm/Metadata/RelationshipClass.js.map +1 -0
  179. package/lib/esm/Metadata/Schema.d.ts +330 -0
  180. package/lib/esm/Metadata/Schema.d.ts.map +1 -0
  181. package/lib/esm/Metadata/Schema.js +570 -0
  182. package/lib/esm/Metadata/Schema.js.map +1 -0
  183. package/lib/esm/Metadata/SchemaItem.d.ts +67 -0
  184. package/lib/esm/Metadata/SchemaItem.d.ts.map +1 -0
  185. package/lib/esm/Metadata/SchemaItem.js +140 -0
  186. package/lib/esm/Metadata/SchemaItem.js.map +1 -0
  187. package/lib/esm/Metadata/Unit.d.ts +77 -0
  188. package/lib/esm/Metadata/Unit.d.ts.map +1 -0
  189. package/lib/esm/Metadata/Unit.js +158 -0
  190. package/lib/esm/Metadata/Unit.js.map +1 -0
  191. package/lib/esm/Metadata/UnitSystem.d.ts +21 -0
  192. package/lib/esm/Metadata/UnitSystem.d.ts.map +1 -0
  193. package/lib/esm/Metadata/UnitSystem.js +25 -0
  194. package/lib/esm/Metadata/UnitSystem.js.map +1 -0
  195. package/lib/esm/PropertyTypes.d.ts +50 -0
  196. package/lib/esm/PropertyTypes.d.ts.map +1 -0
  197. package/lib/esm/PropertyTypes.js +88 -0
  198. package/lib/esm/PropertyTypes.js.map +1 -0
  199. package/lib/esm/SchemaJsonLocater.d.ts +42 -0
  200. package/lib/esm/SchemaJsonLocater.d.ts.map +1 -0
  201. package/lib/esm/SchemaJsonLocater.js +54 -0
  202. package/lib/esm/SchemaJsonLocater.js.map +1 -0
  203. package/lib/esm/SchemaKey.d.ts +111 -0
  204. package/lib/esm/SchemaKey.d.ts.map +1 -0
  205. package/lib/esm/SchemaKey.js +214 -0
  206. package/lib/esm/SchemaKey.js.map +1 -0
  207. package/lib/esm/SchemaLoader.d.ts +32 -0
  208. package/lib/esm/SchemaLoader.d.ts.map +1 -0
  209. package/lib/esm/SchemaLoader.js +53 -0
  210. package/lib/esm/SchemaLoader.js.map +1 -0
  211. package/lib/esm/SchemaPartVisitorDelegate.d.ts +275 -0
  212. package/lib/esm/SchemaPartVisitorDelegate.d.ts.map +1 -0
  213. package/lib/esm/SchemaPartVisitorDelegate.js +209 -0
  214. package/lib/esm/SchemaPartVisitorDelegate.js.map +1 -0
  215. package/lib/esm/UnitConversion/Graph.d.ts +35 -0
  216. package/lib/esm/UnitConversion/Graph.d.ts.map +1 -0
  217. package/lib/esm/UnitConversion/Graph.js +80 -0
  218. package/lib/esm/UnitConversion/Graph.js.map +1 -0
  219. package/lib/esm/UnitConversion/Parser.d.ts +9 -0
  220. package/lib/esm/UnitConversion/Parser.d.ts.map +1 -0
  221. package/lib/esm/UnitConversion/Parser.js +39 -0
  222. package/lib/esm/UnitConversion/Parser.js.map +1 -0
  223. package/lib/esm/UnitConversion/UnitConversion.d.ts +46 -0
  224. package/lib/esm/UnitConversion/UnitConversion.d.ts.map +1 -0
  225. package/lib/esm/UnitConversion/UnitConversion.js +74 -0
  226. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -0
  227. package/lib/esm/UnitConversion/UnitConverter.d.ts +40 -0
  228. package/lib/esm/UnitConversion/UnitConverter.d.ts.map +1 -0
  229. package/lib/esm/UnitConversion/UnitConverter.js +113 -0
  230. package/lib/esm/UnitConversion/UnitConverter.js.map +1 -0
  231. package/lib/esm/UnitConversion/UnitTree.d.ts +44 -0
  232. package/lib/esm/UnitConversion/UnitTree.d.ts.map +1 -0
  233. package/lib/esm/UnitConversion/UnitTree.js +165 -0
  234. package/lib/esm/UnitConversion/UnitTree.js.map +1 -0
  235. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts +78 -0
  236. package/lib/esm/UnitProvider/SchemaUnitProvider.d.ts.map +1 -0
  237. package/lib/esm/UnitProvider/SchemaUnitProvider.js +231 -0
  238. package/lib/esm/UnitProvider/SchemaUnitProvider.js.map +1 -0
  239. package/lib/esm/Validation/SchemaWalker.d.ts +24 -0
  240. package/lib/esm/Validation/SchemaWalker.d.ts.map +1 -0
  241. package/lib/esm/Validation/SchemaWalker.js +50 -0
  242. package/lib/esm/Validation/SchemaWalker.js.map +1 -0
  243. package/lib/esm/ecschema-metadata.d.ts +52 -0
  244. package/lib/esm/ecschema-metadata.d.ts.map +1 -0
  245. package/lib/esm/ecschema-metadata.js +55 -0
  246. package/lib/esm/ecschema-metadata.js.map +1 -0
  247. package/lib/esm/utils/SchemaGraph.d.ts +44 -0
  248. package/lib/esm/utils/SchemaGraph.d.ts.map +1 -0
  249. package/lib/esm/utils/SchemaGraph.js +111 -0
  250. package/lib/esm/utils/SchemaGraph.js.map +1 -0
  251. package/package.json +9 -7
@@ -0,0 +1,40 @@
1
+ /** @packageDocumentation
2
+ * @module Metadata
3
+ */
4
+ import { PropertyCategoryProps } from "../Deserialization/JsonProps";
5
+ import { SchemaItemType } from "../ECObjects";
6
+ import { Schema } from "./Schema";
7
+ import { SchemaItem } from "./SchemaItem";
8
+ /**
9
+ * @beta
10
+ */
11
+ export declare class PropertyCategory extends SchemaItem {
12
+ readonly schemaItemType: SchemaItemType.PropertyCategory;
13
+ protected _priority: number;
14
+ get priority(): number;
15
+ constructor(schema: Schema, name: string);
16
+ /**
17
+ * Save this PropertyCategory's properties to an object for serializing to JSON.
18
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
19
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
20
+ */
21
+ toJSON(standalone?: boolean, includeSchemaVersion?: boolean): PropertyCategoryProps;
22
+ /** @internal */
23
+ toXml(schemaXml: Document): Promise<Element>;
24
+ fromJSONSync(propertyCategoryProps: PropertyCategoryProps): void;
25
+ fromJSON(propertyCategoryProps: PropertyCategoryProps): Promise<void>;
26
+ /**
27
+ * @alpha
28
+ * Used for schema editing.
29
+ */
30
+ protected setPriority(priority: number): void;
31
+ }
32
+ /**
33
+ * @internal
34
+ * An abstract class used for schema editing.
35
+ */
36
+ export declare abstract class MutablePropertyCategory extends PropertyCategory {
37
+ abstract setPriority(priority: number): void;
38
+ abstract setDisplayLabel(displayLabel: string): void;
39
+ }
40
+ //# sourceMappingURL=PropertyCategory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyCategory.d.ts","sourceRoot":"","sources":["../../../src/Metadata/PropertyCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,SAAyB,cAAc,EAAG,cAAc,CAAC,gBAAgB,CAAC;IAC1E,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAE5B,IAAW,QAAQ,WAA6B;gBAEpC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMxC;;;;OAIG;IACa,MAAM,CAAC,UAAU,GAAE,OAAe,EAAE,oBAAoB,GAAE,OAAe,GAAG,qBAAqB;IAMjH,gBAAgB;IACM,KAAK,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAMlD,YAAY,CAAC,qBAAqB,EAAE,qBAAqB;IAKnD,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;IAG3E;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM;CAGvC;AAED;;;GAGG;AACH,8BAAsB,uBAAwB,SAAQ,gBAAgB;aAC3C,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;aACnC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -0,0 +1,57 @@
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 { SchemaItemType } from "../ECObjects";
9
+ import { SchemaItem } from "./SchemaItem";
10
+ /**
11
+ * @beta
12
+ */
13
+ export class PropertyCategory extends SchemaItem {
14
+ get priority() { return this._priority; }
15
+ constructor(schema, name) {
16
+ super(schema, name);
17
+ this.schemaItemType = SchemaItemType.PropertyCategory;
18
+ this._priority = 0;
19
+ }
20
+ /**
21
+ * Save this PropertyCategory's properties to an object for serializing to JSON.
22
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
23
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
24
+ */
25
+ toJSON(standalone = false, includeSchemaVersion = false) {
26
+ const schemaJson = super.toJSON(standalone, includeSchemaVersion);
27
+ schemaJson.priority = this.priority;
28
+ return schemaJson;
29
+ }
30
+ /** @internal */
31
+ async toXml(schemaXml) {
32
+ const itemElement = await super.toXml(schemaXml);
33
+ itemElement.setAttribute("priority", this.priority.toString());
34
+ return itemElement;
35
+ }
36
+ fromJSONSync(propertyCategoryProps) {
37
+ super.fromJSONSync(propertyCategoryProps);
38
+ this._priority = propertyCategoryProps.priority;
39
+ }
40
+ async fromJSON(propertyCategoryProps) {
41
+ this.fromJSONSync(propertyCategoryProps);
42
+ }
43
+ /**
44
+ * @alpha
45
+ * Used for schema editing.
46
+ */
47
+ setPriority(priority) {
48
+ this._priority = priority;
49
+ }
50
+ }
51
+ /**
52
+ * @internal
53
+ * An abstract class used for schema editing.
54
+ */
55
+ export class MutablePropertyCategory extends PropertyCategory {
56
+ }
57
+ //# sourceMappingURL=PropertyCategory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyCategory.js","sourceRoot":"","sources":["../../../src/Metadata/PropertyCategory.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAI9C,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhD,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,gBAAgB,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACa,MAAM,CAAC,aAAsB,KAAK,EAAE,uBAAgC,KAAK;QACvF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAQ,CAAC;QACzE,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QACpC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,gBAAgB;IACA,KAAK,CAAC,KAAK,CAAC,SAAmB;QAC7C,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjD,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/D,OAAO,WAAW,CAAC;IACrB,CAAC;IAEe,YAAY,CAAC,qBAA4C;QACvE,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,QAAQ,CAAC;IAClD,CAAC;IAEe,KAAK,CAAC,QAAQ,CAAC,qBAA4C;QACzE,IAAI,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;IACD;;;OAGG;IACO,WAAW,CAAC,QAAgB;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,uBAAwB,SAAQ,gBAAgB;CAGrE","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 { PropertyCategoryProps } from \"../Deserialization/JsonProps\";\r\nimport { SchemaItemType } from \"../ECObjects\";\r\nimport { Schema } from \"./Schema\";\r\nimport { SchemaItem } from \"./SchemaItem\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class PropertyCategory extends SchemaItem {\r\n public override readonly schemaItemType!: SchemaItemType.PropertyCategory; // eslint-disable-line\r\n protected _priority: number;\r\n\r\n public get priority() { return this._priority; }\r\n\r\n constructor(schema: Schema, name: string) {\r\n super(schema, name);\r\n this.schemaItemType = SchemaItemType.PropertyCategory;\r\n this._priority = 0;\r\n }\r\n\r\n /**\r\n * Save this PropertyCategory's properties to an object for serializing to JSON.\r\n * @param standalone Serialization includes only this object (as opposed to the full schema).\r\n * @param includeSchemaVersion Include the Schema's version information in the serialized object.\r\n */\r\n public override toJSON(standalone: boolean = false, includeSchemaVersion: boolean = false): PropertyCategoryProps {\r\n const schemaJson = super.toJSON(standalone, includeSchemaVersion) as any;\r\n schemaJson.priority = this.priority;\r\n return schemaJson;\r\n }\r\n\r\n /** @internal */\r\n public override async toXml(schemaXml: Document): Promise<Element> {\r\n const itemElement = await super.toXml(schemaXml);\r\n itemElement.setAttribute(\"priority\", this.priority.toString());\r\n return itemElement;\r\n }\r\n\r\n public override fromJSONSync(propertyCategoryProps: PropertyCategoryProps) {\r\n super.fromJSONSync(propertyCategoryProps);\r\n this._priority = propertyCategoryProps.priority;\r\n }\r\n\r\n public override async fromJSON(propertyCategoryProps: PropertyCategoryProps) {\r\n this.fromJSONSync(propertyCategoryProps);\r\n }\r\n /**\r\n * @alpha\r\n * Used for schema editing.\r\n */\r\n protected setPriority(priority: number) {\r\n this._priority = priority;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n * An abstract class used for schema editing.\r\n */\r\nexport abstract class MutablePropertyCategory extends PropertyCategory {\r\n public abstract override setPriority(priority: number): void;\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n}\r\n"]}
@@ -0,0 +1,170 @@
1
+ /** @packageDocumentation
2
+ * @module Metadata
3
+ */
4
+ import { RelationshipClassProps, RelationshipConstraintProps } from "../Deserialization/JsonProps";
5
+ import { ECClassModifier, RelationshipEnd, SchemaItemType, StrengthDirection, StrengthType } from "../ECObjects";
6
+ import { LazyLoadedRelationshipConstraintClass } from "../Interfaces";
7
+ import { ECClass } from "./Class";
8
+ import { CustomAttribute, CustomAttributeContainerProps, CustomAttributeSet } from "./CustomAttribute";
9
+ import { EntityClass } from "./EntityClass";
10
+ import { Mixin } from "./Mixin";
11
+ import { NavigationProperty } from "./Property";
12
+ import { Schema } from "./Schema";
13
+ /**
14
+ * A Typescript class representation of a ECRelationshipClass.
15
+ * @beta
16
+ */
17
+ export declare class RelationshipClass extends ECClass {
18
+ readonly schema: Schema;
19
+ readonly schemaItemType: SchemaItemType.RelationshipClass;
20
+ protected _strength: StrengthType;
21
+ protected _strengthDirection: StrengthDirection;
22
+ protected _source: RelationshipConstraint;
23
+ protected _target: RelationshipConstraint;
24
+ constructor(schema: Schema, name: string, modifier?: ECClassModifier);
25
+ get strength(): StrengthType;
26
+ get strengthDirection(): StrengthDirection;
27
+ get source(): RelationshipConstraint;
28
+ get target(): RelationshipConstraint;
29
+ /**
30
+ *
31
+ * @param name
32
+ * @param relationship
33
+ * @param direction
34
+ */
35
+ protected createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
36
+ protected createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
37
+ /**
38
+ * @alpha Used for schema editing.
39
+ */
40
+ protected setStrength(strength: StrengthType): void;
41
+ /**
42
+ * @alpha Used for schema editing.
43
+ */
44
+ protected setStrengthDirection(direction: StrengthDirection): void;
45
+ /**
46
+ * @alpha Used for schema editing.
47
+ */
48
+ protected setSourceConstraint(source: RelationshipConstraint): void;
49
+ /**
50
+ * @alpha Used for schema editing.
51
+ */
52
+ protected setTargetConstraint(target: RelationshipConstraint): void;
53
+ /**
54
+ * Save this RelationshipClass's properties to an object for serializing to JSON.
55
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
56
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
57
+ */
58
+ toJSON(standalone?: boolean, includeSchemaVersion?: boolean): RelationshipClassProps;
59
+ /** @internal */
60
+ toXml(schemaXml: Document): Promise<Element>;
61
+ fromJSONSync(relationshipClassProps: RelationshipClassProps): void;
62
+ fromJSON(relationshipClassProps: RelationshipClassProps): Promise<void>;
63
+ }
64
+ /**
65
+ * A Typescript class representation of a ECRelationshipConstraint.
66
+ * @beta
67
+ */
68
+ export declare class RelationshipConstraint implements CustomAttributeContainerProps {
69
+ protected _abstractConstraint?: LazyLoadedRelationshipConstraintClass;
70
+ protected _relationshipClass: RelationshipClass;
71
+ protected _relationshipEnd: RelationshipEnd;
72
+ protected _multiplicity?: RelationshipMultiplicity;
73
+ protected _polymorphic?: boolean;
74
+ protected _roleLabel?: string;
75
+ protected _constraintClasses?: LazyLoadedRelationshipConstraintClass[];
76
+ private _customAttributes?;
77
+ constructor(relClass: RelationshipClass, relEnd: RelationshipEnd, roleLabel?: string, polymorphic?: boolean);
78
+ get multiplicity(): RelationshipMultiplicity;
79
+ protected set multiplicity(multiplicity: RelationshipMultiplicity);
80
+ get polymorphic(): boolean;
81
+ protected set polymorphic(polymorphic: boolean);
82
+ get roleLabel(): string | undefined;
83
+ protected set roleLabel(roleLabel: string | undefined);
84
+ get constraintClasses(): LazyLoadedRelationshipConstraintClass[] | undefined;
85
+ get relationshipClass(): RelationshipClass;
86
+ get relationshipEnd(): RelationshipEnd;
87
+ protected set relationshipEnd(relationshipEnd: RelationshipEnd);
88
+ get customAttributes(): CustomAttributeSet | undefined;
89
+ /** Returns the constraint name, ie. 'RelationshipName.Source/Target' */
90
+ get fullName(): string;
91
+ /** Returns the schema of the RelationshipClass. */
92
+ get schema(): Schema;
93
+ get abstractConstraint(): LazyLoadedRelationshipConstraintClass | undefined;
94
+ set abstractConstraint(abstractConstraint: LazyLoadedRelationshipConstraintClass | undefined);
95
+ /**
96
+ * True if this RelationshipConstraint is the Source relationship end.
97
+ */
98
+ get isSource(): boolean;
99
+ /**
100
+ * Adds the provided class as a constraint class to this constraint.
101
+ * @param constraint The class to add as a constraint class.
102
+ */
103
+ addClass(constraint: EntityClass | Mixin | RelationshipClass): void;
104
+ /**
105
+ * Removes the provided class as a constraint class from this constraint.
106
+ * @param constraint The class to add as a constraint class.
107
+ */
108
+ protected removeClass(constraint: EntityClass | Mixin | RelationshipClass): void;
109
+ /**
110
+ * Save this RelationshipConstraint's properties to an object for serializing to JSON.
111
+ */
112
+ toJSON(): RelationshipConstraintProps;
113
+ /** @internal */
114
+ toXml(schemaXml: Document): Promise<Element>;
115
+ fromJSONSync(relationshipConstraintProps: RelationshipConstraintProps): void;
116
+ fromJSON(relationshipConstraintProps: RelationshipConstraintProps): Promise<void>;
117
+ /**
118
+ * Indicates if the provided [[ECClass]] is supported by this [[RelationshipConstraint]].
119
+ * @param ecClass The class to check.
120
+ */
121
+ supportsClass(ecClass: ECClass): Promise<boolean>;
122
+ /**
123
+ * Indicates if an ECClass is of the type or applies to the type (if a mixin) of the ECClass specified by the constraintClass parameter.
124
+ * @param constraintClass The ECClass that is a constraint class of a relationship.
125
+ * @param testClass The ECClass to check against the constraint class.
126
+ * @param isPolymorphic Indicates if the testClass should be checked polymorphically.
127
+ */
128
+ static classCompatibleWithConstraint(constraintClass: ECClass, testClass: ECClass, isPolymorphic: boolean): Promise<boolean>;
129
+ /**
130
+ * @internal
131
+ */
132
+ static isRelationshipConstraint(object: any): object is RelationshipConstraint;
133
+ protected addCustomAttribute(customAttribute: CustomAttribute): void;
134
+ }
135
+ /**
136
+ * Hackish approach that works like a "friend class" so we can access protected members without making them public.
137
+ * @internal
138
+ */
139
+ export declare abstract class MutableRelationshipConstraint extends RelationshipConstraint {
140
+ abstract addCustomAttribute(customAttribute: CustomAttribute): void;
141
+ }
142
+ /**
143
+ * @beta
144
+ */
145
+ export declare class RelationshipMultiplicity {
146
+ static readonly zeroOne: RelationshipMultiplicity;
147
+ static readonly zeroMany: RelationshipMultiplicity;
148
+ static readonly oneOne: RelationshipMultiplicity;
149
+ static readonly oneMany: RelationshipMultiplicity;
150
+ readonly lowerLimit: number;
151
+ readonly upperLimit: number;
152
+ constructor(lowerLimit: number, upperLimit: number);
153
+ static fromString(str: string): RelationshipMultiplicity | undefined;
154
+ equals(rhs: RelationshipMultiplicity): boolean;
155
+ toString(): string;
156
+ }
157
+ /**
158
+ * @internal
159
+ * An abstract class used for schema editing.
160
+ */
161
+ export declare abstract class MutableRelationshipClass extends RelationshipClass {
162
+ get source(): MutableRelationshipConstraint;
163
+ get target(): MutableRelationshipConstraint;
164
+ abstract setStrength(strength: StrengthType): void;
165
+ abstract setStrengthDirection(direction: StrengthDirection): void;
166
+ abstract createNavigationProperty(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<NavigationProperty>;
167
+ abstract createNavigationPropertySync(name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): NavigationProperty;
168
+ abstract setDisplayLabel(displayLabel: string): void;
169
+ }
170
+ //# sourceMappingURL=RelationshipClass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelationshipClass.d.ts","sourceRoot":"","sources":["../../../src/Metadata/RelationshipClass.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAEnG,OAAO,EACL,eAAe,EAAyC,eAAe,EAAE,cAAc,EAAE,iBAAiB,EACxF,YAAY,EAC/B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,qCAAqC,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,kBAAkB,EAA6B,MAAM,mBAAmB,CAAC;AAClI,OAAO,EAA0D,WAAW,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,SAAyB,MAAM,EAAG,MAAM,CAAC;IACzC,SAAyB,cAAc,EAAG,cAAc,CAAC,iBAAiB,CAAC;IAC3E,SAAS,CAAC,SAAS,EAAE,YAAY,CAAC;IAClC,SAAS,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;IAChD,SAAS,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAC1C,SAAS,CAAC,OAAO,EAAE,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;GAGG;AACH,8BAAsB,wBAAyB,SAAQ,iBAAiB;IACtE,IAAoB,MAAM,kCAA4D;IACtF,IAAoB,MAAM,kCAA4D;aAC7D,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;aACzC,oBAAoB,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;aACxD,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;aACpJ,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,kBAAkB;aAC/I,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CACrE"}
@@ -0,0 +1,380 @@
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 { DelayedPromiseWithProps } from "../DelayedPromise";
9
+ import { XmlSerializationUtils } from "../Deserialization/XmlSerializationUtils";
10
+ import { parseStrength, parseStrengthDirection, RelationshipEnd, SchemaItemType, StrengthDirection, strengthDirectionToString, strengthToString, StrengthType, } from "../ECObjects";
11
+ import { ECObjectsError, ECObjectsStatus } from "../Exception";
12
+ import { ECClass } from "./Class";
13
+ import { serializeCustomAttributes } from "./CustomAttribute";
14
+ import { createNavigationProperty, createNavigationPropertySync } from "./EntityClass";
15
+ import { SchemaItem } from "./SchemaItem";
16
+ /**
17
+ * A Typescript class representation of a ECRelationshipClass.
18
+ * @beta
19
+ */
20
+ export class RelationshipClass extends ECClass {
21
+ constructor(schema, name, modifier) {
22
+ super(schema, name, modifier);
23
+ this.schemaItemType = SchemaItemType.RelationshipClass;
24
+ this._strengthDirection = StrengthDirection.Forward;
25
+ this._strength = StrengthType.Referencing;
26
+ this._source = new RelationshipConstraint(this, RelationshipEnd.Source);
27
+ this._target = new RelationshipConstraint(this, RelationshipEnd.Target);
28
+ }
29
+ get strength() { return this._strength; }
30
+ get strengthDirection() { return this._strengthDirection; }
31
+ get source() { return this._source; }
32
+ get target() { return this._target; }
33
+ /**
34
+ *
35
+ * @param name
36
+ * @param relationship
37
+ * @param direction
38
+ */
39
+ async createNavigationProperty(name, relationship, direction) {
40
+ return this.addProperty(await createNavigationProperty(this, name, relationship, direction));
41
+ }
42
+ createNavigationPropertySync(name, relationship, direction) {
43
+ return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));
44
+ }
45
+ /**
46
+ * @alpha Used for schema editing.
47
+ */
48
+ setStrength(strength) {
49
+ this._strength = strength;
50
+ }
51
+ /**
52
+ * @alpha Used for schema editing.
53
+ */
54
+ setStrengthDirection(direction) {
55
+ this._strengthDirection = direction;
56
+ }
57
+ /**
58
+ * @alpha Used for schema editing.
59
+ */
60
+ setSourceConstraint(source) {
61
+ this._source = source;
62
+ }
63
+ /**
64
+ * @alpha Used for schema editing.
65
+ */
66
+ setTargetConstraint(target) {
67
+ this._target = target;
68
+ }
69
+ /**
70
+ * Save this RelationshipClass's properties to an object for serializing to JSON.
71
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
72
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
73
+ */
74
+ toJSON(standalone = false, includeSchemaVersion = false) {
75
+ const schemaJson = super.toJSON(standalone, includeSchemaVersion);
76
+ schemaJson.strength = strengthToString(this.strength);
77
+ schemaJson.strengthDirection = strengthDirectionToString(this.strengthDirection);
78
+ schemaJson.source = this.source.toJSON();
79
+ schemaJson.target = this.target.toJSON();
80
+ return schemaJson;
81
+ }
82
+ /** @internal */
83
+ async toXml(schemaXml) {
84
+ const itemElement = await super.toXml(schemaXml);
85
+ itemElement.setAttribute("strength", strengthToString(this.strength));
86
+ itemElement.setAttribute("strengthDirection", strengthDirectionToString(this.strengthDirection));
87
+ itemElement.appendChild(await this.source.toXml(schemaXml));
88
+ itemElement.appendChild(await this.target.toXml(schemaXml));
89
+ return itemElement;
90
+ }
91
+ fromJSONSync(relationshipClassProps) {
92
+ super.fromJSONSync(relationshipClassProps);
93
+ const strength = parseStrength(relationshipClassProps.strength);
94
+ if (undefined === strength)
95
+ throw new ECObjectsError(ECObjectsStatus.InvalidStrength, `The RelationshipClass ${this.fullName} has an invalid 'strength' attribute. '${relationshipClassProps.strength}' is not a valid StrengthType.`);
96
+ const strengthDirection = parseStrengthDirection(relationshipClassProps.strengthDirection);
97
+ if (undefined === strengthDirection)
98
+ throw new ECObjectsError(ECObjectsStatus.InvalidStrength, `The RelationshipClass ${this.fullName} has an invalid 'strengthDirection' attribute. '${relationshipClassProps.strengthDirection}' is not a valid StrengthDirection.`);
99
+ this._strength = strength;
100
+ this._strengthDirection = strengthDirection;
101
+ }
102
+ async fromJSON(relationshipClassProps) {
103
+ this.fromJSONSync(relationshipClassProps);
104
+ }
105
+ }
106
+ /**
107
+ * A Typescript class representation of a ECRelationshipConstraint.
108
+ * @beta
109
+ */
110
+ export class RelationshipConstraint {
111
+ constructor(relClass, relEnd, roleLabel, polymorphic) {
112
+ this._relationshipEnd = relEnd;
113
+ if (polymorphic)
114
+ this._polymorphic = polymorphic;
115
+ else
116
+ this._polymorphic = false;
117
+ this._multiplicity = RelationshipMultiplicity.zeroOne;
118
+ this._relationshipClass = relClass;
119
+ this._roleLabel = roleLabel;
120
+ }
121
+ get multiplicity() { return this._multiplicity ?? RelationshipMultiplicity.zeroOne; }
122
+ set multiplicity(multiplicity) {
123
+ this._multiplicity = multiplicity;
124
+ }
125
+ get polymorphic() { return this._polymorphic ?? false; }
126
+ set polymorphic(polymorphic) {
127
+ this._polymorphic = polymorphic;
128
+ }
129
+ get roleLabel() { return this._roleLabel; }
130
+ set roleLabel(roleLabel) {
131
+ this._roleLabel = roleLabel;
132
+ }
133
+ get constraintClasses() { return this._constraintClasses; }
134
+ get relationshipClass() { return this._relationshipClass; }
135
+ get relationshipEnd() { return this._relationshipEnd; }
136
+ set relationshipEnd(relationshipEnd) {
137
+ this._relationshipEnd = relationshipEnd;
138
+ }
139
+ get customAttributes() { return this._customAttributes; }
140
+ /** Returns the constraint name, ie. 'RelationshipName.Source/Target' */
141
+ get fullName() { return `${this._relationshipClass.name}:${this.isSource ? "Source" : "Target"}`; }
142
+ /** Returns the schema of the RelationshipClass. */
143
+ get schema() { return this._relationshipClass.schema; }
144
+ get abstractConstraint() {
145
+ if (this._abstractConstraint)
146
+ return this._abstractConstraint;
147
+ if (this.constraintClasses && this.constraintClasses.length === 1)
148
+ return this.constraintClasses[0];
149
+ return this._abstractConstraint;
150
+ }
151
+ set abstractConstraint(abstractConstraint) {
152
+ this._abstractConstraint = abstractConstraint;
153
+ }
154
+ /**
155
+ * True if this RelationshipConstraint is the Source relationship end.
156
+ */
157
+ get isSource() { return this.relationshipEnd === RelationshipEnd.Source; }
158
+ /**
159
+ * Adds the provided class as a constraint class to this constraint.
160
+ * @param constraint The class to add as a constraint class.
161
+ */
162
+ addClass(constraint) {
163
+ // TODO: Ensure we don't start mixing constraint class types
164
+ // TODO: Check that this class is or subclasses abstract constraint?
165
+ if (!this._constraintClasses)
166
+ this._constraintClasses = [];
167
+ // TODO: Handle relationship constraints
168
+ this._constraintClasses.push(new DelayedPromiseWithProps(constraint.key, async () => constraint));
169
+ }
170
+ /**
171
+ * Removes the provided class as a constraint class from this constraint.
172
+ * @param constraint The class to add as a constraint class.
173
+ */
174
+ removeClass(constraint) {
175
+ if (undefined === this._constraintClasses)
176
+ return;
177
+ this._constraintClasses.forEach((item, index) => {
178
+ const constraintName = item.fullName;
179
+ if (constraintName === constraint.fullName)
180
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
181
+ this._constraintClasses?.splice(index, 1);
182
+ });
183
+ }
184
+ /**
185
+ * Save this RelationshipConstraint's properties to an object for serializing to JSON.
186
+ */
187
+ toJSON() {
188
+ const schemaJson = {};
189
+ schemaJson.multiplicity = this.multiplicity.toString();
190
+ schemaJson.roleLabel = this.roleLabel;
191
+ schemaJson.polymorphic = this.polymorphic;
192
+ if (undefined !== this._abstractConstraint)
193
+ schemaJson.abstractConstraint = this._abstractConstraint.fullName;
194
+ if (undefined !== this.constraintClasses && this.constraintClasses.length > 0)
195
+ schemaJson.constraintClasses = this.constraintClasses.map((constraintClass) => constraintClass.fullName);
196
+ const customAttributes = serializeCustomAttributes(this.customAttributes);
197
+ if (undefined !== customAttributes)
198
+ schemaJson.customAttributes = customAttributes;
199
+ return schemaJson;
200
+ }
201
+ /** @internal */
202
+ async toXml(schemaXml) {
203
+ const elementName = this.isSource ? "Source" : "Target";
204
+ const itemElement = schemaXml.createElement(elementName);
205
+ if (undefined !== this.polymorphic)
206
+ itemElement.setAttribute("polymorphic", this.polymorphic.toString());
207
+ if (undefined !== this.roleLabel)
208
+ itemElement.setAttribute("roleLabel", this.roleLabel);
209
+ if (undefined !== this.multiplicity)
210
+ itemElement.setAttribute("multiplicity", this.multiplicity.toString());
211
+ const abstractConstraint = await this.abstractConstraint;
212
+ if (undefined !== abstractConstraint) {
213
+ const abstractConstraintName = XmlSerializationUtils.createXmlTypedName(this.schema, abstractConstraint.schema, abstractConstraint.name);
214
+ itemElement.setAttribute("abstractConstraint", abstractConstraintName);
215
+ }
216
+ if (undefined !== this.constraintClasses) {
217
+ for (const item of this.constraintClasses) {
218
+ const constraintClass = await item;
219
+ const classElement = schemaXml.createElement("Class");
220
+ const constraintClassName = XmlSerializationUtils.createXmlTypedName(this.schema, constraintClass.schema, constraintClass.name);
221
+ classElement.setAttribute("class", constraintClassName);
222
+ itemElement.appendChild(classElement);
223
+ }
224
+ }
225
+ if (this._customAttributes) {
226
+ const caContainerElement = schemaXml.createElement("ECCustomAttributes");
227
+ for (const [name, attribute] of this._customAttributes) {
228
+ const caElement = await XmlSerializationUtils.writeCustomAttribute(name, attribute, schemaXml, this.schema);
229
+ caContainerElement.appendChild(caElement);
230
+ }
231
+ itemElement.appendChild(caContainerElement);
232
+ }
233
+ return itemElement;
234
+ }
235
+ fromJSONSync(relationshipConstraintProps) {
236
+ this._roleLabel = relationshipConstraintProps.roleLabel;
237
+ this._polymorphic = relationshipConstraintProps.polymorphic;
238
+ const parsedMultiplicity = RelationshipMultiplicity.fromString(relationshipConstraintProps.multiplicity);
239
+ if (!parsedMultiplicity)
240
+ throw new ECObjectsError(ECObjectsStatus.InvalidMultiplicity, ``);
241
+ this._multiplicity = parsedMultiplicity;
242
+ const relClassSchema = this.relationshipClass.schema;
243
+ if (undefined !== relationshipConstraintProps.abstractConstraint) {
244
+ const abstractConstraintSchemaItemKey = relClassSchema.getSchemaItemKey(relationshipConstraintProps.abstractConstraint);
245
+ if (!abstractConstraintSchemaItemKey)
246
+ throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the abstractConstraint ${relationshipConstraintProps.abstractConstraint}.`);
247
+ this.abstractConstraint = new DelayedPromiseWithProps(abstractConstraintSchemaItemKey, async () => {
248
+ const tempAbstractConstraint = await relClassSchema.lookupItem(relationshipConstraintProps.abstractConstraint);
249
+ if (undefined === tempAbstractConstraint)
250
+ throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the abstractConstraint ${relationshipConstraintProps.abstractConstraint}.`);
251
+ return tempAbstractConstraint;
252
+ });
253
+ }
254
+ const loadEachConstraint = (constraintClassName) => {
255
+ const tempConstraintClass = relClassSchema.lookupItemSync(constraintClassName);
256
+ if (!tempConstraintClass)
257
+ throw new ECObjectsError(ECObjectsStatus.InvalidECJson, ``);
258
+ return tempConstraintClass;
259
+ };
260
+ for (const constraintClassName of relationshipConstraintProps.constraintClasses) {
261
+ const constraintClass = loadEachConstraint(constraintClassName);
262
+ this.addClass(constraintClass);
263
+ }
264
+ }
265
+ async fromJSON(relationshipConstraintProps) {
266
+ this.fromJSONSync(relationshipConstraintProps);
267
+ }
268
+ /**
269
+ * Indicates if the provided [[ECClass]] is supported by this [[RelationshipConstraint]].
270
+ * @param ecClass The class to check.
271
+ */
272
+ async supportsClass(ecClass) {
273
+ if (!this.constraintClasses) {
274
+ if (this.relationshipClass.baseClass) {
275
+ const baseRelationship = await this.relationshipClass.baseClass;
276
+ const baseConstraint = this.isSource ? baseRelationship.source : baseRelationship.target;
277
+ return baseConstraint.supportsClass(ecClass);
278
+ }
279
+ return false;
280
+ }
281
+ if (ecClass.schemaItemType !== SchemaItemType.EntityClass && ecClass.schemaItemType !== SchemaItemType.RelationshipClass &&
282
+ ecClass.schemaItemType !== SchemaItemType.Mixin) {
283
+ return false;
284
+ }
285
+ const abstractConstraint = await this.abstractConstraint;
286
+ if (abstractConstraint && await RelationshipConstraint.classCompatibleWithConstraint(abstractConstraint, ecClass, this.polymorphic || false))
287
+ return true;
288
+ for (const constraint of this.constraintClasses) {
289
+ if (await RelationshipConstraint.classCompatibleWithConstraint(await constraint, ecClass, this.polymorphic || false))
290
+ return true;
291
+ }
292
+ return false;
293
+ }
294
+ /**
295
+ * Indicates if an ECClass is of the type or applies to the type (if a mixin) of the ECClass specified by the constraintClass parameter.
296
+ * @param constraintClass The ECClass that is a constraint class of a relationship.
297
+ * @param testClass The ECClass to check against the constraint class.
298
+ * @param isPolymorphic Indicates if the testClass should be checked polymorphically.
299
+ */
300
+ static async classCompatibleWithConstraint(constraintClass, testClass, isPolymorphic) {
301
+ if (SchemaItem.equalByKey(constraintClass, testClass))
302
+ return true;
303
+ if (isPolymorphic) {
304
+ if (testClass.schemaItemType === SchemaItemType.EntityClass || testClass.schemaItemType === SchemaItemType.RelationshipClass) {
305
+ return testClass.is(constraintClass);
306
+ }
307
+ if (testClass.schemaItemType === SchemaItemType.Mixin) {
308
+ if (constraintClass.schemaItemType === SchemaItemType.EntityClass)
309
+ return testClass.applicableTo(constraintClass);
310
+ else
311
+ return testClass.is(constraintClass);
312
+ }
313
+ }
314
+ return false;
315
+ }
316
+ /**
317
+ * @internal
318
+ */
319
+ static isRelationshipConstraint(object) {
320
+ const relationshipConstrait = object;
321
+ return relationshipConstrait !== undefined && relationshipConstrait.polymorphic !== undefined && relationshipConstrait.multiplicity !== undefined
322
+ && relationshipConstrait.relationshipEnd !== undefined && relationshipConstrait._relationshipClass !== undefined;
323
+ }
324
+ addCustomAttribute(customAttribute) {
325
+ if (!this._customAttributes)
326
+ this._customAttributes = new Map();
327
+ this._customAttributes.set(customAttribute.className, customAttribute);
328
+ }
329
+ }
330
+ /**
331
+ * Hackish approach that works like a "friend class" so we can access protected members without making them public.
332
+ * @internal
333
+ */
334
+ export class MutableRelationshipConstraint extends RelationshipConstraint {
335
+ }
336
+ const INT32_MAX = 2147483647;
337
+ /**
338
+ * @beta
339
+ */
340
+ export class RelationshipMultiplicity {
341
+ constructor(lowerLimit, upperLimit) {
342
+ this.lowerLimit = lowerLimit;
343
+ this.upperLimit = upperLimit;
344
+ }
345
+ static fromString(str) {
346
+ const matches = /^\(([0-9]*)\.\.([0-9]*|\*)\)$/.exec(str);
347
+ if (matches === null || matches.length !== 3)
348
+ return undefined;
349
+ const lowerLimit = parseInt(matches[1], 10);
350
+ const upperLimit = matches[2] === "*" ? INT32_MAX : parseInt(matches[2], 10);
351
+ if (0 === lowerLimit && 1 === upperLimit)
352
+ return RelationshipMultiplicity.zeroOne;
353
+ else if (0 === lowerLimit && INT32_MAX === upperLimit)
354
+ return RelationshipMultiplicity.zeroMany;
355
+ else if (1 === lowerLimit && 1 === upperLimit)
356
+ return RelationshipMultiplicity.oneOne;
357
+ else if (1 === lowerLimit && INT32_MAX === upperLimit)
358
+ return RelationshipMultiplicity.oneMany;
359
+ return new RelationshipMultiplicity(lowerLimit, upperLimit);
360
+ }
361
+ equals(rhs) {
362
+ return this.lowerLimit === rhs.lowerLimit && this.upperLimit === rhs.upperLimit;
363
+ }
364
+ toString() {
365
+ return `(${this.lowerLimit}..${this.upperLimit === INT32_MAX ? "*" : this.upperLimit})`;
366
+ }
367
+ }
368
+ RelationshipMultiplicity.zeroOne = new RelationshipMultiplicity(0, 1);
369
+ RelationshipMultiplicity.zeroMany = new RelationshipMultiplicity(0, INT32_MAX);
370
+ RelationshipMultiplicity.oneOne = new RelationshipMultiplicity(1, 1);
371
+ RelationshipMultiplicity.oneMany = new RelationshipMultiplicity(1, INT32_MAX);
372
+ /**
373
+ * @internal
374
+ * An abstract class used for schema editing.
375
+ */
376
+ export class MutableRelationshipClass extends RelationshipClass {
377
+ get source() { return this._source; }
378
+ get target() { return this._target; }
379
+ }
380
+ //# sourceMappingURL=RelationshipClass.js.map