@itwin/ecschema-metadata 4.0.0-dev.7 → 4.0.0-dev.70

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 (121) hide show
  1. package/CHANGELOG.md +13 -3
  2. package/lib/cjs/Constants.d.ts +23 -23
  3. package/lib/cjs/Constants.js +33 -33
  4. package/lib/cjs/Constants.js.map +1 -1
  5. package/lib/cjs/Context.d.ts +139 -139
  6. package/lib/cjs/Context.js +204 -204
  7. package/lib/cjs/DelayedPromise.d.ts +88 -88
  8. package/lib/cjs/DelayedPromise.d.ts.map +1 -1
  9. package/lib/cjs/DelayedPromise.js +91 -91
  10. package/lib/cjs/DelayedPromise.js.map +1 -1
  11. package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
  12. package/lib/cjs/Deserialization/AbstractParser.d.ts.map +1 -1
  13. package/lib/cjs/Deserialization/AbstractParser.js +11 -11
  14. package/lib/cjs/Deserialization/Helper.d.ts +251 -251
  15. package/lib/cjs/Deserialization/Helper.js +843 -843
  16. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  17. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  18. package/lib/cjs/Deserialization/JsonProps.d.ts +282 -282
  19. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  20. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  21. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  22. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  23. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  24. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  25. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  26. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  27. package/lib/cjs/ECName.d.ts +30 -30
  28. package/lib/cjs/ECName.js +85 -85
  29. package/lib/cjs/ECObjects.d.ts +162 -162
  30. package/lib/cjs/ECObjects.js +453 -453
  31. package/lib/cjs/Exception.d.ts +43 -43
  32. package/lib/cjs/Exception.js +84 -84
  33. package/lib/cjs/Interfaces.d.ts +66 -66
  34. package/lib/cjs/Interfaces.d.ts.map +1 -1
  35. package/lib/cjs/Interfaces.js +9 -9
  36. package/lib/cjs/Metadata/Class.d.ts +243 -243
  37. package/lib/cjs/Metadata/Class.js +558 -558
  38. package/lib/cjs/Metadata/Class.js.map +1 -1
  39. package/lib/cjs/Metadata/Constant.d.ts +64 -64
  40. package/lib/cjs/Metadata/Constant.js +123 -123
  41. package/lib/cjs/Metadata/Constant.js.map +1 -1
  42. package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
  43. package/lib/cjs/Metadata/CustomAttribute.js +27 -27
  44. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
  45. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  46. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  47. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  48. package/lib/cjs/Metadata/EntityClass.js +230 -230
  49. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  50. package/lib/cjs/Metadata/Enumeration.d.ts.map +1 -1
  51. package/lib/cjs/Metadata/Enumeration.js +159 -159
  52. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  53. package/lib/cjs/Metadata/Format.d.ts +98 -98
  54. package/lib/cjs/Metadata/Format.js +242 -242
  55. package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
  56. package/lib/cjs/Metadata/InvertedUnit.js +97 -97
  57. package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
  58. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  59. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  60. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  61. package/lib/cjs/Metadata/Mixin.js +113 -113
  62. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  63. package/lib/cjs/Metadata/OverrideFormat.d.ts +55 -55
  64. package/lib/cjs/Metadata/OverrideFormat.js +88 -88
  65. package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
  66. package/lib/cjs/Metadata/Phenomenon.js +59 -59
  67. package/lib/cjs/Metadata/Property.d.ts +197 -197
  68. package/lib/cjs/Metadata/Property.d.ts.map +1 -1
  69. package/lib/cjs/Metadata/Property.js +491 -491
  70. package/lib/cjs/Metadata/Property.js.map +1 -1
  71. package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
  72. package/lib/cjs/Metadata/PropertyCategory.js +61 -61
  73. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  74. package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
  75. package/lib/cjs/Metadata/RelationshipClass.js +349 -349
  76. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  77. package/lib/cjs/Metadata/Schema.d.ts +291 -291
  78. package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
  79. package/lib/cjs/Metadata/Schema.js +520 -520
  80. package/lib/cjs/Metadata/Schema.js.map +1 -1
  81. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  82. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  83. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  84. package/lib/cjs/Metadata/Unit.js +162 -162
  85. package/lib/cjs/Metadata/Unit.js.map +1 -1
  86. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  87. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  88. package/lib/cjs/PropertyTypes.d.ts +49 -49
  89. package/lib/cjs/PropertyTypes.js +91 -91
  90. package/lib/cjs/PropertyTypes.js.map +1 -1
  91. package/lib/cjs/SchemaJsonLocater.d.ts +34 -34
  92. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -1
  93. package/lib/cjs/SchemaJsonLocater.js +42 -42
  94. package/lib/cjs/SchemaKey.d.ts +110 -110
  95. package/lib/cjs/SchemaKey.js +219 -219
  96. package/lib/cjs/SchemaLoader.d.ts +23 -23
  97. package/lib/cjs/SchemaLoader.js +47 -47
  98. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  99. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  100. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  101. package/lib/cjs/UnitConversion/Graph.js +83 -83
  102. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  103. package/lib/cjs/UnitConversion/Parser.js +42 -42
  104. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  105. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  106. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  107. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  108. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  109. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  110. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  111. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  112. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +234 -236
  113. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  114. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  115. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  116. package/lib/cjs/ecschema-metadata.d.ts +51 -51
  117. package/lib/cjs/ecschema-metadata.js +100 -96
  118. package/lib/cjs/ecschema-metadata.js.map +1 -1
  119. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  120. package/lib/cjs/utils/SchemaGraph.js +65 -65
  121. package/package.json +11 -11
