@itwin/ecschema-metadata 3.6.0-dev.54 → 3.6.0-dev.55

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 (140) hide show
  1. package/lib/cjs/Constants.d.ts +23 -23
  2. package/lib/cjs/Constants.js +33 -33
  3. package/lib/cjs/Constants.js.map +1 -1
  4. package/lib/cjs/Context.d.ts +139 -139
  5. package/lib/cjs/Context.js +204 -204
  6. package/lib/cjs/DelayedPromise.d.ts +88 -88
  7. package/lib/cjs/DelayedPromise.js +91 -91
  8. package/lib/cjs/DelayedPromise.js.map +1 -1
  9. package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
  10. package/lib/cjs/Deserialization/AbstractParser.js +11 -11
  11. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  12. package/lib/cjs/Deserialization/Helper.d.ts +251 -251
  13. package/lib/cjs/Deserialization/Helper.js +843 -843
  14. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  15. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  16. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  17. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  18. package/lib/cjs/Deserialization/JsonProps.d.ts +282 -282
  19. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  20. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  21. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  22. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  23. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  24. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  25. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  26. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  27. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  28. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  29. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  30. package/lib/cjs/ECName.d.ts +30 -30
  31. package/lib/cjs/ECName.js +85 -85
  32. package/lib/cjs/ECName.js.map +1 -1
  33. package/lib/cjs/ECObjects.d.ts +162 -162
  34. package/lib/cjs/ECObjects.js +453 -453
  35. package/lib/cjs/ECObjects.js.map +1 -1
  36. package/lib/cjs/Exception.d.ts +43 -43
  37. package/lib/cjs/Exception.js +86 -86
  38. package/lib/cjs/Exception.js.map +1 -1
  39. package/lib/cjs/Interfaces.d.ts +66 -66
  40. package/lib/cjs/Interfaces.js +9 -9
  41. package/lib/cjs/Interfaces.js.map +1 -1
  42. package/lib/cjs/Metadata/Class.d.ts +243 -243
  43. package/lib/cjs/Metadata/Class.js +558 -558
  44. package/lib/cjs/Metadata/Class.js.map +1 -1
  45. package/lib/cjs/Metadata/Constant.d.ts +64 -64
  46. package/lib/cjs/Metadata/Constant.js +123 -123
  47. package/lib/cjs/Metadata/Constant.js.map +1 -1
  48. package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
  49. package/lib/cjs/Metadata/CustomAttribute.js +27 -27
  50. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  51. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
  52. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  53. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  54. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  55. package/lib/cjs/Metadata/EntityClass.js +230 -230
  56. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  57. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  58. package/lib/cjs/Metadata/Enumeration.js +159 -159
  59. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  60. package/lib/cjs/Metadata/Format.d.ts +98 -98
  61. package/lib/cjs/Metadata/Format.js +242 -242
  62. package/lib/cjs/Metadata/Format.js.map +1 -1
  63. package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
  64. package/lib/cjs/Metadata/InvertedUnit.js +97 -97
  65. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  66. package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
  67. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  68. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  69. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  70. package/lib/cjs/Metadata/Mixin.js +113 -113
  71. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  72. package/lib/cjs/Metadata/OverrideFormat.d.ts +55 -55
  73. package/lib/cjs/Metadata/OverrideFormat.js +88 -88
  74. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  75. package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
  76. package/lib/cjs/Metadata/Phenomenon.js +59 -59
  77. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  78. package/lib/cjs/Metadata/Property.d.ts +197 -197
  79. package/lib/cjs/Metadata/Property.js +491 -491
  80. package/lib/cjs/Metadata/Property.js.map +1 -1
  81. package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
  82. package/lib/cjs/Metadata/PropertyCategory.js +61 -61
  83. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  84. package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
  85. package/lib/cjs/Metadata/RelationshipClass.js +349 -349
  86. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  87. package/lib/cjs/Metadata/Schema.d.ts +291 -291
  88. package/lib/cjs/Metadata/Schema.js +520 -520
  89. package/lib/cjs/Metadata/Schema.js.map +1 -1
  90. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  91. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  92. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  93. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  94. package/lib/cjs/Metadata/Unit.js +162 -162
  95. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  96. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  97. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  98. package/lib/cjs/PropertyTypes.d.ts +49 -49
  99. package/lib/cjs/PropertyTypes.js +91 -91
  100. package/lib/cjs/PropertyTypes.js.map +1 -1
  101. package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
  102. package/lib/cjs/SchemaJsonLocater.js +42 -42
  103. package/lib/cjs/SchemaJsonLocater.js.map +1 -1
  104. package/lib/cjs/SchemaKey.d.ts +110 -110
  105. package/lib/cjs/SchemaKey.js +219 -219
  106. package/lib/cjs/SchemaKey.js.map +1 -1
  107. package/lib/cjs/SchemaLoader.d.ts +23 -23
  108. package/lib/cjs/SchemaLoader.js +47 -47
  109. package/lib/cjs/SchemaLoader.js.map +1 -1
  110. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  111. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  112. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  113. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  114. package/lib/cjs/UnitConversion/Graph.js +83 -83
  115. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  116. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  117. package/lib/cjs/UnitConversion/Parser.js +42 -42
  118. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  119. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  120. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  121. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  122. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  123. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  124. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  125. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  126. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  127. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  128. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  129. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +236 -236
  130. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  131. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  132. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  133. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  134. package/lib/cjs/ecschema-metadata.d.ts +51 -51
  135. package/lib/cjs/ecschema-metadata.js +96 -96
  136. package/lib/cjs/ecschema-metadata.js.map +1 -1
  137. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  138. package/lib/cjs/utils/SchemaGraph.js +65 -65
  139. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  140. package/package.json +7 -7
