@itwin/ecschema-editing 4.7.0-dev.9 → 4.7.0

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 (131) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/lib/cjs/Editing/Constants.d.ts +6 -6
  3. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  4. package/lib/cjs/Editing/Constants.js +26 -31
  5. package/lib/cjs/Editing/Constants.js.map +1 -1
  6. package/lib/cjs/Editing/CustomAttributes.d.ts +3 -3
  7. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  8. package/lib/cjs/Editing/CustomAttributes.js +18 -28
  9. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  10. package/lib/cjs/Editing/ECClasses.d.ts +24 -23
  11. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  12. package/lib/cjs/Editing/ECClasses.js +126 -156
  13. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  14. package/lib/cjs/Editing/Editor.d.ts +10 -31
  15. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  16. package/lib/cjs/Editing/Editor.js +59 -43
  17. package/lib/cjs/Editing/Editor.js.map +1 -1
  18. package/lib/cjs/Editing/Entities.d.ts +9 -9
  19. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  20. package/lib/cjs/Editing/Entities.js +65 -85
  21. package/lib/cjs/Editing/Entities.js.map +1 -1
  22. package/lib/cjs/Editing/Enumerations.d.ts +6 -6
  23. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  24. package/lib/cjs/Editing/Enumerations.js +57 -55
  25. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  26. package/lib/cjs/Editing/Exception.d.ts +257 -0
  27. package/lib/cjs/Editing/Exception.d.ts.map +1 -0
  28. package/lib/cjs/Editing/Exception.js +426 -0
  29. package/lib/cjs/Editing/Exception.js.map +1 -0
  30. package/lib/cjs/Editing/Formats.d.ts +6 -6
  31. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  32. package/lib/cjs/Editing/Formats.js +28 -33
  33. package/lib/cjs/Editing/Formats.js.map +1 -1
  34. package/lib/cjs/Editing/InvertedUnits.d.ts +6 -6
  35. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  36. package/lib/cjs/Editing/InvertedUnits.js +41 -56
  37. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  38. package/lib/cjs/Editing/KindOfQuantities.d.ts +6 -6
  39. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  40. package/lib/cjs/Editing/KindOfQuantities.js +50 -57
  41. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  42. package/lib/cjs/Editing/Mixins.d.ts +5 -5
  43. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  44. package/lib/cjs/Editing/Mixins.js +43 -58
  45. package/lib/cjs/Editing/Mixins.js.map +1 -1
  46. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +1 -5
  47. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts.map +1 -1
  48. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +1 -45
  49. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  50. package/lib/cjs/Editing/Phenomena.d.ts +7 -7
  51. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  52. package/lib/cjs/Editing/Phenomena.js +23 -23
  53. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  54. package/lib/cjs/Editing/Properties.d.ts +7 -6
  55. package/lib/cjs/Editing/Properties.d.ts.map +1 -1
  56. package/lib/cjs/Editing/Properties.js +99 -46
  57. package/lib/cjs/Editing/Properties.js.map +1 -1
  58. package/lib/cjs/Editing/PropertyCategories.d.ts +6 -6
  59. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  60. package/lib/cjs/Editing/PropertyCategories.js +29 -27
  61. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  62. package/lib/cjs/Editing/RelationshipClasses.d.ts +15 -17
  63. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  64. package/lib/cjs/Editing/RelationshipClasses.js +97 -101
  65. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  66. package/lib/cjs/Editing/SchemaItems.d.ts +13 -5
  67. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
  68. package/lib/cjs/Editing/SchemaItems.js +58 -6
  69. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  70. package/lib/cjs/Editing/Structs.d.ts +3 -3
  71. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  72. package/lib/cjs/Editing/Structs.js +17 -27
  73. package/lib/cjs/Editing/Structs.js.map +1 -1
  74. package/lib/cjs/Editing/UnitSystems.d.ts +7 -7
  75. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  76. package/lib/cjs/Editing/UnitSystems.js +22 -20
  77. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  78. package/lib/cjs/Editing/Units.d.ts +6 -6
  79. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  80. package/lib/cjs/Editing/Units.js +26 -35
  81. package/lib/cjs/Editing/Units.js.map +1 -1
  82. package/lib/cjs/Merging/CAClassMerger.js +2 -2
  83. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  84. package/lib/cjs/Merging/ClassMerger.d.ts +1 -2
  85. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  86. package/lib/cjs/Merging/ClassMerger.js +15 -39
  87. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  88. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  89. package/lib/cjs/Merging/ConstantMerger.js +2 -3
  90. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  91. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +4 -5
  92. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  93. package/lib/cjs/Merging/CustomAttributeMerger.js +8 -18
  94. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  95. package/lib/cjs/Merging/EntityClassMerger.d.ts +1 -2
  96. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  97. package/lib/cjs/Merging/EntityClassMerger.js +3 -10
  98. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  99. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  100. package/lib/cjs/Merging/EnumerationMerger.js +8 -10
  101. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  102. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  103. package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -3
  104. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  105. package/lib/cjs/Merging/MixinMerger.js +2 -2
  106. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  107. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
  108. package/lib/cjs/Merging/PhenomenonMerger.js +1 -2
  109. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  110. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
  111. package/lib/cjs/Merging/PropertyCategoryMerger.js +1 -2
  112. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  113. package/lib/cjs/Merging/PropertyMerger.d.ts +2 -3
  114. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  115. package/lib/cjs/Merging/PropertyMerger.js +21 -42
  116. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  117. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +5 -3
  118. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  119. package/lib/cjs/Merging/RelationshipClassMerger.js +35 -33
  120. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  121. package/lib/cjs/Merging/SchemaItemMerger.d.ts +3 -4
  122. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  123. package/lib/cjs/Merging/SchemaItemMerger.js +3 -2
  124. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  125. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  126. package/lib/cjs/Merging/SchemaMerger.js +2 -8
  127. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  128. package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
  129. package/lib/cjs/Merging/UnitSystemMerger.js +1 -2
  130. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  131. package/package.json +9 -9
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StructProperties = exports.NavigationProperties = exports.EnumerationProperties = exports.PrimitiveProperties = exports.ArrayProperties = exports.Properties = void 0;
4
4
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
5
+ const core_bentley_1 = require("@itwin/core-bentley");
5
6
  const Rules = require("../Validation/ECRules");
