@itwin/ecschema-editing 3.4.0-dev.44 → 3.4.0-dev.47

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 (146) hide show
  1. package/lib/cjs/Editing/Constants.d.ts +20 -20
  2. package/lib/cjs/Editing/Constants.js +64 -64
  3. package/lib/cjs/Editing/Constants.js.map +1 -1
  4. package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
  5. package/lib/cjs/Editing/CustomAttributes.js +62 -62
  6. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  7. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  8. package/lib/cjs/Editing/ECClasses.js +269 -269
  9. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  10. package/lib/cjs/Editing/Editor.d.ts +112 -112
  11. package/lib/cjs/Editing/Editor.js +166 -166
  12. package/lib/cjs/Editing/Editor.js.map +1 -1
  13. package/lib/cjs/Editing/Entities.d.ts +25 -25
  14. package/lib/cjs/Editing/Entities.js +124 -124
  15. package/lib/cjs/Editing/Entities.js.map +1 -1
  16. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  17. package/lib/cjs/Editing/Enumerations.js +76 -76
  18. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  19. package/lib/cjs/Editing/Formats.d.ts +21 -21
  20. package/lib/cjs/Editing/Formats.js +63 -63
  21. package/lib/cjs/Editing/Formats.js.map +1 -1
  22. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  23. package/lib/cjs/Editing/InvertedUnits.js +85 -85
  24. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  25. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  26. package/lib/cjs/Editing/KindOfQuantities.js +79 -79
  27. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  28. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  29. package/lib/cjs/Editing/Mixins.js +88 -88
  30. package/lib/cjs/Editing/Mixins.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  32. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  33. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  35. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  36. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  38. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  39. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  41. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  42. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  44. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  45. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  46. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  47. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  48. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  50. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  51. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  52. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  53. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  54. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  56. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  57. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  58. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  59. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  60. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  61. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  62. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  63. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  64. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  65. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  66. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  67. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  68. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  69. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  70. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  71. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  72. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  73. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  74. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  75. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  76. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  77. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  78. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  79. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  80. package/lib/cjs/Editing/Phenomena.js +47 -47
  81. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  82. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  83. package/lib/cjs/Editing/PropertyCategories.js +53 -53
  84. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  85. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  86. package/lib/cjs/Editing/RelationshipClasses.js +69 -69
  87. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  88. package/lib/cjs/Editing/Structs.d.ts +19 -19
  89. package/lib/cjs/Editing/Structs.js +60 -60
  90. package/lib/cjs/Editing/Structs.js.map +1 -1
  91. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  92. package/lib/cjs/Editing/UnitSystems.js +43 -43
  93. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  94. package/lib/cjs/Editing/Units.d.ts +15 -15
  95. package/lib/cjs/Editing/Units.js +61 -61
  96. package/lib/cjs/Editing/Units.js.map +1 -1
  97. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  98. package/lib/cjs/Validation/Diagnostic.js +310 -310
  99. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  100. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  101. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  102. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  103. package/lib/cjs/Validation/ECRules.d.ts +438 -438
  104. package/lib/cjs/Validation/ECRules.js +583 -583
  105. package/lib/cjs/Validation/ECRules.js.map +1 -1
  106. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  107. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  108. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  109. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +58 -58
  110. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  111. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  112. package/lib/cjs/Validation/Rules.d.ts +64 -64
  113. package/lib/cjs/Validation/Rules.js +9 -9
  114. package/lib/cjs/Validation/Rules.js.map +1 -1
  115. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  116. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  117. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  118. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  119. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  120. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  121. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  122. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  123. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  124. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  125. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  126. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  127. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  128. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  129. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  130. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  131. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  132. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  133. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  134. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  135. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  136. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  137. package/lib/cjs/Validation/SchemaValidationVisitor.js +490 -490
  138. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  139. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  140. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  141. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  142. package/lib/cjs/ecschema-editing.d.ts +33 -33
  143. package/lib/cjs/ecschema-editing.js +54 -54
  144. package/lib/cjs/ecschema-editing.js.map +1 -1
  145. package/package.json +10 -10
  146. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1,270 +1,270 @@
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 Editing
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ECClasses = void 0;
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- const core_bentley_1 = require("@itwin/core-bentley");
13
- const Rules = require("../Validation/ECRules");
14
- /**
15
- * @alpha
16
- * Acts as a base class for schema class creation. Enables property creation.
17
- */
18
- class ECClasses {
19
- constructor(_schemaEditor) {
20
- this._schemaEditor = _schemaEditor;
21
- }
22
- /**
23
- * Creates a property on class identified by the given SchemaItemKey. This method restricts the
24
- * property type to primitives of type Double, String, DateTime and Integer.
25
- * @param classKey The SchemaItemKey of the class.
26
- * @param name The name of the new property.
27
- * @param type The PrimitiveType assigned to the new property.
28
- */
29
- async createProperty(classKey, name, type, prefix) {
30
- let mutableClass;
31
- if (type !== ecschema_metadata_1.PrimitiveType.Double && type !== ecschema_metadata_1.PrimitiveType.String && type !== ecschema_metadata_1.PrimitiveType.DateTime
32
- && type !== ecschema_metadata_1.PrimitiveType.Integer)
33
- throw new Error("Property creation is restricted to type Double, String, DateTime, and Integer.");
34
- if ("" === prefix)
35
- throw new Error("The specified property name prefix is invalid");
36
- const prefixedName = `${prefix}_${name}`;
37
- try {
38
- mutableClass = await this.getClass(classKey);
39
- }
40
- catch (e) {
41
- return { errorMessage: e.message };
42
- }
43
- await mutableClass.createPrimitiveProperty(prefixedName, type);
44
- return { itemKey: classKey, propertyName: prefixedName };
45
- }
46
- /**
47
- * Create a primitive property on class identified by the given SchemaItemKey.
48
- * @param classKey The SchemaItemKey of the class.
49
- * @param name The name of the new property.
50
- * @param type The PrimitiveType assigned to the new property.
51
- */
52
- async createPrimitiveProperty(classKey, name, type) {
53
- let mutableClass;
54
- try {
55
- mutableClass = await this.getClass(classKey);
56
- }
57
- catch (e) {
58
- return { errorMessage: e.message };
59
- }
60
- await mutableClass.createPrimitiveProperty(name, type);
61
- return { itemKey: classKey, propertyName: name };
62
- }
63
- async createPrimitivePropertyFromProps(classKey, name, type, primitiveProps) {
64
- let mutableClass;
65
- try {
66
- mutableClass = await this.getClass(classKey);
67
- }
68
- catch (e) {
69
- return { errorMessage: e.message };
70
- }
71
- const newProperty = await mutableClass.createPrimitiveProperty(name, type);
72
- await newProperty.fromJSON(primitiveProps);
73
- return { itemKey: classKey, propertyName: name };
74
- }
75
- async createEnumerationProperty(classKey, name, type) {
76
- let mutableClass;
77
- try {
78
- mutableClass = await this.getClass(classKey);
79
- }
80
- catch (e) {
81
- return { errorMessage: e.message };
82
- }
83
- const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);
84
- if (enumSchemaItemKey === undefined)
85
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);
86
- await mutableClass.createPrimitiveProperty(name, type);
87
- return { itemKey: classKey, propertyName: name };
88
- }
89
- async createEnumerationPropertyFromProps(classKey, name, type, enumProps) {
90
- let mutableClass;
91
- try {
92
- mutableClass = await this.getClass(classKey);
93
- }
94
- catch (e) {
95
- return { errorMessage: e.message };
96
- }
97
- const newProperty = await mutableClass.createPrimitiveProperty(name, type);
98
- await newProperty.fromJSON(enumProps);
99
- return { itemKey: classKey, propertyName: name };
100
- }
101
- async createPrimitiveArrayProperty(classKey, name, type) {
102
- let mutableClass;
103
- try {
104
- mutableClass = await this.getClass(classKey);
105
- }
106
- catch (e) {
107
- return { errorMessage: e.message };
108
- }
109
- await mutableClass.createPrimitiveArrayProperty(name, type);
110
- return { itemKey: classKey, propertyName: name };
111
- }
112
- async createPrimitiveArrayPropertyFromProps(classKey, name, type, primitiveProps) {
113
- let mutableClass;
114
- try {
115
- mutableClass = await this.getClass(classKey);
116
- }
117
- catch (e) {
118
- return { errorMessage: e.message };
119
- }
120
- const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);
121
- await newProperty.fromJSON(primitiveProps);
122
- return { itemKey: classKey, propertyName: name };
123
- }
124
- async createStructProperty(classKey, name, type) {
125
- let mutableClass;
126
- try {
127
- mutableClass = await this.getClass(classKey);
128
- }
129
- catch (e) {
130
- return { errorMessage: e.message };
131
- }
132
- await mutableClass.createStructProperty(name, type);
133
- return { itemKey: classKey, propertyName: name };
134
- }
135
- async createStructPropertyFromProps(classKey, name, type, structProps) {
136
- let mutableClass;
137
- try {
138
- mutableClass = await this.getClass(classKey);
139
- }
140
- catch (e) {
141
- return { errorMessage: e.message };
142
- }
143
- const newProperty = await mutableClass.createStructProperty(name, type);
144
- await newProperty.fromJSON(structProps);
145
- return { itemKey: classKey, propertyName: name };
146
- }
147
- async createStructArrayProperty(classKey, name, type) {
148
- let mutableClass;
149
- try {
150
- mutableClass = await this.getClass(classKey);
151
- }
152
- catch (e) {
153
- return { errorMessage: e.message };
154
- }
155
- await mutableClass.createStructArrayProperty(name, type);
156
- return { itemKey: classKey, propertyName: name };
157
- }
158
- async createStructArrayPropertyFromProps(classKey, name, type, structProps) {
159
- let mutableClass;
160
- try {
161
- mutableClass = await this.getClass(classKey);
162
- }
163
- catch (e) {
164
- return { errorMessage: e.message };
165
- }
166
- const newProperty = await mutableClass.createStructArrayProperty(name, type);
167
- await newProperty.fromJSON(structProps);
168
- return { itemKey: classKey, propertyName: name };
169
- }
170
- async deleteProperty(classKey, name) {
171
- let mutableClass;
172
- try {
173
- mutableClass = await this.getClass(classKey);
174
- }
175
- catch (e) {
176
- return { errorMessage: e.message };
177
- }
178
- await mutableClass.deleteProperty(name);
179
- return { itemKey: classKey, propertyName: name };
180
- }
181
- async delete(classKey) {
182
- const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
183
- if (schema === undefined)
184
- return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };
185
- const ecClass = await schema.getItem(classKey.name);
186
- if (ecClass === undefined)
187
- return {};
188
- await schema.deleteClass(ecClass.name);
189
- return { itemKey: classKey };
190
- }
191
- /**
192
- * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey
193
- * @param classKey The SchemaItemKey identifying the schema.
194
- * @param customAttribute The CustomAttribute instance to add.
195
- */
196
- async addCustomAttribute(classKey, customAttribute) {
197
- let mutableClass;
198
- try {
199
- mutableClass = await this.getClass(classKey);
200
- }
201
- catch (e) {
202
- return { errorMessage: e.message };
203
- }
204
- mutableClass.addCustomAttribute(customAttribute);
205
- const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);
206
- const result = { errorMessage: "" };
207
- for await (const diagnostic of diagnostics) {
208
- result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
209
- }
210
- if (result.errorMessage) {
211
- this.removeCustomAttribute(mutableClass, customAttribute);
212
- return result;
213
- }
214
- return {};
215
- }
216
- /**
217
- * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.
218
- * @param classKey The SchemaItemKey identifying the class.
219
- * @param propertyName The name of the property.
220
- * @param customAttribute The CustomAttribute instance to add.
221
- */
222
- async addCustomAttributeToProperty(classKey, propertyName, customAttribute) {
223
- let mutableClass;
224
- try {
225
- mutableClass = await this.getClass(classKey);
226
- }
227
- catch (e) {
228
- return { errorMessage: e.message };
229
- }
230
- const property = await mutableClass.getProperty(propertyName);
231
- if (!property) {
232
- return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };
233
- }
234
- property.addCustomAttribute(customAttribute);
235
- const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);
236
- const result = { errorMessage: "" };
237
- for await (const diagnostic of diagnostics) {
238
- result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
239
- }
240
- if (result.errorMessage) {
241
- this.removeCustomAttribute(property, customAttribute);
242
- return result;
243
- }
244
- return {};
245
- }
246
- async getClass(classKey) {
247
- const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
248
- const ecClass = await schema.getItem(classKey.name);
249
- if (ecClass === undefined)
250
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);
251
- switch (ecClass.schemaItemType) {
252
- case ecschema_metadata_1.SchemaItemType.EntityClass:
253
- case ecschema_metadata_1.SchemaItemType.Mixin:
254
- case ecschema_metadata_1.SchemaItemType.StructClass:
255
- case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
256
- case ecschema_metadata_1.SchemaItemType.RelationshipClass:
257
- break;
258
- default:
259
- throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);
260
- }
261
- return ecClass;
262
- }
263
- removeCustomAttribute(container, customAttribute) {
264
- (0, core_bentley_1.assert)(container.customAttributes !== undefined);
265
- const map = container.customAttributes;
266
- map.delete(customAttribute.className);
267
- }
268
- }
269
- exports.ECClasses = ECClasses;
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 Editing
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ECClasses = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const core_bentley_1 = require("@itwin/core-bentley");
13
+ const Rules = require("../Validation/ECRules");
14
+ /**
15
+ * @alpha
16
+ * Acts as a base class for schema class creation. Enables property creation.
17
+ */
18
+ class ECClasses {
19
+ constructor(_schemaEditor) {
20
+ this._schemaEditor = _schemaEditor;
21
+ }
22
+ /**
23
+ * Creates a property on class identified by the given SchemaItemKey. This method restricts the
24
+ * property type to primitives of type Double, String, DateTime and Integer.
25
+ * @param classKey The SchemaItemKey of the class.
26
+ * @param name The name of the new property.
27
+ * @param type The PrimitiveType assigned to the new property.
28
+ */
29
+ async createProperty(classKey, name, type, prefix) {
30
+ let mutableClass;
31
+ if (type !== ecschema_metadata_1.PrimitiveType.Double && type !== ecschema_metadata_1.PrimitiveType.String && type !== ecschema_metadata_1.PrimitiveType.DateTime
32
+ && type !== ecschema_metadata_1.PrimitiveType.Integer)
33
+ throw new Error("Property creation is restricted to type Double, String, DateTime, and Integer.");
34
+ if ("" === prefix)
35
+ throw new Error("The specified property name prefix is invalid");
36
+ const prefixedName = `${prefix}_${name}`;
37
+ try {
38
+ mutableClass = await this.getClass(classKey);
39
+ }
40
+ catch (e) {
41
+ return { errorMessage: e.message };
42
+ }
43
+ await mutableClass.createPrimitiveProperty(prefixedName, type);
44
+ return { itemKey: classKey, propertyName: prefixedName };
45
+ }
46
+ /**
47
+ * Create a primitive property on class identified by the given SchemaItemKey.
48
+ * @param classKey The SchemaItemKey of the class.
49
+ * @param name The name of the new property.
50
+ * @param type The PrimitiveType assigned to the new property.
51
+ */
52
+ async createPrimitiveProperty(classKey, name, type) {
53
+ let mutableClass;
54
+ try {
55
+ mutableClass = await this.getClass(classKey);
56
+ }
57
+ catch (e) {
58
+ return { errorMessage: e.message };
59
+ }
60
+ await mutableClass.createPrimitiveProperty(name, type);
61
+ return { itemKey: classKey, propertyName: name };
62
+ }
63
+ async createPrimitivePropertyFromProps(classKey, name, type, primitiveProps) {
64
+ let mutableClass;
65
+ try {
66
+ mutableClass = await this.getClass(classKey);
67
+ }
68
+ catch (e) {
69
+ return { errorMessage: e.message };
70
+ }
71
+ const newProperty = await mutableClass.createPrimitiveProperty(name, type);
72
+ await newProperty.fromJSON(primitiveProps);
73
+ return { itemKey: classKey, propertyName: name };
74
+ }
75
+ async createEnumerationProperty(classKey, name, type) {
76
+ let mutableClass;
77
+ try {
78
+ mutableClass = await this.getClass(classKey);
79
+ }
80
+ catch (e) {
81
+ return { errorMessage: e.message };
82
+ }
83
+ const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);
84
+ if (enumSchemaItemKey === undefined)
85
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);
86
+ await mutableClass.createPrimitiveProperty(name, type);
87
+ return { itemKey: classKey, propertyName: name };
88
+ }
89
+ async createEnumerationPropertyFromProps(classKey, name, type, enumProps) {
90
+ let mutableClass;
91
+ try {
92
+ mutableClass = await this.getClass(classKey);
93
+ }
94
+ catch (e) {
95
+ return { errorMessage: e.message };
96
+ }
97
+ const newProperty = await mutableClass.createPrimitiveProperty(name, type);
98
+ await newProperty.fromJSON(enumProps);
99
+ return { itemKey: classKey, propertyName: name };
100
+ }
101
+ async createPrimitiveArrayProperty(classKey, name, type) {
102
+ let mutableClass;
103
+ try {
104
+ mutableClass = await this.getClass(classKey);
105
+ }
106
+ catch (e) {
107
+ return { errorMessage: e.message };
108
+ }
109
+ await mutableClass.createPrimitiveArrayProperty(name, type);
110
+ return { itemKey: classKey, propertyName: name };
111
+ }
112
+ async createPrimitiveArrayPropertyFromProps(classKey, name, type, primitiveProps) {
113
+ let mutableClass;
114
+ try {
115
+ mutableClass = await this.getClass(classKey);
116
+ }
117
+ catch (e) {
118
+ return { errorMessage: e.message };
119
+ }
120
+ const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);
121
+ await newProperty.fromJSON(primitiveProps);
122
+ return { itemKey: classKey, propertyName: name };
123
+ }
124
+ async createStructProperty(classKey, name, type) {
125
+ let mutableClass;
126
+ try {
127
+ mutableClass = await this.getClass(classKey);
128
+ }
129
+ catch (e) {
130
+ return { errorMessage: e.message };
131
+ }
132
+ await mutableClass.createStructProperty(name, type);
133
+ return { itemKey: classKey, propertyName: name };
134
+ }
135
+ async createStructPropertyFromProps(classKey, name, type, structProps) {
136
+ let mutableClass;
137
+ try {
138
+ mutableClass = await this.getClass(classKey);
139
+ }
140
+ catch (e) {
141
+ return { errorMessage: e.message };
142
+ }
143
+ const newProperty = await mutableClass.createStructProperty(name, type);
144
+ await newProperty.fromJSON(structProps);
145
+ return { itemKey: classKey, propertyName: name };
146
+ }
147
+ async createStructArrayProperty(classKey, name, type) {
148
+ let mutableClass;
149
+ try {
150
+ mutableClass = await this.getClass(classKey);
151
+ }
152
+ catch (e) {
153
+ return { errorMessage: e.message };
154
+ }
155
+ await mutableClass.createStructArrayProperty(name, type);
156
+ return { itemKey: classKey, propertyName: name };
157
+ }
158
+ async createStructArrayPropertyFromProps(classKey, name, type, structProps) {
159
+ let mutableClass;
160
+ try {
161
+ mutableClass = await this.getClass(classKey);
162
+ }
163
+ catch (e) {
164
+ return { errorMessage: e.message };
165
+ }
166
+ const newProperty = await mutableClass.createStructArrayProperty(name, type);
167
+ await newProperty.fromJSON(structProps);
168
+ return { itemKey: classKey, propertyName: name };
169
+ }
170
+ async deleteProperty(classKey, name) {
171
+ let mutableClass;
172
+ try {
173
+ mutableClass = await this.getClass(classKey);
174
+ }
175
+ catch (e) {
176
+ return { errorMessage: e.message };
177
+ }
178
+ await mutableClass.deleteProperty(name);
179
+ return { itemKey: classKey, propertyName: name };
180
+ }
181
+ async delete(classKey) {
182
+ const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
183
+ if (schema === undefined)
184
+ return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };
185
+ const ecClass = await schema.getItem(classKey.name);
186
+ if (ecClass === undefined)
187
+ return {};
188
+ await schema.deleteClass(ecClass.name);
189
+ return { itemKey: classKey };
190
+ }
191
+ /**
192
+ * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey
193
+ * @param classKey The SchemaItemKey identifying the schema.
194
+ * @param customAttribute The CustomAttribute instance to add.
195
+ */
196
+ async addCustomAttribute(classKey, customAttribute) {
197
+ let mutableClass;
198
+ try {
199
+ mutableClass = await this.getClass(classKey);
200
+ }
201
+ catch (e) {
202
+ return { errorMessage: e.message };
203
+ }
204
+ mutableClass.addCustomAttribute(customAttribute);
205
+ const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);
206
+ const result = { errorMessage: "" };
207
+ for await (const diagnostic of diagnostics) {
208
+ result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
209
+ }
210
+ if (result.errorMessage) {
211
+ this.removeCustomAttribute(mutableClass, customAttribute);
212
+ return result;
213
+ }
214
+ return {};
215
+ }
216
+ /**
217
+ * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.
218
+ * @param classKey The SchemaItemKey identifying the class.
219
+ * @param propertyName The name of the property.
220
+ * @param customAttribute The CustomAttribute instance to add.
221
+ */
222
+ async addCustomAttributeToProperty(classKey, propertyName, customAttribute) {
223
+ let mutableClass;
224
+ try {
225
+ mutableClass = await this.getClass(classKey);
226
+ }
227
+ catch (e) {
228
+ return { errorMessage: e.message };
229
+ }
230
+ const property = await mutableClass.getProperty(propertyName);
231
+ if (!property) {
232
+ return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };
233
+ }
234
+ property.addCustomAttribute(customAttribute);
235
+ const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);
236
+ const result = { errorMessage: "" };
237
+ for await (const diagnostic of diagnostics) {
238
+ result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
239
+ }
240
+ if (result.errorMessage) {
241
+ this.removeCustomAttribute(property, customAttribute);
242
+ return result;
243
+ }
244
+ return {};
245
+ }
246
+ async getClass(classKey) {
247
+ const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
248
+ const ecClass = await schema.getItem(classKey.name);
249
+ if (ecClass === undefined)
250
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);
251
+ switch (ecClass.schemaItemType) {
252
+ case ecschema_metadata_1.SchemaItemType.EntityClass:
253
+ case ecschema_metadata_1.SchemaItemType.Mixin:
254
+ case ecschema_metadata_1.SchemaItemType.StructClass:
255
+ case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
256
+ case ecschema_metadata_1.SchemaItemType.RelationshipClass:
257
+ break;
258
+ default:
259
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);
260
+ }
261
+ return ecClass;
262
+ }
263
+ removeCustomAttribute(container, customAttribute) {
264
+ (0, core_bentley_1.assert)(container.customAttributes !== undefined);
265
+ const map = container.customAttributes;
266
+ map.delete(customAttribute.className);
267
+ }
268
+ }
269
+ exports.ECClasses = ECClasses;
270
270
  //# sourceMappingURL=ECClasses.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAMkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,SAAS;IAEpB,YAAgC,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAEvE;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,QAAuB,EAAE,IAAY,EAAE,IAAmB,EAAE,MAAc;QACpG,IAAI,YAA0B,CAAC;QAE/B,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,IAAI,IAAI,KAAK,iCAAa,CAAC,QAAQ;eAChG,IAAI,KAAK,iCAAa,CAAC,OAAO;YACjC,MAAM,IAAI,KAAK,CAAE,gFAAgF,CAAC,CAAC;QAErG,IAAI,EAAE,KAAK,MAAM;YACf,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAEnE,MAAM,YAAY,GAAG,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;QAEzC,IAAI;YACF,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC9C;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IAEO,qBAAqB,CAAC,SAAwC,EAAE,eAAgC;QACtG,IAAA,qBAAM,EAAC,SAAS,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgD,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AA1RD,8BA0RC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n ECClass, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses {\n\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n return { itemKey: classKey, propertyName: prefixedName };\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined) throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n return { itemKey: classKey, propertyName: name };\n }\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.deleteProperty(name);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n return {};\n\n await schema.deleteClass(ecClass.name);\n\n return { itemKey: classKey };\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\n * @param classKey The SchemaItemKey identifying the class.\n * @param propertyName The name of the property.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\n if (!property) {\n return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n property.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(property, customAttribute);\n return result;\n }\n\n return {};\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\n if (ecClass === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\n\n switch (ecClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n case SchemaItemType.CustomAttributeClass:\n case SchemaItemType.RelationshipClass:\n break;\n default:\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\n }\n\n return ecClass;\n }\n\n private removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete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tD,OAAO,MAAM,CAAC;SACf;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,QAAuB;QAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAe,QAAQ,CAAC,IAAI,CAAC,CAAC;QAClE,IAAI,OAAO,KAAK,SAAS;YACvB,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,SAAS,QAAQ,CAAC,IAAI,4BAA4B,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEjJ,QAAQ,OAAO,CAAC,cAAc,EAAE;YAC9B,KAAK,kCAAc,CAAC,WAAW,CAAC;YAChC,KAAK,kCAAc,CAAC,KAAK,CAAC;YAC1B,KAAK,kCAAc,CAAC,WAAW,CAAC;YAChC,KAAK,kCAAc,CAAC,oBAAoB,CAAC;YACzC,KAAK,kCAAc,CAAC,iBAAiB;gBACnC,MAAM;YACR;gBACE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,qBAAqB,EAAE,gCAAgC,CAAC,CAAC;SACrG;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,qBAAqB,CAAC,SAAwC,EAAE,eAAgC;QACtG,IAAA,qBAAM,EAAC,SAAS,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgD,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AA1RD,8BA0RC","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 {\r\n CustomAttribute,\r\n CustomAttributeContainerProps,\r\n ECClass, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\r\n PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\r\n StructClass, StructPropertyProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\n\r\n/**\r\n * @alpha\r\n * Acts as a base class for schema class creation. Enables property creation.\r\n */\r\nexport class ECClasses {\r\n\r\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n /**\r\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\r\n * property type to primitives of type Double, String, DateTime and Integer.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The name of the new property.\r\n * @param type The PrimitiveType assigned to the new property.\r\n */\r\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n\r\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\r\n && type !== PrimitiveType.Integer)\r\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\r\n\r\n if (\"\" === prefix)\r\n throw new Error(\"The specified property name prefix is invalid\");\r\n\r\n const prefixedName = `${prefix}_${name}`;\r\n\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveProperty(prefixedName, type);\r\n return { itemKey: classKey, propertyName: prefixedName };\r\n }\r\n\r\n /**\r\n * Create a primitive property on class identified by the given SchemaItemKey.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The name of the new property.\r\n * @param type The PrimitiveType assigned to the new property.\r\n */\r\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\r\n if (enumSchemaItemKey === undefined) throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(enumProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createStructProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createStructProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createStructArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.deleteProperty(name);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\r\n\r\n const ecClass = await schema.getItem<ECClass>(classKey.name);\r\n if (ecClass === undefined)\r\n return {};\r\n\r\n await schema.deleteClass(ecClass.name);\r\n\r\n return { itemKey: classKey };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\r\n * @param classKey The SchemaItemKey identifying the schema.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n mutableClass.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\r\n\r\n const result: SchemaItemEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(mutableClass, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\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 addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\r\n if (!property) {\r\n return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\r\n }\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n const result: SchemaItemEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(property, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\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 const ecClass = await schema.getItem<MutableClass>(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 switch (ecClass.schemaItemType) {\r\n case SchemaItemType.EntityClass:\r\n case SchemaItemType.Mixin:\r\n case SchemaItemType.StructClass:\r\n case SchemaItemType.CustomAttributeClass:\r\n case SchemaItemType.RelationshipClass:\r\n break;\r\n default:\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\r\n }\r\n\r\n return ecClass;\r\n }\r\n\r\n private 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"]}