@@ -1,454 +1,454 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Metadata
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.strengthDirectionToString = exports.parseStrengthDirection = exports.strengthToString = exports.parseStrength = exports.relationshipEndToString = exports.parseRelationshipEnd = exports.containerTypeToString = exports.parseCustomAttributeContainerType = exports.primitiveTypeToString = exports.parsePrimitiveType = exports.schemaItemTypeToXmlString = exports.schemaItemTypeToString = exports.parseSchemaItemType = exports.classModifierToString = exports.parseClassModifier = exports.StrengthDirection = exports.StrengthType = exports.RelationshipEnd = exports.SchemaMatchType = exports.CustomAttributeContainerType = exports.PrimitiveType = exports.SchemaItemType = exports.ECClassModifier = exports.PropertyType = void 0;
11
- const Constants_1 = require("./Constants");
12
- const Exception_1 = require("./Exception");
13
- var PropertyTypes_1 = require("./PropertyTypes");
14
- Object.defineProperty(exports, "PropertyType", { enumerable: true, get: function () { return PropertyTypes_1.PropertyType; } });
15
- // NEEDSWORK: This shim is currently required to use async iterators. See https://github.com/Microsoft/TypeScript/issues/14151
16
- if (!Symbol.asyncIterator) {
17
- Symbol.asyncIterator = Symbol.for("Symbol.asyncIterator");
18
- }
19
- /** @beta */
20
- var ECClassModifier;
21
- (function (ECClassModifier) {
22
- ECClassModifier[ECClassModifier["None"] = 0] = "None";
23
- ECClassModifier[ECClassModifier["Abstract"] = 1] = "Abstract";
24
- ECClassModifier[ECClassModifier["Sealed"] = 2] = "Sealed";
25
- })(ECClassModifier = exports.ECClassModifier || (exports.ECClassModifier = {}));
26
- /** @beta */
27
- var SchemaItemType;
28
- (function (SchemaItemType) {
29
- SchemaItemType[SchemaItemType["EntityClass"] = 0] = "EntityClass";
30
- SchemaItemType[SchemaItemType["Mixin"] = 1] = "Mixin";
31
- SchemaItemType[SchemaItemType["StructClass"] = 2] = "StructClass";
32
- SchemaItemType[SchemaItemType["CustomAttributeClass"] = 3] = "CustomAttributeClass";
33
- SchemaItemType[SchemaItemType["RelationshipClass"] = 4] = "RelationshipClass";
34
- SchemaItemType[SchemaItemType["Enumeration"] = 5] = "Enumeration";
35
- SchemaItemType[SchemaItemType["KindOfQuantity"] = 6] = "KindOfQuantity";
36
- SchemaItemType[SchemaItemType["PropertyCategory"] = 7] = "PropertyCategory";
37
- SchemaItemType[SchemaItemType["Unit"] = 8] = "Unit";
38
- SchemaItemType[SchemaItemType["InvertedUnit"] = 9] = "InvertedUnit";
39
- SchemaItemType[SchemaItemType["Constant"] = 10] = "Constant";
40
- SchemaItemType[SchemaItemType["Phenomenon"] = 11] = "Phenomenon";
41
- SchemaItemType[SchemaItemType["UnitSystem"] = 12] = "UnitSystem";
42
- SchemaItemType[SchemaItemType["Format"] = 13] = "Format";
43
- })(SchemaItemType = exports.SchemaItemType || (exports.SchemaItemType = {}));
44
- /**
45
- * Primitive data types for ECProperties.
46
- * @beta
47
- */
48
- var PrimitiveType;
49
- (function (PrimitiveType) {
50
- PrimitiveType[PrimitiveType["Uninitialized"] = 0] = "Uninitialized";
51
- PrimitiveType[PrimitiveType["Binary"] = 257] = "Binary";
52
- PrimitiveType[PrimitiveType["Boolean"] = 513] = "Boolean";
53
- PrimitiveType[PrimitiveType["DateTime"] = 769] = "DateTime";
54
- PrimitiveType[PrimitiveType["Double"] = 1025] = "Double";
55
- PrimitiveType[PrimitiveType["Integer"] = 1281] = "Integer";
56
- PrimitiveType[PrimitiveType["Long"] = 1537] = "Long";
57
- PrimitiveType[PrimitiveType["Point2d"] = 1793] = "Point2d";
58
- PrimitiveType[PrimitiveType["Point3d"] = 2049] = "Point3d";
59
- PrimitiveType[PrimitiveType["String"] = 2305] = "String";
60
- PrimitiveType[PrimitiveType["IGeometry"] = 2561] = "IGeometry";
61
- })(PrimitiveType = exports.PrimitiveType || (exports.PrimitiveType = {}));
62
- /**
63
- * Defines the valid CustomAttribute container types.
64
- * @beta
65
- */
66
- var CustomAttributeContainerType;
67
- (function (CustomAttributeContainerType) {
68
- CustomAttributeContainerType[CustomAttributeContainerType["Schema"] = 1] = "Schema";
69
- CustomAttributeContainerType[CustomAttributeContainerType["EntityClass"] = 2] = "EntityClass";
70
- CustomAttributeContainerType[CustomAttributeContainerType["CustomAttributeClass"] = 4] = "CustomAttributeClass";
71
- CustomAttributeContainerType[CustomAttributeContainerType["StructClass"] = 8] = "StructClass";
72
- CustomAttributeContainerType[CustomAttributeContainerType["RelationshipClass"] = 16] = "RelationshipClass";
73
- CustomAttributeContainerType[CustomAttributeContainerType["AnyClass"] = 30] = "AnyClass";
74
- CustomAttributeContainerType[CustomAttributeContainerType["PrimitiveProperty"] = 32] = "PrimitiveProperty";
75
- CustomAttributeContainerType[CustomAttributeContainerType["StructProperty"] = 64] = "StructProperty";
76
- CustomAttributeContainerType[CustomAttributeContainerType["PrimitiveArrayProperty"] = 128] = "PrimitiveArrayProperty";
77
- CustomAttributeContainerType[CustomAttributeContainerType["StructArrayProperty"] = 256] = "StructArrayProperty";
78
- CustomAttributeContainerType[CustomAttributeContainerType["NavigationProperty"] = 512] = "NavigationProperty";
79
- CustomAttributeContainerType[CustomAttributeContainerType["AnyProperty"] = 992] = "AnyProperty";
80
- CustomAttributeContainerType[CustomAttributeContainerType["SourceRelationshipConstraint"] = 1024] = "SourceRelationshipConstraint";
81
- CustomAttributeContainerType[CustomAttributeContainerType["TargetRelationshipConstraint"] = 2048] = "TargetRelationshipConstraint";
82
- CustomAttributeContainerType[CustomAttributeContainerType["AnyRelationshipConstraint"] = 3072] = "AnyRelationshipConstraint";
83
- CustomAttributeContainerType[CustomAttributeContainerType["Any"] = 4095] = "Any";
84
- })(CustomAttributeContainerType = exports.CustomAttributeContainerType || (exports.CustomAttributeContainerType = {}));
85
- /**
86
- * Defines what sort of match should be used when locating a schema.
87
- * @beta
88
- */
89
- var SchemaMatchType;
90
- (function (SchemaMatchType) {
91
- // Find exact VersionRead, VersionWrite, VersionMinor match as well as Data
92
- SchemaMatchType[SchemaMatchType["Identical"] = 0] = "Identical";
93
- // Find exact VersionRead, VersionWrite, VersionMinor match.
94
- SchemaMatchType[SchemaMatchType["Exact"] = 1] = "Exact";
95
- // Find latest version with matching VersionRead and VersionWrite
96
- SchemaMatchType[SchemaMatchType["LatestWriteCompatible"] = 2] = "LatestWriteCompatible";
97
- // Find latest version.
98
- SchemaMatchType[SchemaMatchType["Latest"] = 3] = "Latest";
99
- // Find latest version with matching VersionRead
100
- SchemaMatchType[SchemaMatchType["LatestReadCompatible"] = 4] = "LatestReadCompatible";
101
- })(SchemaMatchType = exports.SchemaMatchType || (exports.SchemaMatchType = {}));
102
- /**
103
- * Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.
104
- * @beta
105
- */
106
- var RelationshipEnd;
107
- (function (RelationshipEnd) {
108
- RelationshipEnd[RelationshipEnd["Source"] = 0] = "Source";
109
- RelationshipEnd[RelationshipEnd["Target"] = 1] = "Target";
110
- })(RelationshipEnd = exports.RelationshipEnd || (exports.RelationshipEnd = {}));
111
- /** @beta */
112
- var StrengthType;
113
- (function (StrengthType) {
114
- StrengthType[StrengthType["Referencing"] = 0] = "Referencing";
115
- StrengthType[StrengthType["Holding"] = 1] = "Holding";
116
- StrengthType[StrengthType["Embedding"] = 2] = "Embedding";
117
- })(StrengthType = exports.StrengthType || (exports.StrengthType = {}));
118
- /** @beta */
119
- var StrengthDirection;
120
- (function (StrengthDirection) {
121
- StrengthDirection[StrengthDirection["Forward"] = 1] = "Forward";
122
- StrengthDirection[StrengthDirection["Backward"] = 2] = "Backward";
123
- })(StrengthDirection = exports.StrengthDirection || (exports.StrengthDirection = {}));
124
- // Helper methods for going to/from string for the above Enumerations.
125
- /**
126
- * Parses the provided string into an ECClassModifier if the string is a valid modifier.
127
- * @param modifier The modifier string to parse.
128
- * @beta
129
- */
130
- function parseClassModifier(modifier) {
131
- const lowerModifier = modifier.toLowerCase();
132
- switch (lowerModifier) {
133
- case "abstract": return ECClassModifier.Abstract;
134
- case "none": return ECClassModifier.None;
135
- case "sealed": return ECClassModifier.Sealed;
136
- }
137
- return undefined;
138
- }
139
- exports.parseClassModifier = parseClassModifier;
140
- /**
141
- * @return A string representing the provided ECClassModifier. If the modifier is not valid, an empty string is returned.
142
- * @beta
143
- */
144
- function classModifierToString(modifier) {
145
- switch (modifier) {
146
- case ECClassModifier.Abstract: return "Abstract";
147
- case ECClassModifier.None: return "None";
148
- case ECClassModifier.Sealed: return "Sealed";
149
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidModifier, "An invalid ECClassModifier has been provided.");
150
- }
151
- }
152
- exports.classModifierToString = classModifierToString;
153
- /**
154
- * Tries to parse the given string as one of the 8 schema item types.
155
- * @param type The schema item type string to parse.
156
- * @returns A valid SchemaItemType if successfully parsed. Otherwise, undefined if the provided string is not a valid SchemaItemType.
157
- * @beta
158
- */
159
- function parseSchemaItemType(type) {
160
- switch (type.toLowerCase()) {
161
- case "entityclass": return SchemaItemType.EntityClass;
162
- case "mixin": return SchemaItemType.Mixin;
163
- case "structclass": return SchemaItemType.StructClass;
164
- case "customattributeclass": return SchemaItemType.CustomAttributeClass;
165
- case "relationshipclass": return SchemaItemType.RelationshipClass;
166
- case "enumeration": return SchemaItemType.Enumeration;
167
- case "kindofquantity": return SchemaItemType.KindOfQuantity;
168
- case "propertycategory": return SchemaItemType.PropertyCategory;
169
- case "unit": return SchemaItemType.Unit;
170
- case "invertedunit": return SchemaItemType.InvertedUnit;
171
- case "constant": return SchemaItemType.Constant;
172
- case "phenomenon": return SchemaItemType.Phenomenon;
173
- case "unitsystem": return SchemaItemType.UnitSystem;
174
- case "format": return SchemaItemType.Format;
175
- }
176
- return undefined;
177
- }
178
- exports.parseSchemaItemType = parseSchemaItemType;
179
- /**
180
- * Converts a valid SchemaItemType to a display string.
181
- * @param value The SchemaItemType to stringify.
182
- * @return A string representing the provided SchemaItemType. If the type is not valid, an empty string is returned.
183
- * @beta
184
- */
185
- function schemaItemTypeToString(value) {
186
- switch (value) {
187
- case SchemaItemType.EntityClass: return "EntityClass";
188
- case SchemaItemType.Mixin: return "Mixin";
189
- case SchemaItemType.StructClass: return "StructClass";
190
- case SchemaItemType.CustomAttributeClass: return "CustomAttributeClass";
191
- case SchemaItemType.RelationshipClass: return "RelationshipClass";
192
- case SchemaItemType.Enumeration: return "Enumeration";
193
- case SchemaItemType.KindOfQuantity: return "KindOfQuantity";
194
- case SchemaItemType.PropertyCategory: return "PropertyCategory";
195
- case SchemaItemType.Unit: return "Unit";
196
- case SchemaItemType.InvertedUnit: return "InvertedUnit";
197
- case SchemaItemType.Constant: return "Constant";
198
- case SchemaItemType.Phenomenon: return "Phenomenon";
199
- case SchemaItemType.UnitSystem: return "UnitSystem";
200
- case SchemaItemType.Format: return "Format";
201
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, "An invalid SchemaItemType has been provided.");
202
- }
203
- }
204
- exports.schemaItemTypeToString = schemaItemTypeToString;
205
- /** @internal */
206
- function schemaItemTypeToXmlString(value) {
207
- switch (value) {
208
- case SchemaItemType.EntityClass: return "ECEntityClass";
209
- case SchemaItemType.Mixin: return "ECEntityClass";
210
- case SchemaItemType.StructClass: return "ECStructClass";
211
- case SchemaItemType.CustomAttributeClass: return "ECCustomAttributeClass";
212
- case SchemaItemType.RelationshipClass: return "ECRelationshipClass";
213
- case SchemaItemType.Enumeration: return "ECEnumeration";
214
- case SchemaItemType.KindOfQuantity: return "KindOfQuantity";
215
- case SchemaItemType.PropertyCategory: return "PropertyCategory";
216
- case SchemaItemType.Unit: return "Unit";
217
- case SchemaItemType.InvertedUnit: return "InvertedUnit";
218
- case SchemaItemType.Constant: return "Constant";
219
- case SchemaItemType.Phenomenon: return "Phenomenon";
220
- case SchemaItemType.UnitSystem: return "UnitSystem";
221
- case SchemaItemType.Format: return "Format";
222
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, "An invalid SchemaItemType has been provided.");
223
- }
224
- }
225
- exports.schemaItemTypeToXmlString = schemaItemTypeToXmlString;
226
- /**
227
- * Tries to parse the given string as one of the 10 primitive types.
228
- * @param type The primitive type string to parse.
229
- * @returns A valid PrimitiveType if successfully parsed, or undefined if the provided string is not a valid PrimitiveType.
230
- * @beta
231
- */
232
- function parsePrimitiveType(type) {
233
- switch (type.toLowerCase()) {
234
- case "binary": return PrimitiveType.Binary;
235
- case "boolean":
236
- case "bool": return PrimitiveType.Boolean;
237
- case "datetime": return PrimitiveType.DateTime;
238
- case "double": return PrimitiveType.Double;
239
- case "int": return PrimitiveType.Integer;
240
- case "long": return PrimitiveType.Long;
241
- case "point2d": return PrimitiveType.Point2d;
242
- case "point3d": return PrimitiveType.Point3d;
243
- case "string": return PrimitiveType.String;
244
- case "bentley.geometry.common.igeometry": return PrimitiveType.IGeometry;
245
- }
246
- return undefined;
247
- }
248
- exports.parsePrimitiveType = parsePrimitiveType;
249
- /** @beta */
250
- function primitiveTypeToString(type) {
251
- switch (type) {
252
- case PrimitiveType.Binary: return "binary";
253
- case PrimitiveType.Boolean: return "boolean";
254
- case PrimitiveType.DateTime: return "dateTime";
255
- case PrimitiveType.Double: return "double";
256
- case PrimitiveType.Integer: return "int";
257
- case PrimitiveType.IGeometry: return "Bentley.Geometry.Common.IGeometry";
258
- case PrimitiveType.Long: return "long";
259
- case PrimitiveType.Point2d: return "point2d";
260
- case PrimitiveType.Point3d: return "point3d";
261
- case PrimitiveType.String: return "string";
262
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidPrimitiveType, "An invalid PrimitiveType has been provided.");
263
- }
264
- }
265
- exports.primitiveTypeToString = primitiveTypeToString;
266
- /**
267
- * Parses the given string into the appropriate CustomAttributeContainerType if the string is valid.
268
- * @param type The container type string to parse.
269
- * @beta
270
- */
271
- function parseCustomAttributeContainerType(type) {
272
- const typeTokens = type.split(/[|,;]+/);
273
- let containerType = 0;
274
- typeTokens.forEach((typeToken) => {
275
- typeToken = typeToken.trim();
276
- if (typeToken.length === 0)
277
- return;
278
- typeToken = typeToken.toLowerCase();
279
- switch (typeToken) {
280
- case "schema":
281
- containerType = containerType | CustomAttributeContainerType.Schema;
282
- break;
283
- case "entityclass":
284
- containerType = containerType | CustomAttributeContainerType.EntityClass;
285
- break;
286
- case "customattributeclass":
287
- containerType = containerType | CustomAttributeContainerType.CustomAttributeClass;
288
- break;
289
- case "structclass":
290
- containerType = containerType | CustomAttributeContainerType.StructClass;
291
- break;
292
- case "relationshipclass":
293
- containerType = containerType | CustomAttributeContainerType.RelationshipClass;
294
- break;
295
- case "anyclass":
296
- containerType = containerType | CustomAttributeContainerType.AnyClass;
297
- break;
298
- case "primitiveproperty":
299
- containerType = containerType | CustomAttributeContainerType.PrimitiveProperty;
300
- break;
301
- case "structproperty":
302
- containerType = containerType | CustomAttributeContainerType.StructProperty;
303
- break;
304
- case "arrayproperty":
305
- containerType = containerType | CustomAttributeContainerType.PrimitiveArrayProperty;
306
- break;
307
- case "structarrayproperty":
308
- containerType = containerType | CustomAttributeContainerType.StructArrayProperty;
309
- break;
310
- case "navigationproperty":
311
- containerType = containerType | CustomAttributeContainerType.NavigationProperty;
312
- break;
313
- case "anyproperty":
314
- containerType = containerType | CustomAttributeContainerType.AnyProperty;
315
- break;
316
- case "sourcerelationshipconstraint":
317
- containerType = containerType | CustomAttributeContainerType.SourceRelationshipConstraint;
318
- break;
319
- case "targetrelationshipconstraint":
320
- containerType = containerType | CustomAttributeContainerType.TargetRelationshipConstraint;
321
- break;
322
- case "anyrelationshipconstraint":
323
- containerType = containerType | CustomAttributeContainerType.AnyRelationshipConstraint;
324
- break;
325
- case "any":
326
- containerType = containerType | CustomAttributeContainerType.Any;
327
- break;
328
- default:
329
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidContainerType, `${typeToken} is not a valid CustomAttributeContainerType value.`);
330
- }
331
- });
332
- return containerType;
333
- }
334
- exports.parseCustomAttributeContainerType = parseCustomAttributeContainerType;
335
- /**
336
- * Creates a string representing a valid CustomAttributeContainerType.
337
- * @param value The CustomAttributeContainerType to stringify.
338
- * @return A string representing the provided CustomAttributeContainerType. If the type is not valid, an empty string is returned.
339
- * @beta
340
- */
341
- function containerTypeToString(type) {
342
- const testContainerTypeValue = (compareType, otherType) => {
343
- return (compareType === (compareType & otherType));
344
- };
345
- if (testContainerTypeValue(CustomAttributeContainerType.Any, type))
346
- return Constants_1.ECStringConstants.CONTAINERTYPE_ANY;
347
- let containerType = "";
348
- const setOrAppend = (val) => {
349
- if (containerType.length === 0)
350
- containerType = val;
351
- else
352
- containerType = `${containerType}, ${val}`;
353
- };
354
- if (testContainerTypeValue(CustomAttributeContainerType.Schema, type))
355
- setOrAppend("Schema");
356
- if (testContainerTypeValue(CustomAttributeContainerType.AnyClass, type))
357
- setOrAppend("AnyClass");
358
- else {
359
- if (testContainerTypeValue(CustomAttributeContainerType.EntityClass, type))
360
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_ENTITYCLASS);
361
- if (testContainerTypeValue(CustomAttributeContainerType.CustomAttributeClass, type))
362
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_CUSTOMATTRIBUTECLASS);
363
- if (testContainerTypeValue(CustomAttributeContainerType.StructClass, type))
364
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_STRUCTCLASS);
365
- if (testContainerTypeValue(CustomAttributeContainerType.RelationshipClass, type))
366
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_RELATIONSHIPCLASS);
367
- }
368
- if (testContainerTypeValue(CustomAttributeContainerType.AnyProperty, type))
369
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_ANYPROPERTY);
370
- else {
371
- if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveProperty, type))
372
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_PRIMITIVEPROPERTY);
373
- if (testContainerTypeValue(CustomAttributeContainerType.StructProperty, type))
374
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_STRUCTPROPERTY);
375
- if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveArrayProperty, type))
376
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_PRIMITIVEARRAYPROPERTY);
377
- if (testContainerTypeValue(CustomAttributeContainerType.StructArrayProperty, type))
378
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_STRUCTARRAYPROPERTY);
379
- if (testContainerTypeValue(CustomAttributeContainerType.NavigationProperty, type))
380
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_NAVIGATIONPROPERTY);
381
- }
382
- if (testContainerTypeValue(CustomAttributeContainerType.AnyRelationshipConstraint, type))
383
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT);
384
- else {
385
- if (testContainerTypeValue(CustomAttributeContainerType.SourceRelationshipConstraint, type))
386
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT);
387
- if (testContainerTypeValue(CustomAttributeContainerType.TargetRelationshipConstraint, type))
388
- setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT);
389
- }
390
- return containerType;
391
- }
392
- exports.containerTypeToString = containerTypeToString;
393
- /** @beta */
394
- function parseRelationshipEnd(end) {
395
- switch (end.toLowerCase()) {
396
- case "source": return RelationshipEnd.Source;
397
- case "target": return RelationshipEnd.Target;
398
- }
399
- return undefined;
400
- }
401
- exports.parseRelationshipEnd = parseRelationshipEnd;
402
- /** @beta */
403
- function relationshipEndToString(end) {
404
- switch (end) {
405
- case RelationshipEnd.Source: return Constants_1.ECStringConstants.RELATIONSHIP_END_SOURCE;
406
- case RelationshipEnd.Target: return Constants_1.ECStringConstants.RELATIONSHIP_END_TARGET;
407
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidRelationshipEnd, `An invalid RelationshipEnd has been provided.`);
408
- }
409
- }
410
- exports.relationshipEndToString = relationshipEndToString;
411
- /**
412
- * Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.
413
- * @throws ECObjectsStatus.InvalidStrength if the provided string that is not valid
414
- * @param strength
415
- * @beta
416
- */
417
- function parseStrength(strength) {
418
- switch (strength.toLowerCase()) {
419
- case "referencing": return StrengthType.Referencing;
420
- case "holding": return StrengthType.Holding;
421
- case "embedding": return StrengthType.Embedding;
422
- }
423
- return undefined;
424
- }
425
- exports.parseStrength = parseStrength;
426
- /** @beta */
427
- function strengthToString(strength) {
428
- switch (strength) {
429
- case StrengthType.Embedding: return "Embedding";
430
- case StrengthType.Holding: return "Holding";
431
- case StrengthType.Referencing: return "Referencing";
432
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrength, `An invalid Strength has been provided.`);
433
- }
434
- }
435
- exports.strengthToString = strengthToString;
436
- /** @beta */
437
- function parseStrengthDirection(direction) {
438
- switch (direction.toLowerCase()) {
439
- case "forward": return StrengthDirection.Forward;
440
- case "backward": return StrengthDirection.Backward;
441
- }
442
- return undefined;
443
- }
444
- exports.parseStrengthDirection = parseStrengthDirection;
445
- /** @beta */
446
- function strengthDirectionToString(direction) {
447
- switch (direction) {
448
- case StrengthDirection.Forward: return "Forward";
449
- case StrengthDirection.Backward: return "Backward";
450
- default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrengthDirection, `An invalid StrengthDirection has been provided.`);
451
- }
452
- }
453
- exports.strengthDirectionToString = strengthDirectionToString;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Metadata
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.strengthDirectionToString = exports.parseStrengthDirection = exports.strengthToString = exports.parseStrength = exports.relationshipEndToString = exports.parseRelationshipEnd = exports.containerTypeToString = exports.parseCustomAttributeContainerType = exports.primitiveTypeToString = exports.parsePrimitiveType = exports.schemaItemTypeToXmlString = exports.schemaItemTypeToString = exports.parseSchemaItemType = exports.classModifierToString = exports.parseClassModifier = exports.StrengthDirection = exports.StrengthType = exports.RelationshipEnd = exports.SchemaMatchType = exports.CustomAttributeContainerType = exports.PrimitiveType = exports.SchemaItemType = exports.ECClassModifier = exports.PropertyType = void 0;
11
+ const Constants_1 = require("./Constants");
12
+ const Exception_1 = require("./Exception");
13
+ var PropertyTypes_1 = require("./PropertyTypes");
14
+ Object.defineProperty(exports, "PropertyType", { enumerable: true, get: function () { return PropertyTypes_1.PropertyType; } });
15
+ // NEEDSWORK: This shim is currently required to use async iterators. See https://github.com/Microsoft/TypeScript/issues/14151
16
+ if (!Symbol.asyncIterator) {
17
+ Symbol.asyncIterator = Symbol.for("Symbol.asyncIterator");
18
+ }
19
+ /** @beta */
20
+ var ECClassModifier;
21
+ (function (ECClassModifier) {
22
+ ECClassModifier[ECClassModifier["None"] = 0] = "None";
23
+ ECClassModifier[ECClassModifier["Abstract"] = 1] = "Abstract";
24
+ ECClassModifier[ECClassModifier["Sealed"] = 2] = "Sealed";
25
+ })(ECClassModifier = exports.ECClassModifier || (exports.ECClassModifier = {}));
26
+ /** @beta */
27
+ var SchemaItemType;
28
+ (function (SchemaItemType) {
29
+ SchemaItemType[SchemaItemType["EntityClass"] = 0] = "EntityClass";
30
+ SchemaItemType[SchemaItemType["Mixin"] = 1] = "Mixin";
31
+ SchemaItemType[SchemaItemType["StructClass"] = 2] = "StructClass";
32
+ SchemaItemType[SchemaItemType["CustomAttributeClass"] = 3] = "CustomAttributeClass";
33
+ SchemaItemType[SchemaItemType["RelationshipClass"] = 4] = "RelationshipClass";
34
+ SchemaItemType[SchemaItemType["Enumeration"] = 5] = "Enumeration";
35
+ SchemaItemType[SchemaItemType["KindOfQuantity"] = 6] = "KindOfQuantity";
36
+ SchemaItemType[SchemaItemType["PropertyCategory"] = 7] = "PropertyCategory";
37
+ SchemaItemType[SchemaItemType["Unit"] = 8] = "Unit";
38
+ SchemaItemType[SchemaItemType["InvertedUnit"] = 9] = "InvertedUnit";
39
+ SchemaItemType[SchemaItemType["Constant"] = 10] = "Constant";
40
+ SchemaItemType[SchemaItemType["Phenomenon"] = 11] = "Phenomenon";
41
+ SchemaItemType[SchemaItemType["UnitSystem"] = 12] = "UnitSystem";
42
+ SchemaItemType[SchemaItemType["Format"] = 13] = "Format";
43
+ })(SchemaItemType = exports.SchemaItemType || (exports.SchemaItemType = {}));
44
+ /**
45
+ * Primitive data types for ECProperties.
46
+ * @beta
47
+ */
48
+ var PrimitiveType;
49
+ (function (PrimitiveType) {
50
+ PrimitiveType[PrimitiveType["Uninitialized"] = 0] = "Uninitialized";
51
+ PrimitiveType[PrimitiveType["Binary"] = 257] = "Binary";
52
+ PrimitiveType[PrimitiveType["Boolean"] = 513] = "Boolean";
53
+ PrimitiveType[PrimitiveType["DateTime"] = 769] = "DateTime";
54
+ PrimitiveType[PrimitiveType["Double"] = 1025] = "Double";
55
+ PrimitiveType[PrimitiveType["Integer"] = 1281] = "Integer";
56
+ PrimitiveType[PrimitiveType["Long"] = 1537] = "Long";
57
+ PrimitiveType[PrimitiveType["Point2d"] = 1793] = "Point2d";
58
+ PrimitiveType[PrimitiveType["Point3d"] = 2049] = "Point3d";
59
+ PrimitiveType[PrimitiveType["String"] = 2305] = "String";
60
+ PrimitiveType[PrimitiveType["IGeometry"] = 2561] = "IGeometry";
61
+ })(PrimitiveType = exports.PrimitiveType || (exports.PrimitiveType = {}));
62
+ /**
63
+ * Defines the valid CustomAttribute container types.
64
+ * @beta
65
+ */
66
+ var CustomAttributeContainerType;
67
+ (function (CustomAttributeContainerType) {
68
+ CustomAttributeContainerType[CustomAttributeContainerType["Schema"] = 1] = "Schema";
69
+ CustomAttributeContainerType[CustomAttributeContainerType["EntityClass"] = 2] = "EntityClass";
70
+ CustomAttributeContainerType[CustomAttributeContainerType["CustomAttributeClass"] = 4] = "CustomAttributeClass";
71
+ CustomAttributeContainerType[CustomAttributeContainerType["StructClass"] = 8] = "StructClass";
72
+ CustomAttributeContainerType[CustomAttributeContainerType["RelationshipClass"] = 16] = "RelationshipClass";
73
+ CustomAttributeContainerType[CustomAttributeContainerType["AnyClass"] = 30] = "AnyClass";
74
+ CustomAttributeContainerType[CustomAttributeContainerType["PrimitiveProperty"] = 32] = "PrimitiveProperty";
75
+ CustomAttributeContainerType[CustomAttributeContainerType["StructProperty"] = 64] = "StructProperty";
76
+ CustomAttributeContainerType[CustomAttributeContainerType["PrimitiveArrayProperty"] = 128] = "PrimitiveArrayProperty";
77
+ CustomAttributeContainerType[CustomAttributeContainerType["StructArrayProperty"] = 256] = "StructArrayProperty";
78
+ CustomAttributeContainerType[CustomAttributeContainerType["NavigationProperty"] = 512] = "NavigationProperty";
79
+ CustomAttributeContainerType[CustomAttributeContainerType["AnyProperty"] = 992] = "AnyProperty";
80
+ CustomAttributeContainerType[CustomAttributeContainerType["SourceRelationshipConstraint"] = 1024] = "SourceRelationshipConstraint";
81
+ CustomAttributeContainerType[CustomAttributeContainerType["TargetRelationshipConstraint"] = 2048] = "TargetRelationshipConstraint";
82
+ CustomAttributeContainerType[CustomAttributeContainerType["AnyRelationshipConstraint"] = 3072] = "AnyRelationshipConstraint";
83
+ CustomAttributeContainerType[CustomAttributeContainerType["Any"] = 4095] = "Any";
84
+ })(CustomAttributeContainerType = exports.CustomAttributeContainerType || (exports.CustomAttributeContainerType = {}));
85
+ /**
86
+ * Defines what sort of match should be used when locating a schema.
87
+ * @beta
88
+ */
89
+ var SchemaMatchType;
90
+ (function (SchemaMatchType) {
91
+ // Find exact VersionRead, VersionWrite, VersionMinor match as well as Data
92
+ SchemaMatchType[SchemaMatchType["Identical"] = 0] = "Identical";
93
+ // Find exact VersionRead, VersionWrite, VersionMinor match.
94
+ SchemaMatchType[SchemaMatchType["Exact"] = 1] = "Exact";
95
+ // Find latest version with matching VersionRead and VersionWrite
96
+ SchemaMatchType[SchemaMatchType["LatestWriteCompatible"] = 2] = "LatestWriteCompatible";
97
+ // Find latest version.
98
+ SchemaMatchType[SchemaMatchType["Latest"] = 3] = "Latest";
99
+ // Find latest version with matching VersionRead
100
+ SchemaMatchType[SchemaMatchType["LatestReadCompatible"] = 4] = "LatestReadCompatible";
101
+ })(SchemaMatchType = exports.SchemaMatchType || (exports.SchemaMatchType = {}));
102
+ /**
103
+ * Identifer for an ECRelationshipConstraint. Used to determine the side of the relationship the constraint is representing.
104
+ * @beta
105
+ */
106
+ var RelationshipEnd;
107
+ (function (RelationshipEnd) {
108
+ RelationshipEnd[RelationshipEnd["Source"] = 0] = "Source";
109
+ RelationshipEnd[RelationshipEnd["Target"] = 1] = "Target";
110
+ })(RelationshipEnd = exports.RelationshipEnd || (exports.RelationshipEnd = {}));
111
+ /** @beta */
112
+ var StrengthType;
113
+ (function (StrengthType) {
114
+ StrengthType[StrengthType["Referencing"] = 0] = "Referencing";
115
+ StrengthType[StrengthType["Holding"] = 1] = "Holding";
116
+ StrengthType[StrengthType["Embedding"] = 2] = "Embedding";
117
+ })(StrengthType = exports.StrengthType || (exports.StrengthType = {}));
118
+ /** @beta */
119
+ var StrengthDirection;
120
+ (function (StrengthDirection) {
121
+ StrengthDirection[StrengthDirection["Forward"] = 1] = "Forward";
122
+ StrengthDirection[StrengthDirection["Backward"] = 2] = "Backward";
123
+ })(StrengthDirection = exports.StrengthDirection || (exports.StrengthDirection = {}));
124
+ // Helper methods for going to/from string for the above Enumerations.
125
+ /**
126
+ * Parses the provided string into an ECClassModifier if the string is a valid modifier.
127
+ * @param modifier The modifier string to parse.
128
+ * @beta
129
+ */
130
+ function parseClassModifier(modifier) {
131
+ const lowerModifier = modifier.toLowerCase();
132
+ switch (lowerModifier) {
133
+ case "abstract": return ECClassModifier.Abstract;
134
+ case "none": return ECClassModifier.None;
135
+ case "sealed": return ECClassModifier.Sealed;
136
+ }
137
+ return undefined;
138
+ }
139
+ exports.parseClassModifier = parseClassModifier;
140
+ /**
141
+ * @return A string representing the provided ECClassModifier. If the modifier is not valid, an empty string is returned.
142
+ * @beta
143
+ */
144
+ function classModifierToString(modifier) {
145
+ switch (modifier) {
146
+ case ECClassModifier.Abstract: return "Abstract";
147
+ case ECClassModifier.None: return "None";
148
+ case ECClassModifier.Sealed: return "Sealed";
149
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidModifier, "An invalid ECClassModifier has been provided.");
150
+ }
151
+ }
152
+ exports.classModifierToString = classModifierToString;
153
+ /**
154
+ * Tries to parse the given string as one of the 8 schema item types.
155
+ * @param type The schema item type string to parse.
156
+ * @returns A valid SchemaItemType if successfully parsed. Otherwise, undefined if the provided string is not a valid SchemaItemType.
157
+ * @beta
158
+ */
159
+ function parseSchemaItemType(type) {
160
+ switch (type.toLowerCase()) {
161
+ case "entityclass": return SchemaItemType.EntityClass;
162
+ case "mixin": return SchemaItemType.Mixin;
163
+ case "structclass": return SchemaItemType.StructClass;
164
+ case "customattributeclass": return SchemaItemType.CustomAttributeClass;
165
+ case "relationshipclass": return SchemaItemType.RelationshipClass;
166
+ case "enumeration": return SchemaItemType.Enumeration;
167
+ case "kindofquantity": return SchemaItemType.KindOfQuantity;
168
+ case "propertycategory": return SchemaItemType.PropertyCategory;
169
+ case "unit": return SchemaItemType.Unit;
170
+ case "invertedunit": return SchemaItemType.InvertedUnit;
171
+ case "constant": return SchemaItemType.Constant;
172
+ case "phenomenon": return SchemaItemType.Phenomenon;
173
+ case "unitsystem": return SchemaItemType.UnitSystem;
174
+ case "format": return SchemaItemType.Format;
175
+ }
176
+ return undefined;
177
+ }
178
+ exports.parseSchemaItemType = parseSchemaItemType;
179
+ /**
180
+ * Converts a valid SchemaItemType to a display string.
181
+ * @param value The SchemaItemType to stringify.
182
+ * @return A string representing the provided SchemaItemType. If the type is not valid, an empty string is returned.
183
+ * @beta
184
+ */
185
+ function schemaItemTypeToString(value) {
186
+ switch (value) {
187
+ case SchemaItemType.EntityClass: return "EntityClass";
188
+ case SchemaItemType.Mixin: return "Mixin";
189
+ case SchemaItemType.StructClass: return "StructClass";
190
+ case SchemaItemType.CustomAttributeClass: return "CustomAttributeClass";
191
+ case SchemaItemType.RelationshipClass: return "RelationshipClass";
192
+ case SchemaItemType.Enumeration: return "Enumeration";
193
+ case SchemaItemType.KindOfQuantity: return "KindOfQuantity";
194
+ case SchemaItemType.PropertyCategory: return "PropertyCategory";
195
+ case SchemaItemType.Unit: return "Unit";
196
+ case SchemaItemType.InvertedUnit: return "InvertedUnit";
197
+ case SchemaItemType.Constant: return "Constant";
198
+ case SchemaItemType.Phenomenon: return "Phenomenon";
199
+ case SchemaItemType.UnitSystem: return "UnitSystem";
200
+ case SchemaItemType.Format: return "Format";
201
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, "An invalid SchemaItemType has been provided.");
202
+ }
203
+ }
204
+ exports.schemaItemTypeToString = schemaItemTypeToString;
205
+ /** @internal */
206
+ function schemaItemTypeToXmlString(value) {
207
+ switch (value) {
208
+ case SchemaItemType.EntityClass: return "ECEntityClass";
209
+ case SchemaItemType.Mixin: return "ECEntityClass";
210
+ case SchemaItemType.StructClass: return "ECStructClass";
211
+ case SchemaItemType.CustomAttributeClass: return "ECCustomAttributeClass";
212
+ case SchemaItemType.RelationshipClass: return "ECRelationshipClass";
213
+ case SchemaItemType.Enumeration: return "ECEnumeration";
214
+ case SchemaItemType.KindOfQuantity: return "KindOfQuantity";
215
+ case SchemaItemType.PropertyCategory: return "PropertyCategory";
216
+ case SchemaItemType.Unit: return "Unit";
217
+ case SchemaItemType.InvertedUnit: return "InvertedUnit";
218
+ case SchemaItemType.Constant: return "Constant";
219
+ case SchemaItemType.Phenomenon: return "Phenomenon";
220
+ case SchemaItemType.UnitSystem: return "UnitSystem";
221
+ case SchemaItemType.Format: return "Format";
222
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidSchemaItemType, "An invalid SchemaItemType has been provided.");
223
+ }
224
+ }
225
+ exports.schemaItemTypeToXmlString = schemaItemTypeToXmlString;
226
+ /**
227
+ * Tries to parse the given string as one of the 10 primitive types.
228
+ * @param type The primitive type string to parse.
229
+ * @returns A valid PrimitiveType if successfully parsed, or undefined if the provided string is not a valid PrimitiveType.
230
+ * @beta
231
+ */
232
+ function parsePrimitiveType(type) {
233
+ switch (type.toLowerCase()) {
234
+ case "binary": return PrimitiveType.Binary;
235
+ case "boolean":
236
+ case "bool": return PrimitiveType.Boolean;
237
+ case "datetime": return PrimitiveType.DateTime;
238
+ case "double": return PrimitiveType.Double;
239
+ case "int": return PrimitiveType.Integer;
240
+ case "long": return PrimitiveType.Long;
241
+ case "point2d": return PrimitiveType.Point2d;
242
+ case "point3d": return PrimitiveType.Point3d;
243
+ case "string": return PrimitiveType.String;
244
+ case "bentley.geometry.common.igeometry": return PrimitiveType.IGeometry;
245
+ }
246
+ return undefined;
247
+ }
248
+ exports.parsePrimitiveType = parsePrimitiveType;
249
+ /** @beta */
250
+ function primitiveTypeToString(type) {
251
+ switch (type) {
252
+ case PrimitiveType.Binary: return "binary";
253
+ case PrimitiveType.Boolean: return "boolean";
254
+ case PrimitiveType.DateTime: return "dateTime";
255
+ case PrimitiveType.Double: return "double";
256
+ case PrimitiveType.Integer: return "int";
257
+ case PrimitiveType.IGeometry: return "Bentley.Geometry.Common.IGeometry";
258
+ case PrimitiveType.Long: return "long";
259
+ case PrimitiveType.Point2d: return "point2d";
260
+ case PrimitiveType.Point3d: return "point3d";
261
+ case PrimitiveType.String: return "string";
262
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidPrimitiveType, "An invalid PrimitiveType has been provided.");
263
+ }
264
+ }
265
+ exports.primitiveTypeToString = primitiveTypeToString;
266
+ /**
267
+ * Parses the given string into the appropriate CustomAttributeContainerType if the string is valid.
268
+ * @param type The container type string to parse.
269
+ * @beta
270
+ */
271
+ function parseCustomAttributeContainerType(type) {
272
+ const typeTokens = type.split(/[|,;]+/);
273
+ let containerType = 0;
274
+ typeTokens.forEach((typeToken) => {
275
+ typeToken = typeToken.trim();
276
+ if (typeToken.length === 0)
277
+ return;
278
+ typeToken = typeToken.toLowerCase();
279
+ switch (typeToken) {
280
+ case "schema":
281
+ containerType = containerType | CustomAttributeContainerType.Schema;
282
+ break;
283
+ case "entityclass":
284
+ containerType = containerType | CustomAttributeContainerType.EntityClass;
285
+ break;
286
+ case "customattributeclass":
287
+ containerType = containerType | CustomAttributeContainerType.CustomAttributeClass;
288
+ break;
289
+ case "structclass":
290
+ containerType = containerType | CustomAttributeContainerType.StructClass;
291
+ break;
292
+ case "relationshipclass":
293
+ containerType = containerType | CustomAttributeContainerType.RelationshipClass;
294
+ break;
295
+ case "anyclass":
296
+ containerType = containerType | CustomAttributeContainerType.AnyClass;
297
+ break;
298
+ case "primitiveproperty":
299
+ containerType = containerType | CustomAttributeContainerType.PrimitiveProperty;
300
+ break;
301
+ case "structproperty":
302
+ containerType = containerType | CustomAttributeContainerType.StructProperty;
303
+ break;
304
+ case "arrayproperty":
305
+ containerType = containerType | CustomAttributeContainerType.PrimitiveArrayProperty;
306
+ break;
307
+ case "structarrayproperty":
308
+ containerType = containerType | CustomAttributeContainerType.StructArrayProperty;
309
+ break;
310
+ case "navigationproperty":
311
+ containerType = containerType | CustomAttributeContainerType.NavigationProperty;
312
+ break;
313
+ case "anyproperty":
314
+ containerType = containerType | CustomAttributeContainerType.AnyProperty;
315
+ break;
316
+ case "sourcerelationshipconstraint":
317
+ containerType = containerType | CustomAttributeContainerType.SourceRelationshipConstraint;
318
+ break;
319
+ case "targetrelationshipconstraint":
320
+ containerType = containerType | CustomAttributeContainerType.TargetRelationshipConstraint;
321
+ break;
322
+ case "anyrelationshipconstraint":
323
+ containerType = containerType | CustomAttributeContainerType.AnyRelationshipConstraint;
324
+ break;
325
+ case "any":
326
+ containerType = containerType | CustomAttributeContainerType.Any;
327
+ break;
328
+ default:
329
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidContainerType, `${typeToken} is not a valid CustomAttributeContainerType value.`);
330
+ }
331
+ });
332
+ return containerType;
333
+ }
334
+ exports.parseCustomAttributeContainerType = parseCustomAttributeContainerType;
335
+ /**
336
+ * Creates a string representing a valid CustomAttributeContainerType.
337
+ * @param value The CustomAttributeContainerType to stringify.
338
+ * @return A string representing the provided CustomAttributeContainerType. If the type is not valid, an empty string is returned.
339
+ * @beta
340
+ */
341
+ function containerTypeToString(type) {
342
+ const testContainerTypeValue = (compareType, otherType) => {
343
+ return (compareType === (compareType & otherType));
344
+ };
345
+ if (testContainerTypeValue(CustomAttributeContainerType.Any, type))
346
+ return Constants_1.ECStringConstants.CONTAINERTYPE_ANY;
347
+ let containerType = "";
348
+ const setOrAppend = (val) => {
349
+ if (containerType.length === 0)
350
+ containerType = val;
351
+ else
352
+ containerType = `${containerType}, ${val}`;
353
+ };
354
+ if (testContainerTypeValue(CustomAttributeContainerType.Schema, type))
355
+ setOrAppend("Schema");
356
+ if (testContainerTypeValue(CustomAttributeContainerType.AnyClass, type))
357
+ setOrAppend("AnyClass");
358
+ else {
359
+ if (testContainerTypeValue(CustomAttributeContainerType.EntityClass, type))
360
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_ENTITYCLASS);
361
+ if (testContainerTypeValue(CustomAttributeContainerType.CustomAttributeClass, type))
362
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_CUSTOMATTRIBUTECLASS);
363
+ if (testContainerTypeValue(CustomAttributeContainerType.StructClass, type))
364
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_STRUCTCLASS);
365
+ if (testContainerTypeValue(CustomAttributeContainerType.RelationshipClass, type))
366
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_RELATIONSHIPCLASS);
367
+ }
368
+ if (testContainerTypeValue(CustomAttributeContainerType.AnyProperty, type))
369
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_ANYPROPERTY);
370
+ else {
371
+ if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveProperty, type))
372
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_PRIMITIVEPROPERTY);
373
+ if (testContainerTypeValue(CustomAttributeContainerType.StructProperty, type))
374
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_STRUCTPROPERTY);
375
+ if (testContainerTypeValue(CustomAttributeContainerType.PrimitiveArrayProperty, type))
376
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_PRIMITIVEARRAYPROPERTY);
377
+ if (testContainerTypeValue(CustomAttributeContainerType.StructArrayProperty, type))
378
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_STRUCTARRAYPROPERTY);
379
+ if (testContainerTypeValue(CustomAttributeContainerType.NavigationProperty, type))
380
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_NAVIGATIONPROPERTY);
381
+ }
382
+ if (testContainerTypeValue(CustomAttributeContainerType.AnyRelationshipConstraint, type))
383
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_ANYRELATIONSHIPCONSTRAINT);
384
+ else {
385
+ if (testContainerTypeValue(CustomAttributeContainerType.SourceRelationshipConstraint, type))
386
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_SOURCERELATIONSHIPCONSTRAINT);
387
+ if (testContainerTypeValue(CustomAttributeContainerType.TargetRelationshipConstraint, type))
388
+ setOrAppend(Constants_1.ECStringConstants.CONTAINERTYPE_TARGETRELATIONSHIPCONSTRAINT);
389
+ }
390
+ return containerType;
391
+ }
392
+ exports.containerTypeToString = containerTypeToString;
393
+ /** @beta */
394
+ function parseRelationshipEnd(end) {
395
+ switch (end.toLowerCase()) {
396
+ case "source": return RelationshipEnd.Source;
397
+ case "target": return RelationshipEnd.Target;
398
+ }
399
+ return undefined;
400
+ }
401
+ exports.parseRelationshipEnd = parseRelationshipEnd;
402
+ /** @beta */
403
+ function relationshipEndToString(end) {
404
+ switch (end) {
405
+ case RelationshipEnd.Source: return Constants_1.ECStringConstants.RELATIONSHIP_END_SOURCE;
406
+ case RelationshipEnd.Target: return Constants_1.ECStringConstants.RELATIONSHIP_END_TARGET;
407
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidRelationshipEnd, `An invalid RelationshipEnd has been provided.`);
408
+ }
409
+ }
410
+ exports.relationshipEndToString = relationshipEndToString;
411
+ /**
412
+ * Takes a string representing a StrengthType, will parse it and return the corresponding StrengthType.
413
+ * @throws ECObjectsStatus.InvalidStrength if the provided string that is not valid
414
+ * @param strength
415
+ * @beta
416
+ */
417
+ function parseStrength(strength) {
418
+ switch (strength.toLowerCase()) {
419
+ case "referencing": return StrengthType.Referencing;
420
+ case "holding": return StrengthType.Holding;
421
+ case "embedding": return StrengthType.Embedding;
422
+ }
423
+ return undefined;
424
+ }
425
+ exports.parseStrength = parseStrength;
426
+ /** @beta */
427
+ function strengthToString(strength) {
428
+ switch (strength) {
429
+ case StrengthType.Embedding: return "Embedding";
430
+ case StrengthType.Holding: return "Holding";
431
+ case StrengthType.Referencing: return "Referencing";
432
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrength, `An invalid Strength has been provided.`);
433
+ }
434
+ }
435
+ exports.strengthToString = strengthToString;
436
+ /** @beta */
437
+ function parseStrengthDirection(direction) {
438
+ switch (direction.toLowerCase()) {
439
+ case "forward": return StrengthDirection.Forward;
440
+ case "backward": return StrengthDirection.Backward;
441
+ }
442
+ return undefined;
443
+ }
444
+ exports.parseStrengthDirection = parseStrengthDirection;
445
+ /** @beta */
446
+ function strengthDirectionToString(direction) {
447
+ switch (direction) {
448
+ case StrengthDirection.Forward: return "Forward";
449
+ case StrengthDirection.Backward: return "Backward";
450
+ default: throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrengthDirection, `An invalid StrengthDirection has been provided.`);
451
+ }
452
+ }
453
+ exports.strengthDirectionToString = strengthDirectionToString;
454
454
  //# sourceMappingURL=ECObjects.js.map