7
+ const Exception_1 = require("./Exception");
6
8
  /**
7
9
  * @alpha
8
10
  * A class allowing editing of attributes of the base Property class.
@@ -13,17 +15,28 @@ class Properties {
13
15
  this._schemaEditor = _schemaEditor;
14
16
  }
15
17
  async setName(classKey, propertyName, newPropertyName) {
16
- const newName = new ecschema_metadata_1.ECName(newPropertyName);
17
- const existingProperty = await this.getProperty(classKey, propertyName);
18
+ let newName;
19
+ try {
20
+ newName = new ecschema_metadata_1.ECName(newPropertyName);
21
+ }
22
+ catch (e) {
23
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPropertyName, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidECName, new Exception_1.PropertyId(this.ecClassType, classKey, newPropertyName)));
24
+ }
25
+ const existingProperty = await this.getProperty(classKey, propertyName)
26
+ .catch((e) => {
27
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPropertyName, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
28
+ });
18
29
  const baseProperty = await existingProperty.class.getProperty(newPropertyName, true);
19
- if (baseProperty)
20
- throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.`);
30
+ if (baseProperty) {
31
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPropertyName, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.PropertyAlreadyExists, new Exception_1.PropertyId(this.ecClassType, baseProperty.class.key, newPropertyName)));
32
+ }
21
33
  // Handle derived classes
22
34
  const derivedProperties = [];
23
35
  const derivedClasses = await this.findDerivedClasses(existingProperty.class);
24
36
  for (const derivedClass of derivedClasses) {
25
- if (await derivedClass.getProperty(newPropertyName))
26
- throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.`);
37
+ if (await derivedClass.getProperty(newPropertyName)) {
38
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPropertyName, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.PropertyAlreadyExists, new Exception_1.PropertyId(this.ecClassType, derivedClass.key, newPropertyName)));
39
+ }
27
40
  const propertyOverride = await derivedClass.getProperty(propertyName);
28
41
  // If found the property is overridden in the derived class.
29
42
  if (propertyOverride)
@@ -42,7 +55,10 @@ class Properties {
42
55
  * @param description The new description to set.
43
56
  */
44
57
  async setDescription(classKey, propertyName, description) {
45
- const property = await this.getProperty(classKey, propertyName);
58
+ const property = await this.getProperty(classKey, propertyName)
59
+ .catch((e) => {
60
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetDescription, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
61
+ });
46
62
  property.setDescription(description);
47
63
  }
48
64
  /**
@@ -52,7 +68,10 @@ class Properties {
52
68
  * @param label The new label to set.
53
69
  */
54
70
  async setLabel(classKey, propertyName, label) {
55
- const property = await this.getProperty(classKey, propertyName);
71
+ const property = await this.getProperty(classKey, propertyName)
72
+ .catch((e) => {
73
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetLabel, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
74
+ });
56
75
  property.setLabel(label);
57
76
  }
58
77
  /**
@@ -62,7 +81,10 @@ class Properties {
62
81
  * @param isReadOnly The new isReadOnly value.
63
82
  */
64
83
  async setIsReadOnly(classKey, propertyName, isReadOnly) {
65
- const property = await this.getProperty(classKey, propertyName);
84
+ const property = await this.getProperty(classKey, propertyName)
85
+ .catch((e) => {
86
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetIsReadOnly, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
87
+ });
66
88
  property.setIsReadOnly(isReadOnly);
67
89
  }
68
90
  /**
@@ -72,7 +94,10 @@ class Properties {
72
94
  * @param priority The new priority.
73
95
  */
74
96
  async setPriority(classKey, propertyName, priority) {
75
- const property = await this.getProperty(classKey, propertyName);
97
+ const property = await this.getProperty(classKey, propertyName)
98
+ .catch((e) => {
99
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPriority, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
100
+ });
76
101
  property.setPriority(priority);
77
102
  }
78
103
  /**
@@ -82,10 +107,13 @@ class Properties {
82
107
  * @param categoryKey The SchemaItemKey of the property category.
83
108
  */
84
109
  async setCategory(classKey, propertyName, categoryKey) {
85
- const property = await this.getProperty(classKey, propertyName);
110
+ const property = await this.getProperty(classKey, propertyName)
111
+ .catch((e) => {
112
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetCategory, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
113
+ });
86
114
  const category = await property.class.schema.lookupItem(categoryKey);
87
115
  if (category === undefined) {
88
- return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${property.class.schema.fullName}.` };
116
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetCategory, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNotFound, new Exception_1.SchemaItemId(ecschema_metadata_1.SchemaItemType.PropertyCategory, categoryKey)));
89
117
  }
90
118
  property.setCategory(new ecschema_metadata_1.DelayedPromiseWithProps(categoryKey, async () => category));
91
119
  return { itemKey: classKey, propertyName };
@@ -97,18 +125,31 @@ class Properties {
97
125
  * @param customAttribute The CustomAttribute instance to add.
98
126
  */
99
127
  async addCustomAttribute(classKey, propertyName, customAttribute) {
100
- const property = await this.getProperty(classKey, propertyName);
128
+ const property = await this.getProperty(classKey, propertyName)
129
+ .catch((e) => {
130
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddCustomAttributeToProperty, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
131
+ });
101
132
  property.addCustomAttribute(customAttribute);
102
- const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);
103
- // TODO: Update error
104
- const error = new Error();
105
- for await (const diagnostic of diagnostics) {
106
- error.message += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
133
+ const diagnosticsIterable = Rules.validateCustomAttributeInstance(property, customAttribute);
134
+ const diagnostics = [];
135
+ for await (const diagnostic of diagnosticsIterable) {
136
+ diagnostics.push(diagnostic);
107
137
  }
108
- if (error.message) {
109
- throw error;
138
+ if (diagnostics.length > 0) {
139
+ this.removeCustomAttribute(property, customAttribute);
140
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.AddCustomAttributeToProperty, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.RuleViolation, new Exception_1.CustomAttributeId(customAttribute.className, property)));
110
141
  }
111
142
  }
143
+ /**
144
+ * Removes a CustomAttribute from a property.
145
+ * @param container
146
+ * @param customAttribute
147
+ */
148
+ removeCustomAttribute(container, customAttribute) {
149
+ (0, core_bentley_1.assert)(container.customAttributes !== undefined);
150
+ const map = container.customAttributes;
151
+ map.delete(customAttribute.className);
152
+ }
112
153
  /**
113
154
  * Gets the property with the specified name from the class identified by the given key.
114
155
  * @param classKey The SchemaItemKey of the class.
@@ -116,13 +157,9 @@ class Properties {
116
157
  */
117
158
  async getProperty(classKey, propertyName) {
118
159
  const mutableClass = await this.getClass(classKey);
119
- if (mutableClass.schemaItemType !== this.ecClassType) {
120
- throw new Error(`The class ${classKey.fullName} is not an ${ecschema_metadata_1.SchemaItemType[this.ecClassType]}.`);
121
- }
122
160
  const property = await mutableClass.getProperty(propertyName);
123
161
  if (property === undefined) {
124
- // TODO: Update error
125
- throw new Error(`An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.`);
162
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.PropertyNotFound, new Exception_1.PropertyId(mutableClass.schemaItemType, classKey, propertyName));
126
163
  }
127
164
  return property;
128
165
  }
@@ -140,12 +177,12 @@ class Properties {
140
177
  async getClass(classKey) {
141
178
  const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
142
179
  if (schema === undefined)
143
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Schema Key ${classKey.schemaKey.toString(true)} not found in context`);
180
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaNotFound, new Exception_1.SchemaId(classKey.schemaKey));
144
181
  const ecClass = await schema.getItem(classKey.name);
