@itwin/ecschema-editing 4.8.0-dev.3 → 4.8.0-dev.4
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.
- package/lib/cjs/Editing/Enumerations.js +4 -4
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts +238 -140
- package/lib/cjs/Editing/Exception.d.ts.map +1 -1
- package/lib/cjs/Editing/Exception.js +217 -196
- package/lib/cjs/Editing/Exception.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.d.ts +10 -0
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.d.ts.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.js +16 -0
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -0
- package/lib/cjs/Editing/SchemaItems.d.ts +12 -0
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +24 -0
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +25 -14
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +1 -0
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +1 -0
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
* @module Editing
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SchemaEditingError = exports.
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
10
|
+
exports.SchemaEditingError = exports.RelationshipConstraintId = exports.CustomAttributeId = exports.EnumeratorId = exports.PropertyId = exports.ClassId = exports.SchemaItemId = exports.SchemaId = exports.SchemaTypeIdentifiers = exports.PropertyTypeName = exports.ECEditingStatus = void 0;
|
|
12
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
13
12
|
/** @alpha */
|
|
14
13
|
var ECEditingStatus;
|
|
@@ -31,76 +30,71 @@ var ECEditingStatus;
|
|
|
31
30
|
ECEditingStatus[ECEditingStatus["InvalidEnumeratorType"] = 196622] = "InvalidEnumeratorType";
|
|
32
31
|
ECEditingStatus[ECEditingStatus["InvalidBaseClass"] = 196623] = "InvalidBaseClass";
|
|
33
32
|
ECEditingStatus[ECEditingStatus["EnumeratorDoesNotExist"] = 196624] = "EnumeratorDoesNotExist";
|
|
34
|
-
ECEditingStatus[ECEditingStatus["
|
|
35
|
-
ECEditingStatus[ECEditingStatus["
|
|
36
|
-
ECEditingStatus[ECEditingStatus["InvalidFormatUnitsSpecified"] = 196627] = "InvalidFormatUnitsSpecified";
|
|
33
|
+
ECEditingStatus[ECEditingStatus["InvalidECName"] = 196625] = "InvalidECName";
|
|
34
|
+
ECEditingStatus[ECEditingStatus["InvalidFormatUnitsSpecified"] = 196626] = "InvalidFormatUnitsSpecified";
|
|
37
35
|
// Outer Errors
|
|
38
|
-
ECEditingStatus[ECEditingStatus["CreateSchemaItemFailed"] =
|
|
39
|
-
ECEditingStatus[ECEditingStatus["CreateSchemaItemFromProps"] =
|
|
40
|
-
ECEditingStatus[ECEditingStatus["CreateElement"] =
|
|
41
|
-
ECEditingStatus[ECEditingStatus["CreateElementUniqueAspect"] =
|
|
42
|
-
ECEditingStatus[ECEditingStatus["CreateElementMultiAspect"] =
|
|
43
|
-
ECEditingStatus[ECEditingStatus["SetBaseClass"] =
|
|
44
|
-
ECEditingStatus[ECEditingStatus["SetSourceConstraint"] =
|
|
45
|
-
ECEditingStatus[ECEditingStatus["SetTargetConstraint"] =
|
|
46
|
-
ECEditingStatus[ECEditingStatus["AddConstraintClass"] =
|
|
47
|
-
ECEditingStatus[ECEditingStatus["RemoveConstraintClass"] =
|
|
48
|
-
ECEditingStatus[ECEditingStatus["SetAbstractConstraint"] =
|
|
49
|
-
ECEditingStatus[ECEditingStatus["AddCustomAttributeToConstraint"] =
|
|
50
|
-
ECEditingStatus[ECEditingStatus["AddCustomAttributeToProperty"] =
|
|
51
|
-
ECEditingStatus[ECEditingStatus["AddCustomAttributeToClass"] =
|
|
52
|
-
ECEditingStatus[ECEditingStatus["CreateNavigationProperty"] =
|
|
53
|
-
ECEditingStatus[ECEditingStatus["CreateNavigationPropertyFromProps"] =
|
|
54
|
-
ECEditingStatus[ECEditingStatus["SetInvertsUnit"] =
|
|
55
|
-
ECEditingStatus[ECEditingStatus["SetUnitSystem"] =
|
|
56
|
-
ECEditingStatus[ECEditingStatus["SetDescription"] =
|
|
57
|
-
ECEditingStatus[ECEditingStatus["SetLabel"] =
|
|
58
|
-
ECEditingStatus[ECEditingStatus["SetIsReadOnly"] =
|
|
59
|
-
ECEditingStatus[ECEditingStatus["SetPriority"] =
|
|
60
|
-
ECEditingStatus[ECEditingStatus["SetCategory"] =
|
|
61
|
-
ECEditingStatus[ECEditingStatus["SetMinOccurs"] =
|
|
62
|
-
ECEditingStatus[ECEditingStatus["SetMaxOccurs"] =
|
|
63
|
-
ECEditingStatus[ECEditingStatus["SetExtendedTypeName"] =
|
|
64
|
-
ECEditingStatus[ECEditingStatus["SetMinLength"] =
|
|
65
|
-
ECEditingStatus[ECEditingStatus["SetMaxLength"] =
|
|
66
|
-
ECEditingStatus[ECEditingStatus["SetMinValue"] =
|
|
67
|
-
ECEditingStatus[ECEditingStatus["SetMaxValue"] =
|
|
68
|
-
ECEditingStatus[ECEditingStatus["SetPropertyName"] =
|
|
69
|
-
ECEditingStatus[ECEditingStatus["AddMixin"] =
|
|
70
|
-
ECEditingStatus[ECEditingStatus["AddEnumerator"] =
|
|
71
|
-
ECEditingStatus[ECEditingStatus["SetEnumeratorLabel"] =
|
|
72
|
-
ECEditingStatus[ECEditingStatus["SetEnumeratorDescription"] =
|
|
73
|
-
ECEditingStatus[ECEditingStatus["AddPresentationUnit"] =
|
|
74
|
-
ECEditingStatus[ECEditingStatus["AddPresentationOverride"] =
|
|
75
|
-
ECEditingStatus[ECEditingStatus["CreateFormatOverride"] =
|
|
76
|
-
ECEditingStatus[ECEditingStatus["SetPropertyCategoryPriority"] =
|
|
77
|
-
ECEditingStatus[ECEditingStatus["CreatePrimitiveProperty"] =
|
|
78
|
-
ECEditingStatus[ECEditingStatus["CreatePrimitivePropertyFromProps"] =
|
|
79
|
-
ECEditingStatus[ECEditingStatus["CreateEnumerationProperty"] =
|
|
80
|
-
ECEditingStatus[ECEditingStatus["CreateEnumerationPropertyFromProps"] =
|
|
81
|
-
ECEditingStatus[ECEditingStatus["CreatePrimitiveArrayProperty"] =
|
|
82
|
-
ECEditingStatus[ECEditingStatus["CreatePrimitiveArrayPropertyFromProps"] =
|
|
83
|
-
ECEditingStatus[ECEditingStatus["CreateEnumerationArrayProperty"] =
|
|
84
|
-
ECEditingStatus[ECEditingStatus["CreateEnumerationArrayPropertyFromProps"] =
|
|
85
|
-
ECEditingStatus[ECEditingStatus["CreateStructProperty"] =
|
|
86
|
-
ECEditingStatus[ECEditingStatus["CreateStructPropertyFromProps"] =
|
|
87
|
-
ECEditingStatus[ECEditingStatus["CreateStructArrayProperty"] =
|
|
88
|
-
ECEditingStatus[ECEditingStatus["CreateStructArrayPropertyFromProps"] =
|
|
89
|
-
ECEditingStatus[ECEditingStatus["DeleteProperty"] =
|
|
90
|
-
ECEditingStatus[ECEditingStatus["DeleteClass"] =
|
|
91
|
-
ECEditingStatus[ECEditingStatus["SetClassName"] =
|
|
92
|
-
ECEditingStatus[ECEditingStatus["AddSchemaReference"] =
|
|
93
|
-
ECEditingStatus[ECEditingStatus["SetSchemaVersion"] =
|
|
94
|
-
ECEditingStatus[ECEditingStatus["IncrementSchemaMinorVersion"] =
|
|
36
|
+
ECEditingStatus[ECEditingStatus["CreateSchemaItemFailed"] = 196627] = "CreateSchemaItemFailed";
|
|
37
|
+
ECEditingStatus[ECEditingStatus["CreateSchemaItemFromProps"] = 196628] = "CreateSchemaItemFromProps";
|
|
38
|
+
ECEditingStatus[ECEditingStatus["CreateElement"] = 196629] = "CreateElement";
|
|
39
|
+
ECEditingStatus[ECEditingStatus["CreateElementUniqueAspect"] = 196630] = "CreateElementUniqueAspect";
|
|
40
|
+
ECEditingStatus[ECEditingStatus["CreateElementMultiAspect"] = 196631] = "CreateElementMultiAspect";
|
|
41
|
+
ECEditingStatus[ECEditingStatus["SetBaseClass"] = 196632] = "SetBaseClass";
|
|
42
|
+
ECEditingStatus[ECEditingStatus["SetSourceConstraint"] = 196633] = "SetSourceConstraint";
|
|
43
|
+
ECEditingStatus[ECEditingStatus["SetTargetConstraint"] = 196634] = "SetTargetConstraint";
|
|
44
|
+
ECEditingStatus[ECEditingStatus["AddConstraintClass"] = 196635] = "AddConstraintClass";
|
|
45
|
+
ECEditingStatus[ECEditingStatus["RemoveConstraintClass"] = 196636] = "RemoveConstraintClass";
|
|
46
|
+
ECEditingStatus[ECEditingStatus["SetAbstractConstraint"] = 196637] = "SetAbstractConstraint";
|
|
47
|
+
ECEditingStatus[ECEditingStatus["AddCustomAttributeToConstraint"] = 196638] = "AddCustomAttributeToConstraint";
|
|
48
|
+
ECEditingStatus[ECEditingStatus["AddCustomAttributeToProperty"] = 196639] = "AddCustomAttributeToProperty";
|
|
49
|
+
ECEditingStatus[ECEditingStatus["AddCustomAttributeToClass"] = 196640] = "AddCustomAttributeToClass";
|
|
50
|
+
ECEditingStatus[ECEditingStatus["CreateNavigationProperty"] = 196641] = "CreateNavigationProperty";
|
|
51
|
+
ECEditingStatus[ECEditingStatus["CreateNavigationPropertyFromProps"] = 196642] = "CreateNavigationPropertyFromProps";
|
|
52
|
+
ECEditingStatus[ECEditingStatus["SetInvertsUnit"] = 196643] = "SetInvertsUnit";
|
|
53
|
+
ECEditingStatus[ECEditingStatus["SetUnitSystem"] = 196644] = "SetUnitSystem";
|
|
54
|
+
ECEditingStatus[ECEditingStatus["SetDescription"] = 196645] = "SetDescription";
|
|
55
|
+
ECEditingStatus[ECEditingStatus["SetLabel"] = 196646] = "SetLabel";
|
|
56
|
+
ECEditingStatus[ECEditingStatus["SetIsReadOnly"] = 196647] = "SetIsReadOnly";
|
|
57
|
+
ECEditingStatus[ECEditingStatus["SetPriority"] = 196648] = "SetPriority";
|
|
58
|
+
ECEditingStatus[ECEditingStatus["SetCategory"] = 196649] = "SetCategory";
|
|
59
|
+
ECEditingStatus[ECEditingStatus["SetMinOccurs"] = 196650] = "SetMinOccurs";
|
|
60
|
+
ECEditingStatus[ECEditingStatus["SetMaxOccurs"] = 196651] = "SetMaxOccurs";
|
|
61
|
+
ECEditingStatus[ECEditingStatus["SetExtendedTypeName"] = 196652] = "SetExtendedTypeName";
|
|
62
|
+
ECEditingStatus[ECEditingStatus["SetMinLength"] = 196653] = "SetMinLength";
|
|
63
|
+
ECEditingStatus[ECEditingStatus["SetMaxLength"] = 196654] = "SetMaxLength";
|
|
64
|
+
ECEditingStatus[ECEditingStatus["SetMinValue"] = 196655] = "SetMinValue";
|
|
65
|
+
ECEditingStatus[ECEditingStatus["SetMaxValue"] = 196656] = "SetMaxValue";
|
|
66
|
+
ECEditingStatus[ECEditingStatus["SetPropertyName"] = 196657] = "SetPropertyName";
|
|
67
|
+
ECEditingStatus[ECEditingStatus["AddMixin"] = 196658] = "AddMixin";
|
|
68
|
+
ECEditingStatus[ECEditingStatus["AddEnumerator"] = 196659] = "AddEnumerator";
|
|
69
|
+
ECEditingStatus[ECEditingStatus["SetEnumeratorLabel"] = 196660] = "SetEnumeratorLabel";
|
|
70
|
+
ECEditingStatus[ECEditingStatus["SetEnumeratorDescription"] = 196661] = "SetEnumeratorDescription";
|
|
71
|
+
ECEditingStatus[ECEditingStatus["AddPresentationUnit"] = 196662] = "AddPresentationUnit";
|
|
72
|
+
ECEditingStatus[ECEditingStatus["AddPresentationOverride"] = 196663] = "AddPresentationOverride";
|
|
73
|
+
ECEditingStatus[ECEditingStatus["CreateFormatOverride"] = 196664] = "CreateFormatOverride";
|
|
74
|
+
ECEditingStatus[ECEditingStatus["SetPropertyCategoryPriority"] = 196665] = "SetPropertyCategoryPriority";
|
|
75
|
+
ECEditingStatus[ECEditingStatus["CreatePrimitiveProperty"] = 196666] = "CreatePrimitiveProperty";
|
|
76
|
+
ECEditingStatus[ECEditingStatus["CreatePrimitivePropertyFromProps"] = 196667] = "CreatePrimitivePropertyFromProps";
|
|
77
|
+
ECEditingStatus[ECEditingStatus["CreateEnumerationProperty"] = 196668] = "CreateEnumerationProperty";
|
|
78
|
+
ECEditingStatus[ECEditingStatus["CreateEnumerationPropertyFromProps"] = 196669] = "CreateEnumerationPropertyFromProps";
|
|
79
|
+
ECEditingStatus[ECEditingStatus["CreatePrimitiveArrayProperty"] = 196670] = "CreatePrimitiveArrayProperty";
|
|
80
|
+
ECEditingStatus[ECEditingStatus["CreatePrimitiveArrayPropertyFromProps"] = 196671] = "CreatePrimitiveArrayPropertyFromProps";
|
|
81
|
+
ECEditingStatus[ECEditingStatus["CreateEnumerationArrayProperty"] = 196672] = "CreateEnumerationArrayProperty";
|
|
82
|
+
ECEditingStatus[ECEditingStatus["CreateEnumerationArrayPropertyFromProps"] = 196673] = "CreateEnumerationArrayPropertyFromProps";
|
|
83
|
+
ECEditingStatus[ECEditingStatus["CreateStructProperty"] = 196674] = "CreateStructProperty";
|
|
84
|
+
ECEditingStatus[ECEditingStatus["CreateStructPropertyFromProps"] = 196675] = "CreateStructPropertyFromProps";
|
|
85
|
+
ECEditingStatus[ECEditingStatus["CreateStructArrayProperty"] = 196676] = "CreateStructArrayProperty";
|
|
86
|
+
ECEditingStatus[ECEditingStatus["CreateStructArrayPropertyFromProps"] = 196677] = "CreateStructArrayPropertyFromProps";
|
|
87
|
+
ECEditingStatus[ECEditingStatus["DeleteProperty"] = 196678] = "DeleteProperty";
|
|
88
|
+
ECEditingStatus[ECEditingStatus["DeleteClass"] = 196679] = "DeleteClass";
|
|
89
|
+
ECEditingStatus[ECEditingStatus["SetClassName"] = 196680] = "SetClassName";
|
|
90
|
+
ECEditingStatus[ECEditingStatus["AddSchemaReference"] = 196681] = "AddSchemaReference";
|
|
91
|
+
ECEditingStatus[ECEditingStatus["SetSchemaVersion"] = 196682] = "SetSchemaVersion";
|
|
92
|
+
ECEditingStatus[ECEditingStatus["IncrementSchemaMinorVersion"] = 196683] = "IncrementSchemaMinorVersion";
|
|
95
93
|
})(ECEditingStatus || (exports.ECEditingStatus = ECEditingStatus = {}));
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
TaskType[TaskType["Update"] = 2] = "Update";
|
|
101
|
-
TaskType[TaskType["Change"] = 3] = "Change";
|
|
102
|
-
TaskType[TaskType["Delete"] = 4] = "Delete";
|
|
103
|
-
})(TaskType || (exports.TaskType = TaskType = {}));
|
|
94
|
+
/**
|
|
95
|
+
* Defines the possible property type names.
|
|
96
|
+
* @alpha
|
|
97
|
+
*/
|
|
104
98
|
var PropertyTypeName;
|
|
105
99
|
(function (PropertyTypeName) {
|
|
106
100
|
PropertyTypeName["ArrayProperty"] = "ArrayProperty";
|
|
@@ -109,13 +103,37 @@ var PropertyTypeName;
|
|
|
109
103
|
PropertyTypeName["NavigationProperty"] = "NavigationProperty";
|
|
110
104
|
PropertyTypeName["StructProperty"] = "StructProperty";
|
|
111
105
|
})(PropertyTypeName || (exports.PropertyTypeName = PropertyTypeName = {}));
|
|
106
|
+
/**
|
|
107
|
+
* Defines the possible schema type identifiers.
|
|
108
|
+
* @alpha
|
|
109
|
+
*/
|
|
110
|
+
var SchemaTypeIdentifiers;
|
|
111
|
+
(function (SchemaTypeIdentifiers) {
|
|
112
|
+
SchemaTypeIdentifiers["SchemaIdentifier"] = "Schema";
|
|
113
|
+
SchemaTypeIdentifiers["SchemaItemIdentifier"] = "SchemaItem";
|
|
114
|
+
SchemaTypeIdentifiers["ClassIdentifier"] = "Class";
|
|
115
|
+
SchemaTypeIdentifiers["PropertyIdentifier"] = "Property";
|
|
116
|
+
SchemaTypeIdentifiers["EnumerationIdentifier"] = "Enumeration";
|
|
117
|
+
SchemaTypeIdentifiers["EnumeratorIdentifier"] = "Enumerator";
|
|
118
|
+
SchemaTypeIdentifiers["CustomAttributeIdentifier"] = "CustomAttribute";
|
|
119
|
+
SchemaTypeIdentifiers["RelationshipConstraintIdentifier"] = "RelationshipConstraint";
|
|
120
|
+
})(SchemaTypeIdentifiers || (exports.SchemaTypeIdentifiers = SchemaTypeIdentifiers = {}));
|
|
121
|
+
/**
|
|
122
|
+
* An ISchemaIdentifier implementation to identify Schemas
|
|
123
|
+
* @alpha
|
|
124
|
+
*/
|
|
112
125
|
class SchemaId {
|
|
113
126
|
constructor(schemaKey) {
|
|
127
|
+
this.typeIdentifier = SchemaTypeIdentifiers.SchemaIdentifier;
|
|
114
128
|
this.name = schemaKey.name;
|
|
115
129
|
this.schemaKey = schemaKey;
|
|
116
130
|
}
|
|
117
131
|
}
|
|
118
132
|
exports.SchemaId = SchemaId;
|
|
133
|
+
/**
|
|
134
|
+
* An ISchemItemIdentifier implementation to identify SchemaItems
|
|
135
|
+
* @alpha
|
|
136
|
+
*/
|
|
119
137
|
class SchemaItemId {
|
|
120
138
|
constructor(schemaItemType, schemaItemKeyOrName, schemaKey) {
|
|
121
139
|
if (typeof (schemaItemKeyOrName) === "string") {
|
|
@@ -128,19 +146,31 @@ class SchemaItemId {
|
|
|
128
146
|
this.schemaKey = schemaItemKeyOrName.schemaKey;
|
|
129
147
|
this.schemaItemKey = schemaItemKeyOrName;
|
|
130
148
|
}
|
|
131
|
-
this.
|
|
149
|
+
this.schemaItemType = schemaItemType;
|
|
132
150
|
this.name = this.schemaItemKey.fullName;
|
|
151
|
+
this.typeIdentifier = SchemaTypeIdentifiers.SchemaItemIdentifier;
|
|
133
152
|
}
|
|
134
153
|
}
|
|
135
154
|
exports.SchemaItemId = SchemaItemId;
|
|
155
|
+
/**
|
|
156
|
+
* An IClassIdentifier implementation to identify Class instances.
|
|
157
|
+
* @alpha
|
|
158
|
+
*/
|
|
136
159
|
class ClassId extends SchemaItemId {
|
|
137
160
|
constructor(schemaItemType, schemaItemKeyOrName, schemaKey) {
|
|
138
161
|
super(schemaItemType, schemaItemKeyOrName, schemaKey);
|
|
162
|
+
this.typeIdentifier = SchemaTypeIdentifiers.ClassIdentifier;
|
|
163
|
+
this.schemaItemType = schemaItemType;
|
|
139
164
|
}
|
|
140
165
|
}
|
|
141
166
|
exports.ClassId = ClassId;
|
|
167
|
+
/**
|
|
168
|
+
* An IPropertyIdentifier implementation to identify Property instances.
|
|
169
|
+
* @alpha
|
|
170
|
+
*/
|
|
142
171
|
class PropertyId {
|
|
143
172
|
constructor(schemaItemType, classKey, property, typeName) {
|
|
173
|
+
this.typeIdentifier = SchemaTypeIdentifiers.PropertyIdentifier;
|
|
144
174
|
this.name = property instanceof ecschema_metadata_1.Property ? property.name : property;
|
|
145
175
|
this.fullName = property instanceof ecschema_metadata_1.Property ? property.fullName : `${classKey.name}.${property}`;
|
|
146
176
|
this.ecClass = new ClassId(schemaItemType, classKey);
|
|
@@ -149,108 +179,56 @@ class PropertyId {
|
|
|
149
179
|
}
|
|
150
180
|
}
|
|
151
181
|
exports.PropertyId = PropertyId;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
182
|
+
/**
|
|
183
|
+
* An IEnumeratorIdentifier implementation to identify Enumerator instances.
|
|
184
|
+
* @alpha
|
|
185
|
+
*/
|
|
186
|
+
class EnumeratorId {
|
|
187
|
+
constructor(enumerator, enumeration) {
|
|
188
|
+
this.typeIdentifier = SchemaTypeIdentifiers.EnumeratorIdentifier;
|
|
189
|
+
this.enumeration = enumeration.key;
|
|
155
190
|
this.enumerationType = enumeration.type ? (0, ecschema_metadata_1.primitiveTypeToString)(enumeration.type) : "string";
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
158
|
-
|
|
159
|
-
getEnumeratorType(enumeration, enumerator) {
|
|
160
|
-
if (typeof (enumerator) === "string")
|
|
161
|
-
return enumeration.isString ? "string" : "int";
|
|
162
|
-
return typeof (enumerator.value) === "string" ? "string" : "int";
|
|
191
|
+
this.enumeratorType = getEnumeratorType(enumeration ?? ecschema_metadata_1.PrimitiveType.String, enumerator);
|
|
192
|
+
this.name = typeof (enumerator) === "string" ? enumerator : enumerator.name;
|
|
193
|
+
this.schemaKey = enumeration.schema.schemaKey;
|
|
163
194
|
}
|
|
164
195
|
}
|
|
165
|
-
exports.
|
|
196
|
+
exports.EnumeratorId = EnumeratorId;
|
|
197
|
+
/**
|
|
198
|
+
* An ICustomAttributeIdentifier implementation to identify CustomAttribute instances.
|
|
199
|
+
* @alpha
|
|
200
|
+
*/
|
|
166
201
|
class CustomAttributeId {
|
|
167
202
|
constructor(name, container) {
|
|
203
|
+
this.typeIdentifier = SchemaTypeIdentifiers.CustomAttributeIdentifier;
|
|
168
204
|
this.name = name;
|
|
169
205
|
this.schemaKey = container.schema.schemaKey;
|
|
170
206
|
this.containerFullName = container.fullName;
|
|
171
207
|
}
|
|
172
208
|
}
|
|
173
209
|
exports.CustomAttributeId = CustomAttributeId;
|
|
210
|
+
/**
|
|
211
|
+
* An IRelationshipConstraintIdentifier implementation to identify RelationshipConstraints.
|
|
212
|
+
* @alpha
|
|
213
|
+
*/
|
|
174
214
|
class RelationshipConstraintId {
|
|
175
215
|
constructor(constraint) {
|
|
176
|
-
this.
|
|
216
|
+
this.typeIdentifier = SchemaTypeIdentifiers.RelationshipConstraintIdentifier;
|
|
217
|
+
this.name = constraint.isSource ? "Source" : "Target";
|
|
177
218
|
this.relationshipKey = constraint.relationshipClass.key;
|
|
178
219
|
this.schemaKey = this.relationshipKey.schemaKey;
|
|
179
220
|
}
|
|
180
221
|
}
|
|
181
222
|
exports.RelationshipConstraintId = RelationshipConstraintId;
|
|
182
223
|
/**
|
|
183
|
-
* Indicates if the given identifier is a SchemaId instance.
|
|
184
|
-
* @param identifier The identifier to check.
|
|
185
|
-
* @returns true if the identifier is the correct type.
|
|
186
|
-
*/
|
|
187
|
-
function isSchemaIdentifier(identifier) {
|
|
188
|
-
return identifier instanceof SchemaId;
|
|
189
|
-
}
|
|
190
|
-
exports.isSchemaIdentifier = isSchemaIdentifier;
|
|
191
|
-
/**
|
|
192
|
-
* Indicates if the given identifier is a SchemaId instance.
|
|
193
|
-
* @param identifier The identifier to check.
|
|
194
|
-
* @returns true if the identifier is the correct type.
|
|
195
|
-
*/
|
|
196
|
-
function isSchemaItemIdentifier(identifier) {
|
|
197
|
-
return identifier instanceof SchemaItemId;
|
|
198
|
-
}
|
|
199
|
-
exports.isSchemaItemIdentifier = isSchemaItemIdentifier;
|
|
200
|
-
/**
|
|
201
|
-
* Indicates if the given identifier is a ClassId instance.
|
|
202
|
-
* @param identifier The identifier to check.
|
|
203
|
-
* @returns true if the identifier is the correct type.
|
|
204
|
-
*/
|
|
205
|
-
function isClassIdentifier(identifier) {
|
|
206
|
-
return identifier instanceof ClassId;
|
|
207
|
-
}
|
|
208
|
-
exports.isClassIdentifier = isClassIdentifier;
|
|
209
|
-
/**
|
|
210
|
-
* Indicates if the given identifier is a PropertyId instance.
|
|
211
|
-
* @param identifier The identifier to check.
|
|
212
|
-
* @returns true if the identifier is the correct type.
|
|
213
|
-
*/
|
|
214
|
-
function isPropertyIdentifier(identifier) {
|
|
215
|
-
return identifier instanceof PropertyId;
|
|
216
|
-
}
|
|
217
|
-
exports.isPropertyIdentifier = isPropertyIdentifier;
|
|
218
|
-
/**
|
|
219
|
-
* Indicates if the given identifier is a EnumerationId instance.
|
|
220
|
-
* @param identifier The identifier to check.
|
|
221
|
-
* @returns true if the identifier is the correct type.
|
|
222
|
-
*/
|
|
223
|
-
function isEnumerationIdentifier(identifier) {
|
|
224
|
-
return identifier instanceof EnumerationId;
|
|
225
|
-
}
|
|
226
|
-
exports.isEnumerationIdentifier = isEnumerationIdentifier;
|
|
227
|
-
/**
|
|
228
|
-
* Indicates if the given identifier is a CustomAttributeId instance.
|
|
229
|
-
* @param identifier The identifier to check.
|
|
230
|
-
* @returns true if the identifier is the correct type.
|
|
231
|
-
*/
|
|
232
|
-
function isCustomAttributeIdentifier(identifier) {
|
|
233
|
-
return identifier instanceof CustomAttributeId;
|
|
234
|
-
}
|
|
235
|
-
exports.isCustomAttributeIdentifier = isCustomAttributeIdentifier;
|
|
236
|
-
/**
|
|
237
|
-
* Indicates if the given identifier is a RelationshipConstraintId instance.
|
|
238
|
-
* @param identifier The identifier to check.
|
|
239
|
-
* @returns true if the identifier is the correct type.
|
|
240
|
-
*/
|
|
241
|
-
function isRelationshipConstraintIdentifier(identifier) {
|
|
242
|
-
return identifier instanceof RelationshipConstraintId;
|
|
243
|
-
}
|
|
244
|
-
exports.isRelationshipConstraintIdentifier = isRelationshipConstraintIdentifier;
|
|
245
|
-
/**
|
|
246
|
-
* @internal
|
|
247
224
|
* An exception class for the ecschema-editing API. Contains identifiers for schema types involved in the
|
|
248
225
|
* exception. An example being SchemaItemId which contains the name of the SchemaItem, SchemaItemKey, SchemaItemType, etc.
|
|
249
226
|
* Typically will contain an innerError of type SchemaEditingError containing the identifier of the schema item that
|
|
250
227
|
* caused the exception. The containing error instance will identify the method called (identified by the errorNumber)
|
|
251
228
|
* and the identifier of the schema item being modified/created.
|
|
229
|
+
* @alpha
|
|
252
230
|
*/
|
|
253
|
-
class SchemaEditingError extends
|
|
231
|
+
class SchemaEditingError extends Error {
|
|
254
232
|
/**
|
|
255
233
|
* Constructs a new SchemaEditingError instance.
|
|
256
234
|
* @param errorNumber The unique ECEditingStatus code identifying the error.
|
|
@@ -260,7 +238,7 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
260
238
|
* @param message Optional error message. Most messages on automatically generated by this class based on the ECEditingStatus code.
|
|
261
239
|
*/
|
|
262
240
|
constructor(errorNumber, identifier, innerError, ruleViolations, message) {
|
|
263
|
-
super(
|
|
241
|
+
super(message);
|
|
264
242
|
this.errorNumber = errorNumber;
|
|
265
243
|
this.identifier = identifier;
|
|
266
244
|
this.innerError = innerError;
|
|
@@ -272,8 +250,8 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
272
250
|
* Gets the SchemaId instance.
|
|
273
251
|
* @throws Error if the identifier is not an instance of SchemaId.
|
|
274
252
|
*/
|
|
275
|
-
get
|
|
276
|
-
if (
|
|
253
|
+
get _schemaId() {
|
|
254
|
+
if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.SchemaIdentifier)
|
|
277
255
|
throw new Error("identifier is not a SchemaId.");
|
|
278
256
|
return this.identifier;
|
|
279
257
|
}
|
|
@@ -281,8 +259,8 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
281
259
|
* Gets the SchemaItemId instance.
|
|
282
260
|
* @throws Error if the identifier is not an instance of SchemaItemId.
|
|
283
261
|
*/
|
|
284
|
-
get
|
|
285
|
-
if (
|
|
262
|
+
get _schemaItemId() {
|
|
263
|
+
if (this.isSchemaItemIdentifier(this.identifier))
|
|
286
264
|
throw new Error("identifier is not a SchemaItemId.");
|
|
287
265
|
return this.identifier;
|
|
288
266
|
}
|
|
@@ -290,8 +268,8 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
290
268
|
* Gets the ClassId instance.
|
|
291
269
|
* @throws Error if the identifier is not an instance of ClassId.
|
|
292
270
|
*/
|
|
293
|
-
get
|
|
294
|
-
if (
|
|
271
|
+
get _classId() {
|
|
272
|
+
if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.ClassIdentifier)
|
|
295
273
|
throw new Error("identifier is not a ClassId.");
|
|
296
274
|
return this.identifier;
|
|
297
275
|
}
|
|
@@ -299,17 +277,17 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
299
277
|
* Gets the PropertyId instance.
|
|
300
278
|
* @throws Error if the identifier is not an instance of PropertyId.
|
|
301
279
|
*/
|
|
302
|
-
get
|
|
303
|
-
if (
|
|
280
|
+
get _propertyId() {
|
|
281
|
+
if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.PropertyIdentifier)
|
|
304
282
|
throw new Error("identifier is not a PropertyId.");
|
|
305
283
|
return this.identifier;
|
|
306
284
|
}
|
|
307
285
|
/**
|
|
308
|
-
* Gets the
|
|
309
|
-
* @throws Error if the identifier is not an instance of
|
|
286
|
+
* Gets the EnumeratorId instance.
|
|
287
|
+
* @throws Error if the identifier is not an instance of EnumeratorId.
|
|
310
288
|
*/
|
|
311
|
-
get
|
|
312
|
-
if (
|
|
289
|
+
get _enumeratorId() {
|
|
290
|
+
if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.EnumeratorIdentifier)
|
|
313
291
|
throw new Error("identifier is not a EnumerationId.");
|
|
314
292
|
return this.identifier;
|
|
315
293
|
}
|
|
@@ -317,8 +295,8 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
317
295
|
* Gets the CustomAttributeId instance.
|
|
318
296
|
* @throws Error if the identifier is not an instance of CustomAttributeId.
|
|
319
297
|
*/
|
|
320
|
-
get
|
|
321
|
-
if (
|
|
298
|
+
get _customAttributeId() {
|
|
299
|
+
if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.CustomAttributeIdentifier)
|
|
322
300
|
throw new Error("identifier is not a CustomAttributeId.");
|
|
323
301
|
return this.identifier;
|
|
324
302
|
}
|
|
@@ -326,27 +304,32 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
326
304
|
* Gets the RelationshipConstraintId instance.
|
|
327
305
|
* @throws Error if the identifier is not an instance of RelationshipConstraintId.
|
|
328
306
|
*/
|
|
329
|
-
get
|
|
330
|
-
if (
|
|
307
|
+
get _relationshipConstraintId() {
|
|
308
|
+
if (this.identifier.typeIdentifier !== SchemaTypeIdentifiers.RelationshipConstraintIdentifier)
|
|
331
309
|
throw new Error("identifier is not a RelationshipConstraintId.");
|
|
332
310
|
return this.identifier;
|
|
333
311
|
}
|
|
312
|
+
/** Gets rule violations that were reported during validation. Returns an array of [[AnyDiagnostic]] if
|
|
313
|
+
* the errorNumber is ECEditingStatus.RuleViolation, otherwise undefined.
|
|
314
|
+
*/
|
|
334
315
|
get ruleViolations() {
|
|
335
316
|
return this._ruleViolations;
|
|
336
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Returns a readable string containing the ECEditingStatus along with the error message. Any
|
|
320
|
+
* innerError will also be appended.
|
|
321
|
+
* @returns
|
|
322
|
+
*/
|
|
337
323
|
toDebugString() {
|
|
338
324
|
let innerMessage = "";
|
|
339
325
|
if (this.innerError) {
|
|
340
326
|
if (this.innerError instanceof SchemaEditingError)
|
|
341
|
-
innerMessage =
|
|
327
|
+
innerMessage = ` Inner error: ${this.innerError.toDebugString()}`;
|
|
342
328
|
else
|
|
343
|
-
innerMessage =
|
|
329
|
+
innerMessage = ` Inner error: ${this.innerError.message}`;
|
|
344
330
|
}
|
|
345
331
|
return this._appendMessage(`ECEditingStatus.${ECEditingStatus[this.errorNumber]}`) + innerMessage;
|
|
346
332
|
}
|
|
347
|
-
_appendMessage(e) {
|
|
348
|
-
return this.message ? `${e}: ${this.message}` : e;
|
|
349
|
-
}
|
|
350
333
|
generateMessage() {
|
|
351
334
|
if (this.message)
|
|
352
335
|
return;
|
|
@@ -355,72 +338,110 @@ class SchemaEditingError extends core_bentley_1.BentleyError {
|
|
|
355
338
|
this.message = `Schema Key ${this._schemaKey.toString(true)} could not be found in the context.`;
|
|
356
339
|
return;
|
|
357
340
|
case ECEditingStatus.SchemaItemNotFound:
|
|
358
|
-
this.message = `${this.
|
|
341
|
+
this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} could not be found in the schema ${this._schemaKey.name}.`;
|
|
359
342
|
return;
|
|
360
343
|
case ECEditingStatus.SchemaItemNotFoundInContext:
|
|
361
|
-
this.message = `${this.
|
|
344
|
+
this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} could not be found in the schema context.`;
|
|
362
345
|
return;
|
|
363
346
|
case ECEditingStatus.InvalidSchemaItemType:
|
|
364
|
-
this.message = `Expected ${this.
|
|
347
|
+
this.message = `Expected ${this._schemaItemId.name} to be of type ${this._schemaItemId.schemaItemType}.`;
|
|
365
348
|
return;
|
|
366
349
|
case ECEditingStatus.SchemaItemNameNotSpecified:
|
|
367
|
-
this.message = `Could not create a new ${this.
|
|
350
|
+
this.message = `Could not create a new ${this._schemaItemId.schemaItemType} in schema ${this._schemaKey.name}. No name was supplied within props.`;
|
|
368
351
|
return;
|
|
369
352
|
case ECEditingStatus.SchemaItemNameAlreadyExists:
|
|
370
|
-
this.message = `${this.
|
|
353
|
+
this.message = `${this._schemaItemId.schemaItemType} ${this._schemaItemId.name} already exists in the schema ${this._schemaKey.name}.`;
|
|
371
354
|
return;
|
|
372
355
|
case ECEditingStatus.RuleViolation:
|
|
373
|
-
this.message = this.
|
|
356
|
+
this.message = this._getRuleViolationMessage();
|
|
374
357
|
return;
|
|
375
358
|
case ECEditingStatus.PropertyNotFound:
|
|
376
|
-
this.message = `An ECProperty with the name ${this.
|
|
359
|
+
this.message = `An ECProperty with the name ${this._propertyId.name} could not be found in the class ${this._propertyId.ecClass.name}.`;
|
|
377
360
|
return;
|
|
378
361
|
case ECEditingStatus.PropertyAlreadyExists:
|
|
379
|
-
this.message = `An ECProperty with the name ${this.
|
|
362
|
+
this.message = `An ECProperty with the name ${this._propertyId.name} already exists in the class ${this._propertyId.ecClass.name}.`;
|
|
380
363
|
return;
|
|
381
364
|
case ECEditingStatus.InvalidPropertyType:
|
|
382
|
-
this.message = `Expected property ${this.
|
|
365
|
+
this.message = `Expected property ${this._propertyId.name} to be of type ${this._propertyId.typeName}.`;
|
|
383
366
|
return;
|
|
384
367
|
case ECEditingStatus.BaseClassIsNotElement:
|
|
385
|
-
this.message = `Expected base class ${this.
|
|
368
|
+
this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.Element.`;
|
|
386
369
|
return;
|
|
387
370
|
case ECEditingStatus.BaseClassIsNotElementUniqueAspect:
|
|
388
|
-
this.message = `Expected base class ${this.
|
|
371
|
+
this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.ElementUniqueAspect.`;
|
|
389
372
|
return;
|
|
390
373
|
case ECEditingStatus.BaseClassIsNotElementMultiAspect:
|
|
391
|
-
this.message = `Expected base class ${this.
|
|
374
|
+
this.message = `Expected base class ${this._schemaItemId.name} to derive from BisCore.ElementMultiAspect.`;
|
|
392
375
|
return;
|
|
393
376
|
case ECEditingStatus.InvalidFormatUnitsSpecified:
|
|
394
|
-
this.message = `The specified Format unit ${this.
|
|
377
|
+
this.message = `The specified Format unit ${this._schemaItemId.name} is not of type Unit or InvertedUnit`;
|
|
395
378
|
return;
|
|
396
379
|
case ECEditingStatus.InvalidEnumeratorType:
|
|
397
|
-
this.message = `The Enumeration ${this.
|
|
380
|
+
this.message = `The Enumeration ${this._enumeratorId.enumeration.fullName} has type ${this._enumeratorId.enumerationType}, while Enumerator ${this._enumeratorId.name} has type ${this._enumeratorId.enumeratorType}.`;
|
|
398
381
|
return;
|
|
399
382
|
case ECEditingStatus.EnumeratorDoesNotExist:
|
|
400
|
-
this.message = `Enumerator ${this.
|
|
383
|
+
this.message = `Enumerator ${this._enumeratorId.name} does not exists in Enumeration ${this._enumeratorId.enumeration.name}.`;
|
|
401
384
|
return;
|
|
402
385
|
case ECEditingStatus.InvalidECName:
|
|
403
|
-
this.message = `Could not rename class ${this.
|
|
386
|
+
this.message = `Could not rename class ${this._schemaItemId.name} because the specified name is not a valid ECName.`;
|
|
404
387
|
return;
|
|
388
|
+
default:
|
|
389
|
+
this.message = this._createTaskErrorMessage();
|
|
405
390
|
}
|
|
406
391
|
}
|
|
407
|
-
|
|
392
|
+
_appendMessage(e) {
|
|
393
|
+
return this.message ? `${e}: ${this.message}` : e;
|
|
394
|
+
}
|
|
395
|
+
_getRuleViolationMessage() {
|
|
408
396
|
if (!this._ruleViolations)
|
|
409
397
|
return "";
|
|
410
398
|
let violations = "";
|
|
411
399
|
for (const diagnostic of this._ruleViolations) {
|
|
412
400
|
violations += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
|
|
413
401
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
402
|
+
switch (this.identifier.typeIdentifier) {
|
|
403
|
+
case SchemaTypeIdentifiers.SchemaIdentifier:
|
|
404
|
+
return `Rule violations occurred from Schema ${this._schemaId.name}: ${violations}`;
|
|
405
|
+
case SchemaTypeIdentifiers.SchemaItemIdentifier:
|
|
406
|
+
return `Rule violations occurred from ${this._schemaItemId.schemaItemType} ${this._schemaItemId.name}: ${violations}`;
|
|
407
|
+
case SchemaTypeIdentifiers.ClassIdentifier:
|
|
408
|
+
return `Rule violations occurred from ${this._schemaItemId.schemaItemType} ${this._schemaItemId.name}: ${violations}`;
|
|
409
|
+
case SchemaTypeIdentifiers.CustomAttributeIdentifier:
|
|
410
|
+
return `Rule violations occurred from CustomAttribute ${this._customAttributeId.name}, container ${this._customAttributeId.containerFullName}: ${violations}`;
|
|
411
|
+
case SchemaTypeIdentifiers.RelationshipConstraintIdentifier:
|
|
412
|
+
return `Rule violations occurred from ${this._relationshipConstraintId.name} constraint of RelationshipClass ${this._relationshipConstraintId.relationshipKey.fullName}: ${violations}`;
|
|
413
|
+
default:
|
|
414
|
+
throw new Error("Invalid identifier.");
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
_createTaskErrorMessage() {
|
|
418
|
+
// Make sure we have an inner error or else it is not a task error
|
|
419
|
+
if (!this.innerError)
|
|
420
|
+
return "";
|
|
421
|
+
switch (this.identifier.typeIdentifier) {
|
|
422
|
+
case SchemaTypeIdentifiers.SchemaIdentifier:
|
|
423
|
+
case SchemaTypeIdentifiers.SchemaItemIdentifier:
|
|
424
|
+
case SchemaTypeIdentifiers.ClassIdentifier:
|
|
425
|
+
case SchemaTypeIdentifiers.RelationshipConstraintIdentifier:
|
|
426
|
+
return `While performing task '${ECEditingStatus[this.errorNumber]}' an error occurred editing ${this.identifier.typeIdentifier} ${this.identifier.name}.`;
|
|
427
|
+
case SchemaTypeIdentifiers.PropertyIdentifier:
|
|
428
|
+
return `While performing task '${ECEditingStatus[this.errorNumber]}' an error occurred editing ${this.identifier.typeIdentifier} ${this.identifier.fullName}.`;
|
|
429
|
+
default:
|
|
430
|
+
throw new Error("Invalid identifier.");
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
isSchemaItemIdentifier(identifier) {
|
|
434
|
+
if (identifier.typeIdentifier !== SchemaTypeIdentifiers.SchemaItemIdentifier &&
|
|
435
|
+
identifier.typeIdentifier !== SchemaTypeIdentifiers.ClassIdentifier)
|
|
436
|
+
return true;
|
|
437
|
+
return false;
|
|
423
438
|
}
|
|
424
439
|
}
|
|
425
440
|
exports.SchemaEditingError = SchemaEditingError;
|
|
441
|
+
function getEnumeratorType(enumeration, enumerator) {
|
|
442
|
+
if (typeof (enumerator) === "string") {
|
|
443
|
+
return enumeration.type ? (0, ecschema_metadata_1.primitiveTypeToString)(enumeration.type) : "string";
|
|
444
|
+
}
|
|
445
|
+
return typeof (enumerator.value) === "string" ? "string" : "int";
|
|
446
|
+
}
|
|
426
447
|
//# sourceMappingURL=Exception.js.map
|