@@ -1,231 +1,231 @@
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.createNavigationPropertySync = exports.createNavigationProperty = exports.MutableEntityClass = exports.EntityClass = void 0;
11
- const DelayedPromise_1 = require("../DelayedPromise");
12
- const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
13
- const ECObjects_1 = require("../ECObjects");
14
- const Exception_1 = require("../Exception");
15
- const Class_1 = require("./Class");
16
- const Property_1 = require("./Property");
17
- /**
18
- * A Typescript class representation of an ECEntityClass.
19
- * @beta
20
- */
21
- class EntityClass extends Class_1.ECClass {
22
- constructor(schema, name, modifier) {
23
- super(schema, name, modifier);
24
- this.schemaItemType = ECObjects_1.SchemaItemType.EntityClass;
25
- }
26
- get mixins() {
27
- if (!this._mixins)
28
- return [];
29
- return this._mixins;
30
- }
31
- *getMixinsSync() {
32
- if (!this._mixins)
33
- return function* () { }(); // empty iterable
34
- for (const mixin of this._mixins) {
35
- const mObj = this.schema.lookupItemSync(mixin);
36
- if (mObj) {
37
- yield mObj;
38
- }
39
- }
40
- }
41
- /**
42
- *
43
- * @param mixin
44
- */
45
- addMixin(mixin) {
46
- if (!this._mixins)
47
- this._mixins = [];
48
- this._mixins.push(new DelayedPromise_1.DelayedPromiseWithProps(mixin.key, async () => mixin));
49
- return;
50
- }
51
- /**
52
- * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.
53
- * @param name The name of the property to find.
54
- */
55
- async getInheritedProperty(name) {
56
- let inheritedProperty = await super.getInheritedProperty(name);
57
- if (!inheritedProperty && this._mixins) {
58
- const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));
59
- mixinProps.some((prop) => {
60
- inheritedProperty = prop;
61
- return inheritedProperty !== undefined;
62
- });
63
- }
64
- return inheritedProperty;
65
- }
66
- /**
67
- * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.
68
- * @param name The name of the property to find.
69
- */
70
- getInheritedPropertySync(name) {
71
- const inheritedProperty = super.getInheritedPropertySync(name);
72
- if (inheritedProperty)
73
- return inheritedProperty;
74
- if (!this._mixins) {
75
- return undefined;
76
- }
77
- for (const mixin of this._mixins) {
78
- const mObj = this.schema.lookupItemSync(mixin);
79
- if (mObj) {
80
- const result = mObj.getPropertySync(name, true);
81
- if (result) {
82
- return result;
83
- }
84
- }
85
- }
86
- return undefined;
87
- }
88
- async buildPropertyCache(result, existingValues, resetBaseCaches = false) {
89
- if (!existingValues) {
90
- existingValues = new Map();
91
- }
92
- if (this.baseClass) {
93
- Class_1.ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);
94
- }
95
- for (const mixin of this.mixins) {
96
- Class_1.ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);
97
- }
98
- if (!this.properties)
99
- return;
100
- Class_1.ECClass.mergeProperties(result, existingValues, [...this.properties], true);
101
- }
102
- buildPropertyCacheSync(result, existingValues, resetBaseCaches = false) {
103
- if (!existingValues) {
104
- existingValues = new Map();
105
- }
106
- const baseClass = this.getBaseClassSync();
107
- if (baseClass) {
108
- Class_1.ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);
109
- }
110
- for (const mixin of this.getMixinsSync()) {
111
- Class_1.ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);
112
- }
113
- if (!this.properties)
114
- return;
115
- Class_1.ECClass.mergeProperties(result, existingValues, [...this.properties], true);
116
- }
117
- /**
118
- *
119
- * @param name
120
- * @param relationship
121
- * @param direction
122
- */
123
- async createNavigationProperty(name, relationship, direction) {
124
- return this.addProperty(await createNavigationProperty(this, name, relationship, direction));
125
- }
126
- /**
127
- *
128
- * @param name
129
- * @param relationship
130
- * @param direction
131
- */
132
- createNavigationPropertySync(name, relationship, direction) {
133
- return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));
134
- }
135
- /**
136
- * Save this EntityClass' properties to an object for serializing to JSON.
137
- * @param standalone Serialization includes only this object (as opposed to the full schema).
138
- * @param includeSchemaVersion Include the Schema's version information in the serialized object.
139
- */
140
- toJSON(standalone = false, includeSchemaVersion = false) {
141
- const schemaJson = super.toJSON(standalone, includeSchemaVersion);
142
- if (this.mixins.length > 0)
143
- schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);
144
- return schemaJson;
145
- }
146
- /** @internal */
147
- async toXml(schemaXml) {
148
- const itemElement = await super.toXml(schemaXml);
149
- for (const mixin of this.getMixinsSync()) {
150
- const mixinElement = schemaXml.createElement("BaseClass");
151
- const mixinName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);
152
- mixinElement.textContent = mixinName;
153
- itemElement.appendChild(mixinElement);
154
- }
155
- return itemElement;
156
- }
157
- async fromJSON(entityClassProps) {
158
- this.fromJSONSync(entityClassProps);
159
- }
160
- fromJSONSync(entityClassProps) {
161
- super.fromJSONSync(entityClassProps);
162
- if (undefined !== entityClassProps.mixins) {
163
- if (!this._mixins)
164
- this._mixins = [];
165
- for (const name of entityClassProps.mixins) {
166
- const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);
167
- if (!mixinSchemaItemKey)
168
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
169
- this._mixins.push(new DelayedPromise_1.DelayedPromiseWithProps(mixinSchemaItemKey, async () => {
170
- const mixin = await this.schema.lookupItem(mixinSchemaItemKey);
171
- if (undefined === mixin)
172
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
173
- return mixin;
174
- }));
175
- }
176
- }
177
- }
178
- }
179
- exports.EntityClass = EntityClass;
180
- /**
181
- * Hackish approach that works like a "friend class" so we can access protected members without making them public.
182
- * @internal
183
- */
184
- class MutableEntityClass extends EntityClass {
185
- }
186
- exports.MutableEntityClass = MutableEntityClass;
187
- /** @internal */
188
- async function createNavigationProperty(ecClass, name, relationship, direction) {
189
- if (await ecClass.getProperty(name))
190
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
191
- let resolvedRelationship;
192
- if (typeof (relationship) === "string") {
193
- resolvedRelationship = await ecClass.schema.lookupItem(relationship);
194
- }
195
- else
196
- resolvedRelationship = relationship;
197
- if (!resolvedRelationship)
198
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`);
199
- if (typeof (direction) === "string") {
200
- const tmpDirection = (0, ECObjects_1.parseStrengthDirection)(direction);
201
- if (undefined === tmpDirection)
202
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
203
- direction = tmpDirection;
204
- }
205
- const lazyRelationship = new DelayedPromise_1.DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
206
- return new Property_1.NavigationProperty(ecClass, name, lazyRelationship, direction);
207
- }
208
- exports.createNavigationProperty = createNavigationProperty;
209
- /** @internal */
210
- function createNavigationPropertySync(ecClass, name, relationship, direction) {
211
- if (ecClass.getPropertySync(name))
212
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
213
- let resolvedRelationship;
214
- if (typeof (relationship) === "string") {
215
- resolvedRelationship = ecClass.schema.lookupItemSync(relationship);
216
- }
217
- else
218
- resolvedRelationship = relationship;
219
- if (!resolvedRelationship)
220
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`);
221
- if (typeof (direction) === "string") {
222
- const tmpDirection = (0, ECObjects_1.parseStrengthDirection)(direction);
223
- if (undefined === tmpDirection)
224
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
225
- direction = tmpDirection;
226
- }
227
- const lazyRelationship = new DelayedPromise_1.DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
228
- return new Property_1.NavigationProperty(ecClass, name, lazyRelationship, direction);
229
- }
230
- exports.createNavigationPropertySync = createNavigationPropertySync;
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.createNavigationPropertySync = exports.createNavigationProperty = exports.MutableEntityClass = exports.EntityClass = void 0;
11
+ const DelayedPromise_1 = require("../DelayedPromise");
12
+ const XmlSerializationUtils_1 = require("../Deserialization/XmlSerializationUtils");
13
+ const ECObjects_1 = require("../ECObjects");
14
+ const Exception_1 = require("../Exception");
15
+ const Class_1 = require("./Class");
16
+ const Property_1 = require("./Property");
17
+ /**
18
+ * A Typescript class representation of an ECEntityClass.
19
+ * @beta
20
+ */
21
+ class EntityClass extends Class_1.ECClass {
22
+ constructor(schema, name, modifier) {
23
+ super(schema, name, modifier);
24
+ this.schemaItemType = ECObjects_1.SchemaItemType.EntityClass;
25
+ }
26
+ get mixins() {
27
+ if (!this._mixins)
28
+ return [];
29
+ return this._mixins;
30
+ }
31
+ *getMixinsSync() {
32
+ if (!this._mixins)
33
+ return function* () { }(); // empty iterable
34
+ for (const mixin of this._mixins) {
35
+ const mObj = this.schema.lookupItemSync(mixin);
36
+ if (mObj) {
37
+ yield mObj;
38
+ }
39
+ }
40
+ }
41
+ /**
42
+ *
43
+ * @param mixin
44
+ */
45
+ addMixin(mixin) {
46
+ if (!this._mixins)
47
+ this._mixins = [];
48
+ this._mixins.push(new DelayedPromise_1.DelayedPromiseWithProps(mixin.key, async () => mixin));
49
+ return;
50
+ }
51
+ /**
52
+ * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.
53
+ * @param name The name of the property to find.
54
+ */
55
+ async getInheritedProperty(name) {
56
+ let inheritedProperty = await super.getInheritedProperty(name);
57
+ if (!inheritedProperty && this._mixins) {
58
+ const mixinProps = await Promise.all(this._mixins.map(async (mixin) => (await mixin).getProperty(name)));
59
+ mixinProps.some((prop) => {
60
+ inheritedProperty = prop;
61
+ return inheritedProperty !== undefined;
62
+ });
63
+ }
64
+ return inheritedProperty;
65
+ }
66
+ /**
67
+ * Searches the base class, if one exists, first then any mixins that exist for the property with the name provided.
68
+ * @param name The name of the property to find.
69
+ */
70
+ getInheritedPropertySync(name) {
71
+ const inheritedProperty = super.getInheritedPropertySync(name);
72
+ if (inheritedProperty)
73
+ return inheritedProperty;
74
+ if (!this._mixins) {
75
+ return undefined;
76
+ }
77
+ for (const mixin of this._mixins) {
78
+ const mObj = this.schema.lookupItemSync(mixin);
79
+ if (mObj) {
80
+ const result = mObj.getPropertySync(name, true);
81
+ if (result) {
82
+ return result;
83
+ }
84
+ }
85
+ }
86
+ return undefined;
87
+ }
88
+ async buildPropertyCache(result, existingValues, resetBaseCaches = false) {
89
+ if (!existingValues) {
90
+ existingValues = new Map();
91
+ }
92
+ if (this.baseClass) {
93
+ Class_1.ECClass.mergeProperties(result, existingValues, await (await this.baseClass).getProperties(resetBaseCaches), false);
94
+ }
95
+ for (const mixin of this.mixins) {
96
+ Class_1.ECClass.mergeProperties(result, existingValues, await (await mixin).getProperties(resetBaseCaches), false);
97
+ }
98
+ if (!this.properties)
99
+ return;
100
+ Class_1.ECClass.mergeProperties(result, existingValues, [...this.properties], true);
101
+ }
102
+ buildPropertyCacheSync(result, existingValues, resetBaseCaches = false) {
103
+ if (!existingValues) {
104
+ existingValues = new Map();
105
+ }
106
+ const baseClass = this.getBaseClassSync();
107
+ if (baseClass) {
108
+ Class_1.ECClass.mergeProperties(result, existingValues, baseClass.getPropertiesSync(resetBaseCaches), false);
109
+ }
110
+ for (const mixin of this.getMixinsSync()) {
111
+ Class_1.ECClass.mergeProperties(result, existingValues, mixin.getPropertiesSync(resetBaseCaches), false);
112
+ }
113
+ if (!this.properties)
114
+ return;
115
+ Class_1.ECClass.mergeProperties(result, existingValues, [...this.properties], true);
116
+ }
117
+ /**
118
+ *
119
+ * @param name
120
+ * @param relationship
121
+ * @param direction
122
+ */
123
+ async createNavigationProperty(name, relationship, direction) {
124
+ return this.addProperty(await createNavigationProperty(this, name, relationship, direction));
125
+ }
126
+ /**
127
+ *
128
+ * @param name
129
+ * @param relationship
130
+ * @param direction
131
+ */
132
+ createNavigationPropertySync(name, relationship, direction) {
133
+ return this.addProperty(createNavigationPropertySync(this, name, relationship, direction));
134
+ }
135
+ /**
136
+ * Save this EntityClass' properties to an object for serializing to JSON.
137
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
138
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
139
+ */
140
+ toJSON(standalone = false, includeSchemaVersion = false) {
141
+ const schemaJson = super.toJSON(standalone, includeSchemaVersion);
142
+ if (this.mixins.length > 0)
143
+ schemaJson.mixins = this.mixins.map((mixin) => mixin.fullName);
144
+ return schemaJson;
145
+ }
146
+ /** @internal */
147
+ async toXml(schemaXml) {
148
+ const itemElement = await super.toXml(schemaXml);
149
+ for (const mixin of this.getMixinsSync()) {
150
+ const mixinElement = schemaXml.createElement("BaseClass");
151
+ const mixinName = XmlSerializationUtils_1.XmlSerializationUtils.createXmlTypedName(this.schema, mixin.schema, mixin.name);
152
+ mixinElement.textContent = mixinName;
153
+ itemElement.appendChild(mixinElement);
154
+ }
155
+ return itemElement;
156
+ }
157
+ async fromJSON(entityClassProps) {
158
+ this.fromJSONSync(entityClassProps);
159
+ }
160
+ fromJSONSync(entityClassProps) {
161
+ super.fromJSONSync(entityClassProps);
162
+ if (undefined !== entityClassProps.mixins) {
163
+ if (!this._mixins)
164
+ this._mixins = [];
165
+ for (const name of entityClassProps.mixins) {
166
+ const mixinSchemaItemKey = this.schema.getSchemaItemKey(name);
167
+ if (!mixinSchemaItemKey)
168
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
169
+ this._mixins.push(new DelayedPromise_1.DelayedPromiseWithProps(mixinSchemaItemKey, async () => {
170
+ const mixin = await this.schema.lookupItem(mixinSchemaItemKey);
171
+ if (undefined === mixin)
172
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The ECEntityClass ${this.name} has a mixin ("${name}") that cannot be found.`);
173
+ return mixin;
174
+ }));
175
+ }
176
+ }
177
+ }
178
+ }
179
+ exports.EntityClass = EntityClass;
180
+ /**
181
+ * Hackish approach that works like a "friend class" so we can access protected members without making them public.
182
+ * @internal
183
+ */
184
+ class MutableEntityClass extends EntityClass {
185
+ }
186
+ exports.MutableEntityClass = MutableEntityClass;
187
+ /** @internal */
188
+ async function createNavigationProperty(ecClass, name, relationship, direction) {
189
+ if (await ecClass.getProperty(name))
190
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
191
+ let resolvedRelationship;
192
+ if (typeof (relationship) === "string") {
193
+ resolvedRelationship = await ecClass.schema.lookupItem(relationship);
194
+ }
195
+ else
196
+ resolvedRelationship = relationship;
197
+ if (!resolvedRelationship)
198
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`);
199
+ if (typeof (direction) === "string") {
200
+ const tmpDirection = (0, ECObjects_1.parseStrengthDirection)(direction);
201
+ if (undefined === tmpDirection)
202
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
203
+ direction = tmpDirection;
204
+ }
205
+ const lazyRelationship = new DelayedPromise_1.DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
206
+ return new Property_1.NavigationProperty(ecClass, name, lazyRelationship, direction);
207
+ }
208
+ exports.createNavigationProperty = createNavigationProperty;
209
+ /** @internal */
210
+ function createNavigationPropertySync(ecClass, name, relationship, direction) {
211
+ if (ecClass.getPropertySync(name))
212
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateProperty, `An ECProperty with the name ${name} already exists in the class ${ecClass.name}.`);
213
+ let resolvedRelationship;
214
+ if (typeof (relationship) === "string") {
215
+ resolvedRelationship = ecClass.schema.lookupItemSync(relationship);
216
+ }
217
+ else
218
+ resolvedRelationship = relationship;
219
+ if (!resolvedRelationship)
220
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidType, `The provided RelationshipClass, ${relationship}, is not a valid RelationshipClassInterface.`);
221
+ if (typeof (direction) === "string") {
222
+ const tmpDirection = (0, ECObjects_1.parseStrengthDirection)(direction);
223
+ if (undefined === tmpDirection)
224
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidStrengthDirection, `The provided StrengthDirection, ${direction}, is not a valid StrengthDirection.`);
225
+ direction = tmpDirection;
226
+ }
227
+ const lazyRelationship = new DelayedPromise_1.DelayedPromiseWithProps(resolvedRelationship.key, async () => resolvedRelationship);
228
+ return new Property_1.NavigationProperty(ecClass, name, lazyRelationship, direction);
229
+ }
230
+ exports.createNavigationPropertySync = createNavigationPropertySync;
231
231
  //# sourceMappingURL=EntityClass.js.map
@@ -1,87 +1,87 @@
1
- /** @packageDocumentation
2
- * @module Metadata
3
- */
4
- import { EnumerationProps } from "../Deserialization/JsonProps";
5
- import { PrimitiveType, SchemaItemType } from "../ECObjects";
6
- import { Schema } from "./Schema";
7
- import { SchemaItem } from "./SchemaItem";
8
- /** @beta */
9
- export interface Enumerator<T> {
10
- readonly name: string;
11
- readonly value: T;
12
- readonly label?: string;
13
- readonly description?: string;
14
- }
15
- /** @beta */
16
- export declare type AnyEnumerator = Enumerator<string | number>;
17
- /**
18
- * A Typescript class representation of an ECEnumeration.
19
- * @beta
20
- */
21
- export declare class Enumeration extends SchemaItem {
22
- readonly schemaItemType: SchemaItemType.Enumeration;
23
- protected _type?: PrimitiveType.Integer | PrimitiveType.String;
24
- protected _isStrict: boolean;
25
- protected _enumerators: AnyEnumerator[];
26
- get enumerators(): AnyEnumerator[];
27
- get type(): PrimitiveType.Integer | PrimitiveType.String | undefined;
28
- get isStrict(): boolean;
29
- constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String);
30
- get isInt(): boolean;
31
- get isString(): boolean;
32
- /**
33
- * Gets an enumerator that matches the name provided.
34
- * @param name The ECName of the Enumerator to find.
35
- */
36
- getEnumeratorByName(name: string): AnyEnumerator | undefined;
37
- /**
38
- * Gets an enumerator that matches the value provided.
39
- * @param value The value of the Enumerator to find.
40
- */
41
- getEnumerator(value: string): Enumerator<string> | undefined;
42
- getEnumerator(value: number): Enumerator<number> | undefined;
43
- /**
44
- * Checks whether there already exists an enumerator with this name or this value
45
- * @param name The name of the enumerator we are trying to create
46
- * @param value The value of the enumerator we are trying to create
47
- * @internal
48
- */
49
- private findDuplicateEnumerators;
50
- /**
51
- * Creates an Enumerator with the provided name and value as well as optional parameters label and description
52
- * @param name The name of the enumerator
53
- * @param value The value of the enumerator. The type of this value is dependent on the backing type of the this Enumeration.
54
- * @param label A localized display label that is used instead of the name in a GUI.
55
- * @param description A localized description for the enumerator.
56
- * @return AnyEnumerator object
57
- */
58
- createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator;
59
- /**
60
- * Adds enumerator to list of enumerators on this Enumeration
61
- * @param enumerator The enumerator to add
62
- */
63
- protected addEnumerator(enumerator: AnyEnumerator): void;
64
- /**
65
- * Save this Enumeration's properties to an object for serializing to JSON.
66
- * @param standalone Serialization includes only this object (as opposed to the full schema).
67
- * @param includeSchemaVersion Include the Schema's version information in the serialized object.
68
- */
69
- toJSON(standalone?: boolean, includeSchemaVersion?: boolean): EnumerationProps;
70
- /** @internal */
71
- toXml(schemaXml: Document): Promise<Element>;
72
- fromJSONSync(enumerationProps: EnumerationProps): void;
73
- fromJSON(enumerationProps: EnumerationProps): Promise<void>;
74
- /**
75
- * @alpha Used in schema editing.
76
- */
77
- protected setIsStrict(isStrict: boolean): void;
78
- }
79
- /** @internal
80
- * An abstract class used for schema editing.
81
- */
82
- export declare abstract class MutableEnumeration extends Enumeration {
83
- abstract addEnumerator(enumerator: AnyEnumerator): void;
84
- abstract setIsStrict(isStrict: boolean): void;
85
- abstract setDisplayLabel(displayLabel: string): void;
86
- }
1
+ /** @packageDocumentation
2
+ * @module Metadata
3
+ */
4
+ import { EnumerationProps } from "../Deserialization/JsonProps";
5
+ import { PrimitiveType, SchemaItemType } from "../ECObjects";
6
+ import { Schema } from "./Schema";
7
+ import { SchemaItem } from "./SchemaItem";
8
+ /** @beta */
9
+ export interface Enumerator<T> {
10
+ readonly name: string;
11
+ readonly value: T;
12
+ readonly label?: string;
13
+ readonly description?: string;
14
+ }
15
+ /** @beta */
16
+ export type AnyEnumerator = Enumerator<string | number>;
17
+ /**
18
+ * A Typescript class representation of an ECEnumeration.
19
+ * @beta
20
+ */
21
+ export declare class Enumeration extends SchemaItem {
22
+ readonly schemaItemType: SchemaItemType.Enumeration;
23
+ protected _type?: PrimitiveType.Integer | PrimitiveType.String;
24
+ protected _isStrict: boolean;
25
+ protected _enumerators: AnyEnumerator[];
26
+ get enumerators(): AnyEnumerator[];
27
+ get type(): PrimitiveType.Integer | PrimitiveType.String | undefined;
28
+ get isStrict(): boolean;
29
+ constructor(schema: Schema, name: string, primitiveType?: PrimitiveType.Integer | PrimitiveType.String);
30
+ get isInt(): boolean;
31
+ get isString(): boolean;
32
+ /**
33
+ * Gets an enumerator that matches the name provided.
34
+ * @param name The ECName of the Enumerator to find.
35
+ */
36
+ getEnumeratorByName(name: string): AnyEnumerator | undefined;
37
+ /**
38
+ * Gets an enumerator that matches the value provided.
39
+ * @param value The value of the Enumerator to find.
40
+ */
41
+ getEnumerator(value: string): Enumerator<string> | undefined;
42
+ getEnumerator(value: number): Enumerator<number> | undefined;
43
+ /**
44
+ * Checks whether there already exists an enumerator with this name or this value
45
+ * @param name The name of the enumerator we are trying to create
46
+ * @param value The value of the enumerator we are trying to create
47
+ * @internal
48
+ */
49
+ private findDuplicateEnumerators;
50
+ /**
51
+ * Creates an Enumerator with the provided name and value as well as optional parameters label and description
52
+ * @param name The name of the enumerator
53
+ * @param value The value of the enumerator. The type of this value is dependent on the backing type of the this Enumeration.
54
+ * @param label A localized display label that is used instead of the name in a GUI.
55
+ * @param description A localized description for the enumerator.
56
+ * @return AnyEnumerator object
57
+ */
58
+ createEnumerator(name: string, value: string | number, label?: string, description?: string): AnyEnumerator;
59
+ /**
60
+ * Adds enumerator to list of enumerators on this Enumeration
61
+ * @param enumerator The enumerator to add
62
+ */
63
+ protected addEnumerator(enumerator: AnyEnumerator): void;
64
+ /**
65
+ * Save this Enumeration's properties to an object for serializing to JSON.
66
+ * @param standalone Serialization includes only this object (as opposed to the full schema).
67
+ * @param includeSchemaVersion Include the Schema's version information in the serialized object.
68
+ */
69
+ toJSON(standalone?: boolean, includeSchemaVersion?: boolean): EnumerationProps;
70
+ /** @internal */
71
+ toXml(schemaXml: Document): Promise<Element>;
72
+ fromJSONSync(enumerationProps: EnumerationProps): void;
73
+ fromJSON(enumerationProps: EnumerationProps): Promise<void>;
74
+ /**
75
+ * @alpha Used in schema editing.
76
+ */
77
+ protected setIsStrict(isStrict: boolean): void;
78
+ }
79
+ /** @internal
80
+ * An abstract class used for schema editing.
81
+ */
82
+ export declare abstract class MutableEnumeration extends Enumeration {
83
+ abstract addEnumerator(enumerator: AnyEnumerator): void;
84
+ abstract setIsStrict(isStrict: boolean): void;
85
+ abstract setDisplayLabel(displayLabel: string): void;
86
+ }
87
87
  //# sourceMappingURL=Enumeration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Enumeration.d.ts","sourceRoot":"","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