145
182
  if (ecClass === undefined)
146
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);
147
- if (!(ecClass instanceof ecschema_metadata_1.ECClass)) {
148
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);
183
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNotFound, new Exception_1.ClassId(this.ecClassType, classKey));
184
+ if (ecClass.schemaItemType !== this.ecClassType) {
185
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidSchemaItemType, new Exception_1.ClassId(this.ecClassType, classKey));
149
186
  }
150
187
  return ecClass;
151
188
  }
@@ -167,7 +204,10 @@ class ArrayProperties extends Properties {
167
204
  * @param minOccurs The new minOccurs value.
168
205
  */
169
206
  async setMinOccurs(classKey, propertyName, minOccurs) {
170
- const property = await this.getProperty(classKey, propertyName);
207
+ const property = await this.getProperty(classKey, propertyName)
208
+ .catch((e) => {
209
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetMinOccurs, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
210
+ });
171
211
  property.setMinOccurs(minOccurs);
172
212
  }
173
213
  /**
@@ -177,7 +217,10 @@ class ArrayProperties extends Properties {
177
217
  * @param maxOccurs The new maxOccurs value.
178
218
  */
179
219
  async setMaxOccurs(classKey, propertyName, maxOccurs) {
180
- const property = await this.getProperty(classKey, propertyName);
220
+ const property = await this.getProperty(classKey, propertyName)
221
+ .catch((e) => {
222
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetMaxOccurs, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
223
+ });
181
224
  property.setMaxOccurs(maxOccurs);
182
225
  }
183
226
  /**
@@ -188,8 +231,7 @@ class ArrayProperties extends Properties {
188
231
  async getProperty(classKey, propertyName) {
189
232
  const property = await super.getProperty(classKey, propertyName);
190
233
  if (!property.isArray()) {
191
- // TODO: Update error
192
- throw new Error(`The property ${propertyName} is not an ArrayProperty.`);
234
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidPropertyType, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName, Exception_1.PropertyTypeName.ArrayProperty));
193
235
  }
194
236
  return property;
195
237
  }
@@ -210,7 +252,10 @@ class PrimitiveOrEnumProperties extends Properties {
210
252
  * @param extendTypeName The extended type name of the property.
211
253
  */
212
254
  async setExtendedTypeName(classKey, propertyName, extendedTypeName) {
213
- const property = await this.getProperty(classKey, propertyName);
255
+ const property = await this.getProperty(classKey, propertyName)
256
+ .catch((e) => {
257
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetExtendedTypeName, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
258
+ });
214
259
  property.setExtendedTypeName(extendedTypeName);
215
260
  }
216
261
  /**
@@ -220,7 +265,10 @@ class PrimitiveOrEnumProperties extends Properties {
220
265
  * @param minLength The minimum length of the property.
221
266
  */
222
267
  async setMinLength(classKey, propertyName, minLength) {
223
- const property = await this.getProperty(classKey, propertyName);
268
+ const property = await this.getProperty(classKey, propertyName)
269
+ .catch((e) => {
270
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetMinLength, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
271
+ });
224
272
  property.setMinLength(minLength);
225
273
  }
226
274
  /**
@@ -230,7 +278,10 @@ class PrimitiveOrEnumProperties extends Properties {
230
278
  * @param maxLength The maximum length of the property.
231
279
  */
232
280
  async setMaxLength(classKey, propertyName, maxLength) {
233
- const property = await this.getProperty(classKey, propertyName);
281
+ const property = await this.getProperty(classKey, propertyName)
282
+ .catch((e) => {
283
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetMaxLength, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
284
+ });
234
285
  property.setMaxLength(maxLength);
235
286
  }
236
287
  /**
@@ -240,7 +291,10 @@ class PrimitiveOrEnumProperties extends Properties {
240
291
  * @param minValue The minimum value of the property.
241
292
  */
242
293
  async setMinValue(classKey, propertyName, minValue) {
243
- const property = await this.getProperty(classKey, propertyName);
294
+ const property = await this.getProperty(classKey, propertyName)
295
+ .catch((e) => {
296
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetMinValue, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
297
+ });
244
298
  property.setMinValue(minValue);
245
299
  }
246
300
  /**
@@ -250,7 +304,10 @@ class PrimitiveOrEnumProperties extends Properties {
250
304
  * @param maxValue The maximum value of the property.
251
305
  */
252
306
  async setMaxValue(classKey, propertyName, maxValue) {
253
- const property = await this.getProperty(classKey, propertyName);
307
+ const property = await this.getProperty(classKey, propertyName)
308
+ .catch((e) => {
309
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetMaxValue, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName), e);
310
+ });
254
311
  property.setMaxValue(maxValue);
255
312
  }
256
313
  }
@@ -270,8 +327,7 @@ class PrimitiveProperties extends PrimitiveOrEnumProperties {
270
327
  async getProperty(classKey, propertyName) {
271
328
  const property = await super.getProperty(classKey, propertyName);
272
329
  if (!(property instanceof ecschema_metadata_1.PrimitiveProperty)) {
273
- // TODO: Update error
274
- throw new Error(`The property ${propertyName} is not an PrimitiveProperty.`);
330
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidPropertyType, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName, Exception_1.PropertyTypeName.PrimitiveProperty));
275
331
  }
276
332
  return property;
277
333
  }
@@ -293,8 +349,7 @@ class EnumerationProperties extends PrimitiveOrEnumProperties {
293
349
  async getProperty(classKey, propertyName) {
294
350
  const property = await super.getProperty(classKey, propertyName);
295
351
  if (!(property instanceof ecschema_metadata_1.EnumerationProperty)) {
296
- // TODO: Update error
297
- throw new Error(`The property ${propertyName} is not an EnumerationProperty.`);
352
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidPropertyType, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName, Exception_1.PropertyTypeName.EnumerationProperty));
298
353
  }
299
354
  return property;
300
355
  }
@@ -316,8 +371,7 @@ class NavigationProperties extends Properties {
316
371
  async getProperty(classKey, propertyName) {
317
372
  const property = await super.getProperty(classKey, propertyName);
318
373
  if (!(property instanceof ecschema_metadata_1.NavigationProperty)) {
319
- // TODO: Update error
320
- throw new Error(`The property ${propertyName} is not a NavigationProperty.`);
374
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidPropertyType, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName, Exception_1.PropertyTypeName.NavigationProperty));
321
375
  }
322
376
  return property;
323
377
  }
@@ -339,8 +393,7 @@ class StructProperties extends Properties {
339
393
  async getProperty(classKey, propertyName) {
340
394
  const property = await super.getProperty(classKey, propertyName);
341
395
  if (!(property instanceof ecschema_metadata_1.StructProperty)) {
342
- // TODO: Update error
343
- throw new Error(`The property ${propertyName} is not a StructProperty.`);
396
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidPropertyType, new Exception_1.PropertyId(this.ecClassType, classKey, propertyName, Exception_1.PropertyTypeName.StructProperty));
344
397
  }
345
398
  return property;
346
399
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":";;;AAAA,gEAEoG;AAEpG,+CAA+C;AAW/C;;;GAGG;AACH,MAAa,UAAU;IACrB,YAA6B,WAA+B,EAAY,aAAkC;QAA7E,gBAAW,GAAX,WAAW,CAAoB;QAAY,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAExG,KAAK,CAAC,OAAO,CAAC,QAAuB,EAAE,YAAoB,EAAE,eAAuB;QACzF,MAAM,OAAO,GAAG,IAAI,0BAAM,CAAC,eAAe,CAAC,CAAC;QAE5C,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAkB,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEzF,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,IAAI,CAAoB,CAAC;QACxG,IAAI,YAAY;YACd,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,gCAAgC,YAAY,CAAC,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;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,UAAU;IAC9C,YAAmB,WAA+B,EAAE,aAAkC;QACpF,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACgB,KAAK,CAAC,WAAW,CAAgC,QAAuB,EAAE,YAAoB;QAC/G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,CAAwB,QAAQ,EAAE,YAAY,CAAM,CAAC;QAC7F,IAAI,CAAC,CAAC,QAAQ,YAAY,kCAAc,CAAC,EAAC,CAAC;YACzC,qBAAqB;YACrB,MAAM,IAAI,KAAK,CAAC,gBAAgB,YAAY,2BAA2B,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAlBD,4CAkBC","sourcesContent":["import { CustomAttribute, DelayedPromiseWithProps, ECClass, ECName, ECObjectsError,\r\n ECObjectsStatus, EnumerationProperty, NavigationProperty, PrimitiveProperty,\r\n PropertyCategory, SchemaItemKey, SchemaItemType, StructProperty } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableArrayProperty } from \"./Mutable/MutableArrayProperty\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"./Mutable/MutablePrimitiveOrEnumProperty\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport { MutableStructProperty } from \"./Mutable/MutableStructProperty\";\r\nimport { MutableNavigationProperty } from \"./Mutable/MutableNavigationProperty\";\r\nimport { ECClassSchemaItems } from \"./ECClasses\";\r\n\r\ntype MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;\r\n\r\n/**\r\n * @alpha\r\n * A class allowing editing of attributes of the base Property class.\r\n */\r\nexport class Properties {\r\n public constructor(protected ecClassType: ECClassSchemaItems, protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n public async setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string) {\r\n const newName = new ECName(newPropertyName);\r\n\r\n const existingProperty = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n const baseProperty = await existingProperty.class.getProperty(newPropertyName, true) as MutableProperty;\r\n if (baseProperty)\r\n throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.`);\r\n\r\n // Handle derived classes\r\n const derivedProperties: Array<MutableProperty> = [];\r\n const derivedClasses = await this.findDerivedClasses(existingProperty.class as MutableClass);\r\n for (const derivedClass of derivedClasses) {\r\n if (await derivedClass.getProperty(newPropertyName))\r\n throw new Error(`An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.`);\r\n\r\n const propertyOverride = await derivedClass.getProperty(propertyName) as MutableProperty;\r\n // If found the property is overridden in the derived class.\r\n if (propertyOverride)\r\n derivedProperties.push(propertyOverride);\r\n }\r\n\r\n // Re-name the overridden property in all derived classes\r\n derivedProperties.forEach((prop: MutableProperty) => {\r\n prop.setName(newName);\r\n });\r\n\r\n existingProperty.setName(newName);\r\n }\r\n\r\n /**\r\n * Sets the property description.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(classKey: SchemaItemKey, propertyName: string, description: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the property label.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param label The new label to set.\r\n */\r\n public async setLabel(classKey: SchemaItemKey, propertyName: string, label: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setLabel(label);\r\n }\r\n\r\n /**\r\n * Sets the property isReadOnly attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param isReadOnly The new isReadOnly value.\r\n */\r\n public async setIsReadOnly(classKey: SchemaItemKey, propertyName: string, isReadOnly: boolean) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setIsReadOnly(isReadOnly);\r\n }\r\n\r\n /**\r\n * Sets the property priority.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param priority The new priority.\r\n */\r\n public async setPriority(classKey: SchemaItemKey, propertyName: string, priority: number) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n property.setPriority(priority);\r\n }\r\n\r\n /**\r\n * Sets the property category.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param categoryKey The SchemaItemKey of the property category.\r\n */\r\n public async setCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n const category = await property.class.schema.lookupItem<PropertyCategory>(categoryKey);\r\n if (category === undefined) {\r\n return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${property.class.schema.fullName}.` };\r\n }\r\n\r\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\r\n return { itemKey: classKey, propertyName };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param propertyName The name of the property.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName);\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n // TODO: Update error\r\n const error = new Error();\r\n for await (const diagnostic of diagnostics) {\r\n error.message += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (error.message) {\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the property with the specified name from the class identified by the given key.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property to retrieve.\r\n */\r\n protected async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const mutableClass = await this.getClass(classKey);\r\n\r\n if (mutableClass.schemaItemType !== this.ecClassType){\r\n throw new Error(`The class ${classKey.fullName} is not an ${SchemaItemType[this.ecClassType]}.`);\r\n }\r\n\r\n const property = await mutableClass.getProperty(propertyName) as T;\r\n if (property === undefined) {\r\n // TODO: Update error\r\n throw new Error(`An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.`);\r\n }\r\n\r\n return property;\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n\r\n for await (const schemaItem of this._schemaEditor.schemaContext.getSchemaItems()) {\r\n if(ECClass.isECClass(schemaItem) && await schemaItem.is(mutableClass)) {\r\n if (!mutableClass.key.matches(schemaItem.key)) {\r\n derivedClasses.push(schemaItem as MutableClass);\r\n }\r\n }\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\r\n\r\n const ecClass = await schema.getItem(classKey.name);\r\n if (ecClass === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\r\n\r\n if (!(ecClass instanceof ECClass)) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\r\n }\r\n\r\n return ecClass as MutableClass;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveArrayProperty,\r\n * EnumerationArrayProperty and StructArrayProperty.\r\n */\r\nexport class ArrayProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the array property minOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minOccurs The new minOccurs value.\r\n */\r\n public async setMinOccurs(classKey: SchemaItemKey, propertyName: string, minOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName);\r\n property.setMinOccurs(minOccurs);\r\n }\r\n\r\n /**\r\n * Sets the array property maxOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxOccurs The new maxOccurs value.\r\n */\r\n public async setMaxOccurs(classKey: SchemaItemKey, propertyName: string, maxOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName);\r\n property.setMaxOccurs(maxOccurs);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is an ArrayProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableArrayProperty>(classKey, propertyName) as T;\r\n if (!property.isArray()){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an ArrayProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.\r\n */\r\nclass PrimitiveOrEnumProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the extendTypeName attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param extendTypeName The extended type name of the property.\r\n */\r\n public async setExtendedTypeName(classKey: SchemaItemKey, propertyName: string, extendedTypeName: string) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setExtendedTypeName(extendedTypeName);\r\n }\r\n\r\n /**\r\n * Sets the minLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minLength The minimum length of the property.\r\n */\r\n public async setMinLength(classKey: SchemaItemKey, propertyName: string, minLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMinLength(minLength);\r\n }\r\n\r\n /**\r\n * Sets the maxLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxLength The maximum length of the property.\r\n */\r\n public async setMaxLength(classKey: SchemaItemKey, propertyName: string, maxLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMaxLength(maxLength);\r\n }\r\n\r\n /**\r\n * Sets the minValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minValue The minimum value of the property.\r\n */\r\n public async setMinValue(classKey: SchemaItemKey, propertyName: string, minValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMinValue(minValue);\r\n }\r\n\r\n /**\r\n * Sets the maxValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxValue The maximum value of the property.\r\n */\r\n public async setMaxValue(classKey: SchemaItemKey, propertyName: string, maxValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName);\r\n property.setMaxValue(maxValue);\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of PrimitiveProperty attributes.\r\n */\r\nexport class PrimitiveProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a PrimitiveProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof PrimitiveProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an PrimitiveProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of EnumerationProperty attributes.\r\n */\r\nexport class EnumerationProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a EnumerationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof EnumerationProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not an EnumerationProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of NavigationProperties attributes.\r\n */\r\nexport class NavigationProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a NavigationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableNavigationProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof NavigationProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not a NavigationProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of StructProperty attributes.\r\n */\r\nexport class StructProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a StructProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableStructProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof StructProperty)){\r\n // TODO: Update error\r\n throw new Error(`The property ${propertyName} is not a StructProperty.`);\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../src/Editing/Properties.ts"],"names":[],"mappings":";;;AAAA,gEAEoG;AACpG,sDAA6C;AAE7C,+CAA+C;AAQ/C,2CAAoJ;AAKpJ;;;GAGG;AACH,MAAa,UAAU;IACrB,YAA6B,WAA+B,EAAY,aAAkC;QAA7E,gBAAW,GAAX,WAAW,CAAoB;QAAY,kBAAa,GAAb,aAAa,CAAqB;IAC1G,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAuB,EAAE,YAAoB,EAAE,eAAuB;QACzF,IAAI,OAAe,CAAC;QACpB,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,0BAAM,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAA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B;QAC/G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,CAAwB,QAAQ,EAAE,YAAY,CAAM,CAAC;QAC7F,IAAI,CAAC,CAAC,QAAQ,YAAY,kCAAc,CAAC,EAAC,CAAC;YACzC,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,mBAAmB,EAAE,IAAI,sBAAU,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,4BAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC/J,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAjBD,4CAiBC","sourcesContent":["import { CustomAttribute, CustomAttributeContainerProps, DelayedPromiseWithProps, ECClass, ECName,\r\n EnumerationProperty, NavigationProperty, PrimitiveProperty,\r\n PropertyCategory, SchemaItemKey, SchemaItemType, StructProperty } from \"@itwin/ecschema-metadata\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableArrayProperty } from \"./Mutable/MutableArrayProperty\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"./Mutable/MutablePrimitiveOrEnumProperty\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport { MutableStructProperty } from \"./Mutable/MutableStructProperty\";\r\nimport { MutableNavigationProperty } from \"./Mutable/MutableNavigationProperty\";\r\nimport { ECClassSchemaItems } from \"./ECClasses\";\r\nimport { ClassId, CustomAttributeId, ECEditingStatus, PropertyId, PropertyTypeName, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\r\nimport { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\n\r\ntype MutablePropertyType = MutableProperty | MutableArrayProperty | MutablePrimitiveOrEnumPropertyBase | MutableNavigationProperty | MutableStructProperty;\r\n\r\n/**\r\n * @alpha\r\n * A class allowing editing of attributes of the base Property class.\r\n */\r\nexport class Properties {\r\n public constructor(protected ecClassType: ECClassSchemaItems, protected _schemaEditor: SchemaContextEditor) {\r\n }\r\n\r\n public async setName(classKey: SchemaItemKey, propertyName: string, newPropertyName: string) {\r\n let newName: ECName;\r\n try {\r\n newName = new ECName(newPropertyName);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.InvalidECName, new PropertyId(this.ecClassType, classKey, newPropertyName)));\r\n }\r\n\r\n const existingProperty = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n const baseProperty = await existingProperty.class.getProperty(newPropertyName, true) as MutableProperty;\r\n if (baseProperty) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, baseProperty.class.key, newPropertyName)));\r\n }\r\n\r\n // Handle derived classes\r\n const derivedProperties: Array<MutableProperty> = [];\r\n const derivedClasses = await this.findDerivedClasses(existingProperty.class as MutableClass);\r\n for (const derivedClass of derivedClasses) {\r\n if (await derivedClass.getProperty(newPropertyName)) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyName, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.PropertyAlreadyExists, new PropertyId(this.ecClassType, derivedClass.key, newPropertyName)));\r\n }\r\n\r\n const propertyOverride = await derivedClass.getProperty(propertyName) as MutableProperty;\r\n // If found the property is overridden in the derived class.\r\n if (propertyOverride)\r\n derivedProperties.push(propertyOverride);\r\n }\r\n\r\n // Re-name the overridden property in all derived classes\r\n derivedProperties.forEach((prop: MutableProperty) => {\r\n prop.setName(newName);\r\n });\r\n\r\n existingProperty.setName(newName);\r\n }\r\n\r\n /**\r\n * Sets the property description.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param description The new description to set.\r\n */\r\n public async setDescription(classKey: SchemaItemKey, propertyName: string, description: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetDescription, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setDescription(description);\r\n }\r\n\r\n /**\r\n * Sets the property label.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param label The new label to set.\r\n */\r\n public async setLabel(classKey: SchemaItemKey, propertyName: string, label: string) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetLabel, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setLabel(label);\r\n }\r\n\r\n /**\r\n * Sets the property isReadOnly attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param isReadOnly The new isReadOnly value.\r\n */\r\n public async setIsReadOnly(classKey: SchemaItemKey, propertyName: string, isReadOnly: boolean) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetIsReadOnly, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setIsReadOnly(isReadOnly);\r\n }\r\n\r\n /**\r\n * Sets the property priority.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param priority The new priority.\r\n */\r\n public async setPriority(classKey: SchemaItemKey, propertyName: string, priority: number) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetPriority, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setPriority(priority);\r\n }\r\n\r\n /**\r\n * Sets the property category.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param categoryKey The SchemaItemKey of the property category.\r\n */\r\n public async setCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetCategory, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n const category = await property.class.schema.lookupItem<PropertyCategory>(categoryKey);\r\n if (category === undefined) {\r\n throw new SchemaEditingError(ECEditingStatus.SetCategory, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(SchemaItemType.PropertyCategory, categoryKey)));\r\n }\r\n\r\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\r\n return { itemKey: classKey, propertyName };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param propertyName The name of the property.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute) {\r\n const property = await this.getProperty<MutableProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToProperty, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnosticsIterable = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n const diagnostics: AnyDiagnostic[] = [];\r\n for await (const diagnostic of diagnosticsIterable) {\r\n diagnostics.push(diagnostic);\r\n }\r\n\r\n if (diagnostics.length > 0) {\r\n this.removeCustomAttribute(property, customAttribute);\r\n throw new SchemaEditingError(ECEditingStatus.AddCustomAttributeToProperty, new PropertyId(this.ecClassType, classKey, propertyName),\r\n new SchemaEditingError(ECEditingStatus.RuleViolation, new CustomAttributeId(customAttribute.className, property)));\r\n }\r\n }\r\n\r\n /**\r\n * Removes a CustomAttribute from a property.\r\n * @param container\r\n * @param customAttribute\r\n */\r\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\r\n assert(container.customAttributes !== undefined);\r\n const map = container.customAttributes as Map<string, CustomAttribute>;\r\n map.delete(customAttribute.className);\r\n }\r\n\r\n /**\r\n * Gets the property with the specified name from the class identified by the given key.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property to retrieve.\r\n */\r\n protected async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const mutableClass = await this.getClass(classKey);\r\n\r\n const property = await mutableClass.getProperty(propertyName) as T;\r\n if (property === undefined) {\r\n throw new SchemaEditingError(ECEditingStatus.PropertyNotFound, new PropertyId(mutableClass.schemaItemType as ECClassSchemaItems, classKey, propertyName));\r\n }\r\n\r\n return property;\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n\r\n for await (const schemaItem of this._schemaEditor.schemaContext.getSchemaItems()) {\r\n if(ECClass.isECClass(schemaItem) && await schemaItem.is(mutableClass)) {\r\n if (!mutableClass.key.matches(schemaItem.key)) {\r\n derivedClasses.push(schemaItem as MutableClass);\r\n }\r\n }\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(classKey.schemaKey));\r\n\r\n const ecClass = await schema.getItem(classKey.name);\r\n if (ecClass === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new ClassId(this.ecClassType, classKey));\r\n\r\n if (ecClass.schemaItemType !== this.ecClassType){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new ClassId(this.ecClassType, classKey));\r\n }\r\n\r\n return ecClass as MutableClass;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveArrayProperty,\r\n * EnumerationArrayProperty and StructArrayProperty.\r\n */\r\nexport class ArrayProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the array property minOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minOccurs The new minOccurs value.\r\n */\r\n public async setMinOccurs(classKey: SchemaItemKey, propertyName: string, minOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMinOccurs, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMinOccurs(minOccurs);\r\n }\r\n\r\n /**\r\n * Sets the array property maxOccurs attribute.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxOccurs The new maxOccurs value.\r\n */\r\n public async setMaxOccurs(classKey: SchemaItemKey, propertyName: string, maxOccurs: number) {\r\n const property = await this.getProperty<MutableArrayProperty>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMaxOccurs, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMaxOccurs(maxOccurs);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is an ArrayProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableArrayProperty>(classKey, propertyName) as T;\r\n if (!property.isArray()){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.ArrayProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of attributes of PrimitiveProperty and EnumerationProperty.\r\n */\r\nclass PrimitiveOrEnumProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Sets the extendTypeName attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param extendTypeName The extended type name of the property.\r\n */\r\n public async setExtendedTypeName(classKey: SchemaItemKey, propertyName: string, extendedTypeName: string) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetExtendedTypeName, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setExtendedTypeName(extendedTypeName);\r\n }\r\n\r\n /**\r\n * Sets the minLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minLength The minimum length of the property.\r\n */\r\n public async setMinLength(classKey: SchemaItemKey, propertyName: string, minLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMinLength, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMinLength(minLength);\r\n }\r\n\r\n /**\r\n * Sets the maxLength attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxLength The maximum length of the property.\r\n */\r\n public async setMaxLength(classKey: SchemaItemKey, propertyName: string, maxLength: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMaxLength, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMaxLength(maxLength);\r\n }\r\n\r\n /**\r\n * Sets the minValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param minValue The minimum value of the property.\r\n */\r\n public async setMinValue(classKey: SchemaItemKey, propertyName: string, minValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMinValue, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMinValue(minValue);\r\n }\r\n\r\n /**\r\n * Sets the maxValue attribute value.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param maxValue The maximum value of the property.\r\n */\r\n public async setMaxValue(classKey: SchemaItemKey, propertyName: string, maxValue: number) {\r\n const property = await this.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName)\r\n .catch((e: any) => {\r\n throw new SchemaEditingError(ECEditingStatus.SetMaxValue, new PropertyId(this.ecClassType, classKey, propertyName), e);\r\n });\r\n property.setMaxValue(maxValue);\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of PrimitiveProperty attributes.\r\n */\r\nexport class PrimitiveProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a PrimitiveProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof PrimitiveProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.PrimitiveProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of EnumerationProperty attributes.\r\n */\r\nexport class EnumerationProperties extends PrimitiveOrEnumProperties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a EnumerationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutablePrimitiveOrEnumPropertyBase>(classKey, propertyName) as T;\r\n if (!(property instanceof EnumerationProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.EnumerationProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of NavigationProperties attributes.\r\n */\r\nexport class NavigationProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a NavigationProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableNavigationProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof NavigationProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.NavigationProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n/**\r\n * @alpha\r\n * A class extending Properties allowing editing of StructProperty attributes.\r\n */\r\nexport class StructProperties extends Properties {\r\n public constructor(ecClassType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor) {\r\n super(ecClassType, _schemaEditor);\r\n }\r\n\r\n /**\r\n * Override to validate that the found property is a StructProperty.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n */\r\n protected override async getProperty<T extends MutablePropertyType>(classKey: SchemaItemKey, propertyName: string): Promise<T> {\r\n const property = await super.getProperty<MutableStructProperty>(classKey, propertyName) as T;\r\n if (!(property instanceof StructProperty)){\r\n throw new SchemaEditingError(ECEditingStatus.InvalidPropertyType, new PropertyId(this.ecClassType, classKey, propertyName, PropertyTypeName.StructProperty));\r\n }\r\n return property;\r\n }\r\n}\r\n\r\n"]}
@@ -2,16 +2,16 @@
2
2
  * @module Editing
3
3
  */
4
4
  import { PropertyCategoryProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
5
- import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
5
+ import { SchemaContextEditor } from "./Editor";
6
+ import { SchemaItems } from "./SchemaItems";
6
7
  /**
7
8
  * @alpha
8
9
  * A class allowing you to create schema items of type Property Category.
9
10
  */
10
- export declare class PropertyCategories {
11
- protected _schemaEditor: SchemaContextEditor;
12
- constructor(_schemaEditor: SchemaContextEditor);
13
- create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemEditResults>;
14
- createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemEditResults>;
11
+ export declare class PropertyCategories extends SchemaItems {
12
+ constructor(schemaEditor: SchemaContextEditor);
13
+ create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemKey>;
14
+ createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemKey>;
15
15
  setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void>;
16
16
  }
17
17
  //# sourceMappingURL=PropertyCategories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategories.d.ts","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAmC,qBAAqB,EAAE,aAAa,EAAkB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC5I,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,kBAAkB;IACV,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAanH,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgBnH,WAAW,CAAC,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAW1F"}
1
+ {"version":3,"file":"PropertyCategories.d.ts","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAoB,qBAAqB,EAAE,aAAa,EAAkB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC7H,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBAC9B,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAa3G,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;IAS3G,WAAW,CAAC,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ1F"}
@@ -9,43 +9,45 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.PropertyCategories = void 0;
11
11
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const Exception_1 = require("./Exception");
13
+ const SchemaItems_1 = require("./SchemaItems");
12
14
  /**
13
15
  * @alpha
14
16
  * A class allowing you to create schema items of type Property Category.
15
17
  */
16
- class PropertyCategories {
17
- constructor(_schemaEditor) {
18
- this._schemaEditor = _schemaEditor;
18
+ class PropertyCategories extends SchemaItems_1.SchemaItems {
19
+ constructor(schemaEditor) {
20
+ super(ecschema_metadata_1.SchemaItemType.PropertyCategory, schemaEditor);
19
21
  }
20
22
  async create(schemaKey, name, priority, displayLabel) {
21
- const schema = await this._schemaEditor.getSchema(schemaKey);
22
- if (schema === undefined)
23
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
24
- const newPropCategory = (await schema.createPropertyCategory(name));
25
- newPropCategory.setPriority(priority);
26
- if (displayLabel)
27
- newPropCategory.setDisplayLabel(displayLabel);
28
- return { itemKey: newPropCategory.key };
23
+ try {
24
+ const newPropCategory = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name);
25
+ newPropCategory.setPriority(priority);
26
+ if (displayLabel)
27
+ newPropCategory.setDisplayLabel(displayLabel);
28
+ return newPropCategory.key;
29
+ }
30
+ catch (e) {
31
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFailed, new Exception_1.SchemaItemId(this.schemaItemType, name, schemaKey), e);
32
+ }
29
33
  }
30
34
  async createFromProps(schemaKey, propertyCategoryProps) {
31
- const schema = await this._schemaEditor.getSchema(schemaKey);
32
- if (schema === undefined)
33
- return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
34
- if (propertyCategoryProps.name === undefined)
35
- return { errorMessage: `No name was supplied within props.` };
36
- const newPropCategory = (await schema.createPropertyCategory(propertyCategoryProps.name));
37
- if (newPropCategory === undefined)
38
- return { errorMessage: `Failed to create class ${propertyCategoryProps.name} in schema ${schemaKey.toString(true)}.` };
39
- await newPropCategory.fromJSON(propertyCategoryProps);
40
- return { itemKey: newPropCategory.key };
35
+ try {
36
+ const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);
37
+ return newPropCategory.key;
38
+ }
39
+ catch (e) {
40
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFromProps, new Exception_1.SchemaItemId(this.schemaItemType, propertyCategoryProps.name, schemaKey), e);
41
+ }
41
42
  }
42
43
  async setPriority(propCategoryKey, priority) {
43
- const propertyCategory = (await this._schemaEditor.schemaContext.getSchemaItem(propCategoryKey));
44
- if (propertyCategory === undefined)
45
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Property Category ${propCategoryKey.fullName} not found in schema context.`);
46
- if (propertyCategory.schemaItemType !== ecschema_metadata_1.SchemaItemType.PropertyCategory)
47
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${propCategoryKey.fullName} to be of type Property Category.`);
48
- propertyCategory.setPriority(priority);
44
+ try {
45
+ const propertyCategory = await this.getSchemaItem(propCategoryKey);
46
+ propertyCategory.setPriority(priority);
47
+ }
48
+ catch (e) {
49
+ throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SetPropertyCategoryPriority, new Exception_1.SchemaItemId(this.schemaItemType, propCategoryKey), e);
50
+ }
49
51
  }
50
52
  }
51
53
  exports.PropertyCategories = PropertyCategories;
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA4I;AAI5I;;;GAGG;AACH,MAAa,kBAAkB;IAC7B,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,eAAe,GAAG,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAA4B,CAAC;QAC/F,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,YAAY;YACd,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEhD,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,qBAA4C;QAC7F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,qBAAqB,CAAC,IAAI,KAAK,SAAS;YAC1C,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,eAAe,GAAG,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAA4B,CAAC;QACrH,IAAI,eAAe,KAAK,SAAS;YAC/B,OAAO,EAAE,YAAY,EAAE,0BAA0B,qBAAqB,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzH,MAAM,eAAe,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,MAAM,gBAAgB,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAA0B,eAAe,CAAC,CAAC,CAAC;QAE1H,IAAI,gBAAgB,KAAK,SAAS;YAChC,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,qBAAqB,eAAe,CAAC,QAAQ,+BAA+B,CAAC,CAAC;QAExI,IAAI,gBAAgB,CAAC,cAAc,KAAK,kCAAc,CAAC,gBAAgB;YACrE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,YAAY,eAAe,CAAC,QAAQ,mCAAmC,CAAC,CAAC;QAE3I,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AA1CD,gDA0CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { ECObjectsError, ECObjectsStatus, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Property Category.\r\n */\r\nexport class PropertyCategories {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n const newPropCategory = (await schema.createPropertyCategory(name)) as MutablePropertyCategory;\r\n newPropCategory.setPriority(priority);\r\n if (displayLabel)\r\n newPropCategory.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newPropCategory.key };\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (propertyCategoryProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newPropCategory = (await schema.createPropertyCategory(propertyCategoryProps.name)) as MutablePropertyCategory;\r\n if (newPropCategory === undefined)\r\n return { errorMessage: `Failed to create class ${propertyCategoryProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newPropCategory.fromJSON(propertyCategoryProps);\r\n return { itemKey: newPropCategory.key };\r\n }\r\n\r\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\r\n const propertyCategory = (await this._schemaEditor.schemaContext.getSchemaItem<MutablePropertyCategory>(propCategoryKey));\r\n\r\n if (propertyCategory === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Property Category ${propCategoryKey.fullName} not found in schema context.`);\r\n\r\n if (propertyCategory.schemaItemType !== SchemaItemType.PropertyCategory)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Expected ${propCategoryKey.fullName} to be of type Property Category.`);\r\n\r\n propertyCategory.setPriority(priority);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PropertyCategories.js","sourceRoot":"","sources":["../../../src/Editing/PropertyCategories.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA6H;AAG7H,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,yBAAW;IACjD,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,QAAgB,EAAE,YAAqB;QAC7F,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAmB,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAA4B,CAAC;YAC/L,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACtC,IAAI,YAAY;gBACd,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEhD,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,qBAA4C;QAC7F,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,CAAC;YAC5K,OAAO,eAAe,CAAC,GAAG,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5J,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,eAA8B,EAAE,QAAgB;QACvE,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,aAAa,CAA0B,eAAe,CAAC,CAAC;YAC5F,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;QAAC,OAAM,CAAM,EAAE,CAAC;YACf,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,2BAA2B,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;IACH,CAAC;CACF;AAnCD,gDAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { PropertyCategory, PropertyCategoryProps, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutablePropertyCategory } from \"./Mutable/MutablePropertyCategory\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Property Category.\r\n */\r\nexport class PropertyCategories extends SchemaItems {\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.PropertyCategory, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, priority: number, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newPropCategory = await this.createSchemaItem<PropertyCategory>(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), name) as MutablePropertyCategory;\r\n newPropCategory.setPriority(priority);\r\n if (displayLabel)\r\n newPropCategory.setDisplayLabel(displayLabel);\r\n\r\n return newPropCategory.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, propertyCategoryProps: PropertyCategoryProps): Promise<SchemaItemKey> {\r\n try {\r\n const newPropCategory = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createPropertyCategory.bind(schema), propertyCategoryProps);\r\n return newPropCategory.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, propertyCategoryProps.name!, schemaKey), e);\r\n }\r\n }\r\n\r\n public async setPriority(propCategoryKey: SchemaItemKey, priority: number): Promise<void> {\r\n try {\r\n const propertyCategory = await this.getSchemaItem<MutablePropertyCategory>(propCategoryKey);\r\n propertyCategory.setPriority(priority);\r\n } catch(e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.SetPropertyCategoryPriority, new SchemaItemId(this.schemaItemType, propCategoryKey), e);\r\n }\r\n }\r\n}\r\n"]}