@itwin/ecschema-editing 4.6.0-dev.9 → 4.6.1
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/CHANGELOG.md +27 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +14 -0
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +15 -2
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +0 -52
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +2 -2
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +3 -3
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +2 -2
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +29 -23
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +51 -95
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +6 -7
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +7 -27
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +6 -2
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +7 -22
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +2 -2
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.d.ts +8 -0
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.d.ts.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js +16 -0
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableStructProperty.d.ts +8 -0
- package/lib/cjs/Editing/Mutable/MutableStructProperty.d.ts.map +1 -0
- package/lib/cjs/Editing/Mutable/MutableStructProperty.js +16 -0
- package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -0
- package/lib/cjs/Editing/Properties.d.ts +201 -0
- package/lib/cjs/Editing/Properties.d.ts.map +1 -0
- package/lib/cjs/Editing/Properties.js +349 -0
- package/lib/cjs/Editing/Properties.js.map +1 -0
- package/lib/cjs/Editing/RelationshipClasses.d.ts +12 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +26 -3
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +1 -1
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +2 -2
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +7 -16
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +6 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +54 -23
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +12 -8
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.d.ts +2 -2
- package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +4 -4
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.d.ts +35 -35
- package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.d.ts +38 -6
- package/lib/cjs/Validation/SchemaChanges.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js +97 -27
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +4 -3
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +1 -0
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +238 -260
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +2 -0
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +2 -0
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +11 -11
|
@@ -22,7 +22,7 @@ var SchemaCompareDirection;
|
|
|
22
22
|
(function (SchemaCompareDirection) {
|
|
23
23
|
SchemaCompareDirection[SchemaCompareDirection["Forward"] = 0] = "Forward";
|
|
24
24
|
SchemaCompareDirection[SchemaCompareDirection["Backward"] = 1] = "Backward";
|
|
25
|
-
})(SchemaCompareDirection
|
|
25
|
+
})(SchemaCompareDirection || (exports.SchemaCompareDirection = SchemaCompareDirection = {}));
|
|
26
26
|
function labelsMatch(label1, label2) {
|
|
27
27
|
label1 = label1 === undefined ? "" : label1;
|
|
28
28
|
label2 = label2 === undefined ? "" : label2;
|
|
@@ -94,9 +94,6 @@ class SchemaComparer {
|
|
|
94
94
|
const promises = [];
|
|
95
95
|
if (!schemaItemB) {
|
|
96
96
|
promises.push(this._reporter.reportSchemaItemMissing(schemaItemA, this._compareDirection));
|
|
97
|
-
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "description", schemaItemA.description, undefined, this._compareDirection));
|
|
98
|
-
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "label", schemaItemA.label, undefined, this._compareDirection));
|
|
99
|
-
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "schemaItemType", schemaItemA.schemaItemType, undefined, this._compareDirection));
|
|
100
97
|
await Promise.all(promises);
|
|
101
98
|
return;
|
|
102
99
|
}
|
|
@@ -119,25 +116,22 @@ class SchemaComparer {
|
|
|
119
116
|
* @param classB The second ECClass.
|
|
120
117
|
*/
|
|
121
118
|
async compareClasses(classA, classB) {
|
|
122
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
119
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !classB)
|
|
123
120
|
return;
|
|
124
121
|
const promises = [];
|
|
125
|
-
|
|
126
|
-
if (classA.modifier !== modifierB) {
|
|
122
|
+
if (classA.modifier !== classB.modifier) {
|
|
127
123
|
const aMod = (0, ecschema_metadata_1.classModifierToString)(classA.modifier);
|
|
128
|
-
const bMod =
|
|
124
|
+
const bMod = (0, ecschema_metadata_1.classModifierToString)(classB.modifier);
|
|
129
125
|
promises.push(this._reporter.reportClassDelta(classA, "modifier", aMod, bMod, this._compareDirection));
|
|
130
126
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const fullNameA = baseClassA ? baseClassA.fullName : undefined;
|
|
135
|
-
const fullNameB = baseClassB ? baseClassB.fullName : undefined;
|
|
127
|
+
if (classA.baseClass || classB.baseClass) {
|
|
128
|
+
const fullNameA = classA.baseClass?.fullName;
|
|
129
|
+
const fullNameB = classB.baseClass?.fullName;
|
|
136
130
|
if (fullNameA !== fullNameB) {
|
|
137
|
-
const areSameByName = this.areItemsSameByName(
|
|
131
|
+
const areSameByName = this.areItemsSameByName(classA.baseClass, classB.baseClass, classA.schema.name, classB.schema.name);
|
|
138
132
|
if (!areSameByName) {
|
|
139
|
-
const baseA = await
|
|
140
|
-
const baseB =
|
|
133
|
+
const baseA = await classA.baseClass;
|
|
134
|
+
const baseB = await classB.baseClass;
|
|
141
135
|
promises.push(this._reporter.reportBaseClassDelta(classA, baseA, baseB, this._compareDirection));
|
|
142
136
|
}
|
|
143
137
|
}
|
|
@@ -153,21 +147,6 @@ class SchemaComparer {
|
|
|
153
147
|
const promises = [];
|
|
154
148
|
if (!propertyB) {
|
|
155
149
|
promises.push(this._reporter.reportPropertyMissing(propertyA, this._compareDirection));
|
|
156
|
-
if (undefined !== propertyA.label)
|
|
157
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "label", propertyA.label, undefined, this._compareDirection));
|
|
158
|
-
if (undefined !== propertyA.description)
|
|
159
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "description", propertyA.description, undefined, this._compareDirection));
|
|
160
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "priority", propertyA.priority, undefined, this._compareDirection));
|
|
161
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "isReadOnly", propertyA.isReadOnly, undefined, this._compareDirection));
|
|
162
|
-
const catKeyA = propertyA.category ? (await propertyA.category).key : undefined;
|
|
163
|
-
const catKeyAText = catKeyA ? catKeyA.fullName : undefined;
|
|
164
|
-
if (undefined !== catKeyAText)
|
|
165
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "category", catKeyAText, undefined, this._compareDirection));
|
|
166
|
-
const koqKeyA = propertyA.kindOfQuantity ? (await propertyA.kindOfQuantity).key : undefined;
|
|
167
|
-
const koqKeyAText = koqKeyA ? koqKeyA.fullName : undefined;
|
|
168
|
-
if (undefined !== koqKeyAText)
|
|
169
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity", koqKeyAText, undefined, this._compareDirection));
|
|
170
|
-
await this.comparePropertyType(propertyA, undefined);
|
|
171
150
|
await Promise.all(promises);
|
|
172
151
|
return;
|
|
173
152
|
}
|
|
@@ -182,25 +161,21 @@ class SchemaComparer {
|
|
|
182
161
|
if (propertyA.priority !== propertyB.priority)
|
|
183
162
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "priority", propertyA.priority, propertyB.priority, this._compareDirection));
|
|
184
163
|
if (propertyA.category || propertyB.category) {
|
|
185
|
-
const catKeyA = propertyA.category
|
|
186
|
-
const catKeyB = propertyB.category
|
|
187
|
-
|
|
188
|
-
const catKeyBText = catKeyB ? catKeyB.fullName : undefined;
|
|
189
|
-
if (catKeyAText !== catKeyBText) {
|
|
164
|
+
const catKeyA = propertyA.category?.fullName;
|
|
165
|
+
const catKeyB = propertyB.category?.fullName;
|
|
166
|
+
if (catKeyA !== catKeyB) {
|
|
190
167
|
const areSameByName = this.areItemsSameByName(propertyA.category, propertyB.category, propertyA.schema.name, propertyB.schema.name);
|
|
191
168
|
if (!areSameByName)
|
|
192
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "category",
|
|
169
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "category", catKeyA, catKeyB, this._compareDirection));
|
|
193
170
|
}
|
|
194
171
|
}
|
|
195
172
|
if (propertyA.kindOfQuantity || propertyB.kindOfQuantity) {
|
|
196
|
-
const koqKeyA = propertyA.kindOfQuantity
|
|
197
|
-
const koqKeyB = propertyB.kindOfQuantity
|
|
198
|
-
|
|
199
|
-
const koqKeyBText = koqKeyB ? koqKeyB.fullName : undefined;
|
|
200
|
-
if (koqKeyAText !== koqKeyBText) {
|
|
173
|
+
const koqKeyA = propertyA.kindOfQuantity?.fullName;
|
|
174
|
+
const koqKeyB = propertyB.kindOfQuantity?.fullName;
|
|
175
|
+
if (koqKeyA !== koqKeyB) {
|
|
201
176
|
const areSameByName = this.areItemsSameByName(propertyA.kindOfQuantity, propertyB.kindOfQuantity, propertyA.schema.name, propertyB.schema.name);
|
|
202
177
|
if (!areSameByName)
|
|
203
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity",
|
|
178
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity", koqKeyA, koqKeyB, this._compareDirection));
|
|
204
179
|
}
|
|
205
180
|
}
|
|
206
181
|
promises.push(this.comparePropertyType(propertyA, propertyB));
|
|
@@ -213,9 +188,11 @@ class SchemaComparer {
|
|
|
213
188
|
*/
|
|
214
189
|
async compareEntityClasses(entityA, entityB) {
|
|
215
190
|
const promises = [];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
191
|
+
if (entityB) {
|
|
192
|
+
for (const mixinA of entityA.mixins) {
|
|
193
|
+
if (-1 === entityB.mixins.findIndex((mixinB) => this.areItemsSameByName(mixinA, mixinB, entityA.schema.name, entityB.schema.name)))
|
|
194
|
+
promises.push(this._reporter.reportEntityMixinMissing(entityA, await mixinA, this._compareDirection));
|
|
195
|
+
}
|
|
219
196
|
}
|
|
220
197
|
await Promise.all(promises);
|
|
221
198
|
}
|
|
@@ -225,13 +202,13 @@ class SchemaComparer {
|
|
|
225
202
|
* @param mixinB
|
|
226
203
|
*/
|
|
227
204
|
async compareMixins(mixinA, mixinB) {
|
|
228
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
205
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !mixinB)
|
|
229
206
|
return;
|
|
230
|
-
if (mixinA.appliesTo) {
|
|
231
|
-
const appliesToA = mixinA.appliesTo
|
|
232
|
-
const appliesToB = mixinB
|
|
207
|
+
if (mixinA.appliesTo || mixinB.appliesTo) {
|
|
208
|
+
const appliesToA = mixinA.appliesTo?.fullName;
|
|
209
|
+
const appliesToB = mixinB.appliesTo?.fullName;
|
|
233
210
|
if (appliesToA !== appliesToB) {
|
|
234
|
-
const areSameByName = this.areItemsSameByName(mixinA.appliesTo, mixinB
|
|
211
|
+
const areSameByName = this.areItemsSameByName(mixinA.appliesTo, mixinB.appliesTo, mixinA.schema.name, mixinB.schema.name);
|
|
235
212
|
if (!areSameByName)
|
|
236
213
|
await this._reporter.reportMixinDelta(mixinA, "appliesTo", appliesToA, appliesToB, this._compareDirection);
|
|
237
214
|
}
|
|
@@ -243,19 +220,17 @@ class SchemaComparer {
|
|
|
243
220
|
* @param relationshipB
|
|
244
221
|
*/
|
|
245
222
|
async compareRelationshipClasses(relationshipA, relationshipB) {
|
|
246
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
223
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !relationshipB)
|
|
247
224
|
return;
|
|
248
225
|
const promises = [];
|
|
249
|
-
|
|
250
|
-
if (relationshipA.strength !== strengthB) {
|
|
226
|
+
if (relationshipA.strength !== relationshipB.strength) {
|
|
251
227
|
const strengthAString = (0, ecschema_metadata_1.strengthToString)(relationshipA.strength);
|
|
252
|
-
const strengthBString =
|
|
228
|
+
const strengthBString = (0, ecschema_metadata_1.strengthToString)(relationshipB.strength);
|
|
253
229
|
promises.push(this._reporter.reportRelationshipClassDelta(relationshipA, "strength", strengthAString, strengthBString, this._compareDirection));
|
|
254
230
|
}
|
|
255
|
-
|
|
256
|
-
if (relationshipA.strengthDirection !== directionB) {
|
|
231
|
+
if (relationshipA.strengthDirection !== relationshipB.strengthDirection) {
|
|
257
232
|
const directionAString = (0, ecschema_metadata_1.strengthDirectionToString)(relationshipA.strengthDirection);
|
|
258
|
-
const directionBString =
|
|
233
|
+
const directionBString = (0, ecschema_metadata_1.strengthDirectionToString)(relationshipB.strengthDirection);
|
|
259
234
|
promises.push(this._reporter.reportRelationshipClassDelta(relationshipA, "strengthDirection", directionAString, directionBString, this._compareDirection));
|
|
260
235
|
}
|
|
261
236
|
await Promise.all(promises);
|
|
@@ -267,36 +242,31 @@ class SchemaComparer {
|
|
|
267
242
|
*/
|
|
268
243
|
async compareRelationshipConstraints(constraintA, constraintB) {
|
|
269
244
|
const promises = [];
|
|
270
|
-
if (constraintA.constraintClasses) {
|
|
245
|
+
if (constraintB && constraintA.constraintClasses) {
|
|
271
246
|
for (const classA of constraintA.constraintClasses) {
|
|
272
|
-
if (!constraintB ||
|
|
273
|
-
-1 === constraintB.constraintClasses.findIndex((classB) => this.areItemsSameByName(classA, classB, constraintA.schema.name, constraintB.schema.name)))
|
|
247
|
+
if (!constraintB.constraintClasses || -1 === constraintB.constraintClasses.findIndex((classB) => this.areItemsSameByName(classA, classB, constraintA.schema.name, constraintB.schema.name)))
|
|
274
248
|
promises.push(this._reporter.reportRelationshipConstraintClassMissing(constraintA, await classA, this._compareDirection));
|
|
275
249
|
}
|
|
276
250
|
}
|
|
277
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
251
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !constraintB) {
|
|
278
252
|
await Promise.all(promises);
|
|
279
253
|
return;
|
|
280
254
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
const multiplicityB = constraintBMultiplicity ? constraintBMultiplicity.toString() : undefined;
|
|
255
|
+
if (constraintA.multiplicity || constraintB.multiplicity) {
|
|
256
|
+
const multiplicityA = constraintA.multiplicity.toString();
|
|
257
|
+
const multiplicityB = constraintB.multiplicity.toString();
|
|
285
258
|
if (multiplicityA !== multiplicityB)
|
|
286
259
|
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "multiplicity", multiplicityA, multiplicityB, this._compareDirection));
|
|
287
260
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (constraintA.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (constraintA.abstractConstraint || constraintBAbstractConstraint) {
|
|
296
|
-
const abstractA = constraintA.abstractConstraint ? constraintA.abstractConstraint.fullName : undefined;
|
|
297
|
-
const abstractB = constraintBAbstractConstraint ? constraintBAbstractConstraint.fullName : undefined;
|
|
261
|
+
if (constraintA.roleLabel !== constraintB.roleLabel)
|
|
262
|
+
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "roleLabel", constraintA.roleLabel, constraintB.roleLabel, this._compareDirection));
|
|
263
|
+
if (constraintA.polymorphic !== constraintB.polymorphic)
|
|
264
|
+
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "polymorphic", constraintA.polymorphic, constraintB.polymorphic, this._compareDirection));
|
|
265
|
+
if (constraintA.abstractConstraint || constraintB.abstractConstraint) {
|
|
266
|
+
const abstractA = constraintA.abstractConstraint?.fullName;
|
|
267
|
+
const abstractB = constraintB.abstractConstraint?.fullName;
|
|
298
268
|
if (abstractA !== abstractB) {
|
|
299
|
-
const areSameByName = this.areItemsSameByName(constraintA.abstractConstraint,
|
|
269
|
+
const areSameByName = this.areItemsSameByName(constraintA.abstractConstraint, constraintB.abstractConstraint, constraintA.schema.name, constraintB.schema.name);
|
|
300
270
|
if (!areSameByName) {
|
|
301
271
|
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "abstractConstraint", abstractA, abstractB, this._compareDirection));
|
|
302
272
|
}
|
|
@@ -310,12 +280,11 @@ class SchemaComparer {
|
|
|
310
280
|
* @param customAttributeClassB
|
|
311
281
|
*/
|
|
312
282
|
async compareCustomAttributeClasses(customAttributeClassA, customAttributeClassB) {
|
|
313
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
283
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !customAttributeClassB)
|
|
314
284
|
return;
|
|
315
|
-
|
|
316
|
-
if (customAttributeClassA.containerType !== containerTypeB) {
|
|
285
|
+
if (customAttributeClassA.containerType !== customAttributeClassB.containerType) {
|
|
317
286
|
const typeA = (0, ecschema_metadata_1.containerTypeToString)(customAttributeClassA.containerType);
|
|
318
|
-
const typeB =
|
|
287
|
+
const typeB = (0, ecschema_metadata_1.containerTypeToString)(customAttributeClassB.containerType);
|
|
319
288
|
await this._reporter.reportCustomAttributeClassDelta(customAttributeClassA, "appliesTo", typeA, typeB, this._compareDirection);
|
|
320
289
|
}
|
|
321
290
|
}
|
|
@@ -326,10 +295,9 @@ class SchemaComparer {
|
|
|
326
295
|
*/
|
|
327
296
|
async compareCustomAttributeContainers(containerA, containerB) {
|
|
328
297
|
const promises = [];
|
|
329
|
-
if (containerA.customAttributes) {
|
|
298
|
+
if (containerB && containerA.customAttributes) {
|
|
330
299
|
for (const ca of containerA.customAttributes) {
|
|
331
|
-
|
|
332
|
-
if (!containerB || !containerB.customAttributes || !this.containerHasClass(caClassName, containerA, containerB))
|
|
300
|
+
if (!containerB.customAttributes || !this.containerHasClass(ca[1], containerA, containerB))
|
|
333
301
|
promises.push(this._reporter.reportCustomAttributeInstanceClassMissing(containerA, ca[1], this._compareDirection));
|
|
334
302
|
}
|
|
335
303
|
}
|
|
@@ -342,29 +310,28 @@ class SchemaComparer {
|
|
|
342
310
|
*/
|
|
343
311
|
async compareEnumerations(enumA, enumB) {
|
|
344
312
|
const promises = [];
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
313
|
+
if (enumB) {
|
|
314
|
+
for (const enumeratorA of enumA.enumerators) {
|
|
315
|
+
const enumeratorB = enumB.enumerators.find((e) => e.name === enumeratorA.name);
|
|
316
|
+
if (!enumeratorB) {
|
|
317
|
+
promises.push(this._reporter.reportEnumeratorMissing(enumA, enumeratorA, this._compareDirection));
|
|
318
|
+
}
|
|
319
|
+
else if (this._compareDirection === SchemaCompareDirection.Forward) {
|
|
320
|
+
promises.push(this.compareEnumerators(enumeratorA, enumeratorB, enumA, enumB));
|
|
321
|
+
}
|
|
353
322
|
}
|
|
354
323
|
}
|
|
355
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
324
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !enumB) {
|
|
356
325
|
await Promise.all(promises);
|
|
357
326
|
return;
|
|
358
327
|
}
|
|
359
|
-
|
|
360
|
-
if (enumA.type !== typeB) {
|
|
328
|
+
if (enumA.type !== enumB.type) {
|
|
361
329
|
const typeAString = enumA.type ? (0, ecschema_metadata_1.primitiveTypeToString)(enumA.type) : undefined;
|
|
362
|
-
const typeBString =
|
|
330
|
+
const typeBString = enumB.type ? (0, ecschema_metadata_1.primitiveTypeToString)(enumB.type) : undefined;
|
|
363
331
|
promises.push(this._reporter.reportEnumerationDelta(enumA, "type", typeAString, typeBString, this._compareDirection));
|
|
364
332
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
promises.push(this._reporter.reportEnumerationDelta(enumA, "isStrict", enumA.isStrict, isStrictB, this._compareDirection));
|
|
333
|
+
if (enumA.isStrict !== enumB.isStrict)
|
|
334
|
+
promises.push(this._reporter.reportEnumerationDelta(enumA, "isStrict", enumA.isStrict, enumB.isStrict, this._compareDirection));
|
|
368
335
|
await Promise.all(promises);
|
|
369
336
|
}
|
|
370
337
|
/**
|
|
@@ -374,26 +341,26 @@ class SchemaComparer {
|
|
|
374
341
|
*/
|
|
375
342
|
async compareKindOfQuantities(koqA, koqB) {
|
|
376
343
|
const promises = [];
|
|
377
|
-
if (koqA.presentationFormats) {
|
|
378
|
-
for (const
|
|
379
|
-
if (
|
|
380
|
-
promises.push(this._reporter.reportPresentationUnitMissing(koqA,
|
|
344
|
+
if (koqB && koqA.presentationFormats) {
|
|
345
|
+
for (const unitA of koqA.presentationFormats) {
|
|
346
|
+
if (-1 === koqB.presentationFormats.findIndex((unitB) => this.areOverrideFormatsSameByName(unitA, unitB, koqA.schema.name, koqB.schema.name)))
|
|
347
|
+
promises.push(this._reporter.reportPresentationUnitMissing(koqA, unitA, this._compareDirection));
|
|
381
348
|
}
|
|
382
349
|
}
|
|
383
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
350
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !koqB) {
|
|
384
351
|
await Promise.all(promises);
|
|
385
352
|
return;
|
|
386
353
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
promises.push(this._reporter.reportKoqDelta(koqA, "relativeError", koqA.relativeError, errorB, this._compareDirection));
|
|
354
|
+
if (koqA.relativeError !== koqB.relativeError) {
|
|
355
|
+
promises.push(this._reporter.reportKoqDelta(koqA, "relativeError", koqA.relativeError, koqB.relativeError, this._compareDirection));
|
|
390
356
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
const unitNameB = unitB ? unitB.fullName : undefined;
|
|
357
|
+
if (koqA.persistenceUnit || koqB.persistenceUnit) {
|
|
358
|
+
const unitNameA = koqA.persistenceUnit?.fullName;
|
|
359
|
+
const unitNameB = koqB.persistenceUnit?.fullName;
|
|
395
360
|
if (unitNameA !== unitNameB) {
|
|
396
|
-
|
|
361
|
+
const eqByName = this.areItemsSameByName(koqA.persistenceUnit, koqB.persistenceUnit, koqA.schema.name, koqB.schema.name);
|
|
362
|
+
if (!eqByName)
|
|
363
|
+
promises.push(this._reporter.reportKoqDelta(koqA, "persistenceUnit", unitNameA, unitNameB, this._compareDirection));
|
|
397
364
|
}
|
|
398
365
|
}
|
|
399
366
|
await Promise.all(promises);
|
|
@@ -404,11 +371,10 @@ class SchemaComparer {
|
|
|
404
371
|
* @param categoryB
|
|
405
372
|
*/
|
|
406
373
|
async comparePropertyCategories(categoryA, categoryB) {
|
|
407
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
374
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !categoryB)
|
|
408
375
|
return;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
await this._reporter.reportPropertyCategoryDelta(categoryA, "priority", categoryA.priority, priorityB, this._compareDirection);
|
|
376
|
+
if (categoryA.priority !== categoryB.priority)
|
|
377
|
+
await this._reporter.reportPropertyCategoryDelta(categoryA, "priority", categoryA.priority, categoryB.priority, this._compareDirection);
|
|
412
378
|
}
|
|
413
379
|
/**
|
|
414
380
|
* Compares two Format objects to identify differences between property values.
|
|
@@ -418,64 +384,50 @@ class SchemaComparer {
|
|
|
418
384
|
async compareFormats(formatA, formatB) {
|
|
419
385
|
const promises = [];
|
|
420
386
|
promises.push(this.compareFormatUnits(formatA, formatB));
|
|
421
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
387
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !formatB) {
|
|
422
388
|
await Promise.all(promises);
|
|
423
389
|
return;
|
|
424
390
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const typeB = formatB ? formatB.type : undefined;
|
|
429
|
-
if (formatA.type !== typeB) {
|
|
391
|
+
if (formatA.roundFactor !== formatB.roundFactor)
|
|
392
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "roundFactor", formatA.roundFactor, formatB.roundFactor, this._compareDirection));
|
|
393
|
+
if (formatA.type !== formatB.type) {
|
|
430
394
|
const typeAString = (0, core_quantity_1.formatTypeToString)(formatA.type);
|
|
431
|
-
const typeBString =
|
|
395
|
+
const typeBString = (0, core_quantity_1.formatTypeToString)(formatB.type);
|
|
432
396
|
promises.push(this._reporter.reportFormatDelta(formatA, "type", typeAString, typeBString, this._compareDirection));
|
|
433
397
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (formatA.
|
|
439
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "minWidth", formatA.minWidth, minWidthB, this._compareDirection));
|
|
440
|
-
const scientificTypeB = formatB ? formatB.scientificType : undefined;
|
|
441
|
-
if (formatA.scientificType !== scientificTypeB) {
|
|
398
|
+
if (formatA.precision !== formatB.precision)
|
|
399
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "precision", formatA.precision, formatB.precision, this._compareDirection));
|
|
400
|
+
if (formatA.minWidth !== formatB.minWidth)
|
|
401
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "minWidth", formatA.minWidth, formatB.minWidth, this._compareDirection));
|
|
402
|
+
if (formatA.scientificType !== formatB.scientificType) {
|
|
442
403
|
const typeAString = formatA.scientificType !== undefined ? (0, core_quantity_1.scientificTypeToString)(formatA.scientificType) : undefined;
|
|
443
|
-
const typeBString =
|
|
404
|
+
const typeBString = formatB.scientificType !== undefined ? (0, core_quantity_1.scientificTypeToString)(formatB.scientificType) : undefined;
|
|
444
405
|
promises.push(this._reporter.reportFormatDelta(formatA, "scientificType", typeAString, typeBString, this._compareDirection));
|
|
445
406
|
}
|
|
446
|
-
|
|
447
|
-
if (formatA.showSignOption !== showSignOptionB) {
|
|
407
|
+
if (formatA.showSignOption !== formatB.showSignOption) {
|
|
448
408
|
const optionA = (0, core_quantity_1.showSignOptionToString)(formatA.showSignOption);
|
|
449
|
-
const optionB =
|
|
409
|
+
const optionB = (0, core_quantity_1.showSignOptionToString)(formatB.showSignOption);
|
|
450
410
|
promises.push(this._reporter.reportFormatDelta(formatA, "showSignOption", optionA, optionB, this._compareDirection));
|
|
451
411
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (formatA.
|
|
457
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (formatA.
|
|
463
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "stationSeparator", formatA.stationSeparator, stationSeparatorB, this._compareDirection));
|
|
464
|
-
const stationOffsetSizeB = formatB ? formatB.stationOffsetSize : undefined;
|
|
465
|
-
if (formatA.stationOffsetSize !== stationOffsetSizeB)
|
|
466
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "stationOffsetSize", formatA.stationOffsetSize, stationOffsetSizeB, this._compareDirection));
|
|
467
|
-
const formatTraitsB = formatB ? formatB.formatTraits : undefined;
|
|
468
|
-
if (formatA.formatTraits !== formatTraitsB) {
|
|
412
|
+
if (formatA.decimalSeparator !== formatB.decimalSeparator)
|
|
413
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "decimalSeparator", formatA.decimalSeparator, formatB.decimalSeparator, this._compareDirection));
|
|
414
|
+
if (formatA.thousandSeparator !== formatB.thousandSeparator)
|
|
415
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "thousandSeparator", formatA.thousandSeparator, formatB.thousandSeparator, this._compareDirection));
|
|
416
|
+
if (formatA.uomSeparator !== formatB.uomSeparator)
|
|
417
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "uomSeparator", formatA.uomSeparator, formatB.uomSeparator, this._compareDirection));
|
|
418
|
+
if (formatA.stationSeparator !== formatB.stationSeparator)
|
|
419
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "stationSeparator", formatA.stationSeparator, formatB.stationSeparator, this._compareDirection));
|
|
420
|
+
if (formatA.stationOffsetSize !== formatB.stationOffsetSize)
|
|
421
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "stationOffsetSize", formatA.stationOffsetSize, formatB.stationOffsetSize, this._compareDirection));
|
|
422
|
+
if (formatA.formatTraits !== formatB.formatTraits) {
|
|
469
423
|
const traitsA = (0, core_quantity_1.formatTraitsToArray)(formatA.formatTraits);
|
|
470
|
-
const traitsB =
|
|
471
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "formatTraits", traitsA.toString(), traitsB
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if (formatA.includeZero !== includeZeroB)
|
|
478
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "includeZero", formatA.includeZero, includeZeroB, this._compareDirection));
|
|
424
|
+
const traitsB = (0, core_quantity_1.formatTraitsToArray)(formatB.formatTraits);
|
|
425
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "formatTraits", traitsA.toString(), traitsB.toString(), this._compareDirection));
|
|
426
|
+
}
|
|
427
|
+
if (formatA.spacer !== formatB.spacer)
|
|
428
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "spacer", formatA.spacer, formatB.spacer, this._compareDirection));
|
|
429
|
+
if (formatA.includeZero !== formatB.includeZero)
|
|
430
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "includeZero", formatA.includeZero, formatB.includeZero, this._compareDirection));
|
|
479
431
|
await Promise.all(promises);
|
|
480
432
|
}
|
|
481
433
|
/**
|
|
@@ -484,35 +436,35 @@ class SchemaComparer {
|
|
|
484
436
|
* @param unitB
|
|
485
437
|
*/
|
|
486
438
|
async compareUnits(unitA, unitB) {
|
|
487
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
439
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !unitB)
|
|
488
440
|
return;
|
|
489
441
|
const promises = [];
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (unitA.
|
|
509
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (unitA.offset !==
|
|
515
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "offset", unitA.offset,
|
|
442
|
+
if (unitA.phenomenon || unitB.phenomenon) {
|
|
443
|
+
const fullNameA = unitA.phenomenon?.fullName;
|
|
444
|
+
const fullNameB = unitB.phenomenon?.fullName;
|
|
445
|
+
if (fullNameA !== fullNameB) {
|
|
446
|
+
const eqByName = this.areItemsSameByName(unitA.phenomenon, unitB.phenomenon, unitA.schema.name, unitB.schema.name);
|
|
447
|
+
if (!eqByName)
|
|
448
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "phenomenon", fullNameA, fullNameB, this._compareDirection));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (unitA.unitSystem || unitB.unitSystem) {
|
|
452
|
+
const fullNameA = unitA.unitSystem?.fullName;
|
|
453
|
+
const fullNameB = unitB.unitSystem?.fullName;
|
|
454
|
+
if (fullNameA !== fullNameB) {
|
|
455
|
+
const eqByName = this.areItemsSameByName(unitA.unitSystem, unitB.unitSystem, unitA.schema.name, unitB.schema.name);
|
|
456
|
+
if (!eqByName)
|
|
457
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "unitSystem", fullNameA, fullNameB, this._compareDirection));
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (unitA.definition !== unitB.definition)
|
|
461
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "definition", unitA.definition, unitB.definition, this._compareDirection));
|
|
462
|
+
if (unitA.numerator !== unitB.numerator)
|
|
463
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "numerator", unitA.numerator, unitB.numerator, this._compareDirection));
|
|
464
|
+
if (unitA.denominator !== unitB.denominator)
|
|
465
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "denominator", unitA.denominator, unitB.denominator, this._compareDirection));
|
|
466
|
+
if (unitA.offset !== unitB.offset)
|
|
467
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "offset", unitA.offset, unitB.offset, this._compareDirection));
|
|
516
468
|
await Promise.all(promises);
|
|
517
469
|
}
|
|
518
470
|
/**
|
|
@@ -521,22 +473,26 @@ class SchemaComparer {
|
|
|
521
473
|
* @param invertedUnitB
|
|
522
474
|
*/
|
|
523
475
|
async compareInvertedUnits(invertedUnitA, invertedUnitB) {
|
|
524
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
476
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !invertedUnitB)
|
|
525
477
|
return;
|
|
526
478
|
const promises = [];
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
479
|
+
if (invertedUnitA.invertsUnit || invertedUnitB.invertsUnit) {
|
|
480
|
+
const fullNameA = invertedUnitA.invertsUnit?.fullName;
|
|
481
|
+
const fullNameB = invertedUnitB.invertsUnit?.fullName;
|
|
482
|
+
if (fullNameA !== fullNameB) {
|
|
483
|
+
const eqByName = this.areItemsSameByName(invertedUnitA.invertsUnit, invertedUnitB.invertsUnit, invertedUnitA.schema.name, invertedUnitB.schema.name);
|
|
484
|
+
if (!eqByName)
|
|
485
|
+
promises.push(this._reporter.reportInvertedUnitDelta(invertedUnitA, "invertsUnit", fullNameA, fullNameB, this._compareDirection));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (invertedUnitA.unitSystem || invertedUnitB.unitSystem) {
|
|
489
|
+
const fullNameA = invertedUnitA.unitSystem?.fullName;
|
|
490
|
+
const fullNameB = invertedUnitB.unitSystem?.fullName;
|
|
491
|
+
if (fullNameA !== fullNameB) {
|
|
492
|
+
const eqByName = this.areItemsSameByName(invertedUnitA.unitSystem, invertedUnitB.unitSystem, invertedUnitA.schema.name, invertedUnitB.schema.name);
|
|
493
|
+
if (!eqByName)
|
|
494
|
+
promises.push(this._reporter.reportInvertedUnitDelta(invertedUnitA, "unitSystem", fullNameA, fullNameB, this._compareDirection));
|
|
495
|
+
}
|
|
540
496
|
}
|
|
541
497
|
await Promise.all(promises);
|
|
542
498
|
}
|
|
@@ -546,11 +502,10 @@ class SchemaComparer {
|
|
|
546
502
|
* @param phenomenonB
|
|
547
503
|
*/
|
|
548
504
|
async comparePhenomenons(phenomenonA, phenomenonB) {
|
|
549
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
505
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !phenomenonB)
|
|
550
506
|
return;
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
await this._reporter.reportPhenomenonDelta(phenomenonA, "definition", phenomenonA.definition, definitionB, this._compareDirection);
|
|
507
|
+
if (phenomenonA.definition !== phenomenonB.definition)
|
|
508
|
+
await this._reporter.reportPhenomenonDelta(phenomenonA, "definition", phenomenonA.definition, phenomenonB.definition, this._compareDirection);
|
|
554
509
|
}
|
|
555
510
|
/**
|
|
556
511
|
* Compares two Constant objects to identify differences between property values.
|
|
@@ -558,51 +513,50 @@ class SchemaComparer {
|
|
|
558
513
|
* @param constantB
|
|
559
514
|
*/
|
|
560
515
|
async compareConstants(constantA, constantB) {
|
|
561
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
516
|
+
if (this._compareDirection === SchemaCompareDirection.Backward || !constantB)
|
|
562
517
|
return;
|
|
563
518
|
const promises = [];
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if (constantA.numerator !==
|
|
576
|
-
promises.push(this._reporter.reportConstantDelta(constantA, "numerator", constantA.numerator,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
promises.push(this._reporter.reportConstantDelta(constantA, "denominator", constantA.denominator, denominatorB, this._compareDirection));
|
|
519
|
+
if (constantA.phenomenon || constantB.phenomenon) {
|
|
520
|
+
const fullNameA = constantA.phenomenon?.fullName;
|
|
521
|
+
const fullNameB = constantB.phenomenon?.fullName;
|
|
522
|
+
if (fullNameA !== fullNameB) {
|
|
523
|
+
const eqByName = this.areItemsSameByName(constantA.phenomenon, constantB.phenomenon, constantA.schema.name, constantB.schema.name);
|
|
524
|
+
if (!eqByName)
|
|
525
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "phenomenon", fullNameA, fullNameB, this._compareDirection));
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (constantA.definition !== constantB.definition)
|
|
529
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "definition", constantA.definition, constantB.definition, this._compareDirection));
|
|
530
|
+
if (constantA.numerator !== constantB.numerator)
|
|
531
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "numerator", constantA.numerator, constantB.numerator, this._compareDirection));
|
|
532
|
+
if (constantA.denominator !== constantB.denominator)
|
|
533
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "denominator", constantA.denominator, constantB.denominator, this._compareDirection));
|
|
580
534
|
await Promise.all(promises);
|
|
581
535
|
}
|
|
582
536
|
async comparePropertyType(propertyA, propertyB) {
|
|
583
537
|
const promises = [];
|
|
584
538
|
const propertyTypeA = (0, ecschema_metadata_1.propertyTypeToString)(propertyA.propertyType);
|
|
585
|
-
const propertyTypeB =
|
|
539
|
+
const propertyTypeB = (0, ecschema_metadata_1.propertyTypeToString)(propertyB.propertyType);
|
|
586
540
|
if (propertyTypeA !== propertyTypeB) {
|
|
587
541
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "type", propertyTypeA, propertyTypeB, this._compareDirection));
|
|
588
542
|
}
|
|
589
543
|
if (propertyA.isArray()) {
|
|
590
|
-
const minOccursB = propertyB
|
|
544
|
+
const minOccursB = propertyB.isArray() ? propertyB.minOccurs : undefined;
|
|
591
545
|
if (propertyA.minOccurs !== minOccursB) {
|
|
592
546
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "minOccurs", propertyA.minOccurs, minOccursB, this._compareDirection));
|
|
593
547
|
}
|
|
594
|
-
const maxOccursB = propertyB
|
|
548
|
+
const maxOccursB = propertyB.isArray() ? propertyB.maxOccurs : undefined;
|
|
595
549
|
if (propertyA.maxOccurs !== maxOccursB) {
|
|
596
550
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "maxOccurs", propertyA.maxOccurs, maxOccursB, this._compareDirection));
|
|
597
551
|
}
|
|
598
552
|
}
|
|
599
553
|
if (propertyA.isEnumeration()) {
|
|
600
|
-
const enumerationB = propertyB
|
|
554
|
+
const enumerationB = propertyB.isEnumeration() ? propertyB.enumeration : undefined;
|
|
601
555
|
if (propertyA.enumeration || enumerationB) {
|
|
602
|
-
const enumA = propertyA.enumeration
|
|
603
|
-
const enumB = enumerationB
|
|
556
|
+
const enumA = propertyA.enumeration?.fullName;
|
|
557
|
+
const enumB = enumerationB?.fullName;
|
|
604
558
|
if (enumA !== enumB) {
|
|
605
|
-
const areSameByName = this.areItemsSameByName(propertyA.enumeration, enumerationB, propertyA.schema.name, propertyB
|
|
559
|
+
const areSameByName = this.areItemsSameByName(propertyA.enumeration, enumerationB, propertyA.schema.name, propertyB.schema.name);
|
|
606
560
|
if (!areSameByName) {
|
|
607
561
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "enumeration", enumA, enumB, this._compareDirection));
|
|
608
562
|
}
|
|
@@ -610,60 +564,60 @@ class SchemaComparer {
|
|
|
610
564
|
}
|
|
611
565
|
}
|
|
612
566
|
if (propertyA.isNavigation()) {
|
|
613
|
-
const strengthDirectionB = propertyB
|
|
567
|
+
const strengthDirectionB = propertyB.isNavigation() ? propertyB.direction : undefined;
|
|
614
568
|
if (propertyA.direction !== strengthDirectionB) {
|
|
615
569
|
const dirA = (0, ecschema_metadata_1.strengthDirectionToString)(propertyA.direction);
|
|
616
570
|
const dirB = strengthDirectionB !== undefined ? (0, ecschema_metadata_1.strengthDirectionToString)(strengthDirectionB) : undefined;
|
|
617
571
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "direction", dirA, dirB, this._compareDirection));
|
|
618
572
|
}
|
|
619
573
|
if (propertyA.relationshipClass) { // eslint-disable-line @typescript-eslint/no-misused-promises
|
|
620
|
-
const relationshipClassB = propertyB
|
|
574
|
+
const relationshipClassB = propertyB.isNavigation() ? propertyB.relationshipClass : undefined;
|
|
621
575
|
const relA = propertyA.relationshipClass.fullName;
|
|
622
576
|
const relB = relationshipClassB ? relationshipClassB.fullName : undefined;
|
|
623
577
|
if (relA !== relB) {
|
|
624
|
-
const areSameByName = this.areItemsSameByName(propertyA.relationshipClass, relationshipClassB, propertyA.schema.name, propertyB
|
|
578
|
+
const areSameByName = this.areItemsSameByName(propertyA.relationshipClass, relationshipClassB, propertyA.schema.name, propertyB.schema.name);
|
|
625
579
|
if (!areSameByName)
|
|
626
580
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "relationshipClass", relA, relB, this._compareDirection));
|
|
627
581
|
}
|
|
628
582
|
}
|
|
629
583
|
}
|
|
630
584
|
if (propertyA.isPrimitive()) {
|
|
631
|
-
const primitiveTypeB = propertyB
|
|
585
|
+
const primitiveTypeB = propertyB.isPrimitive() ? propertyB.primitiveType : undefined;
|
|
632
586
|
if (propertyA.primitiveType !== primitiveTypeB) {
|
|
633
587
|
const aType = (0, ecschema_metadata_1.primitiveTypeToString)(propertyA.primitiveType);
|
|
634
588
|
const bType = primitiveTypeB !== undefined ? (0, ecschema_metadata_1.primitiveTypeToString)(primitiveTypeB) : undefined;
|
|
635
589
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "primitiveType", aType, bType, this._compareDirection));
|
|
636
590
|
}
|
|
637
|
-
const minLengthB = propertyB
|
|
591
|
+
const minLengthB = propertyB.isPrimitive() ? propertyB.minLength : undefined;
|
|
638
592
|
if (propertyA.minLength !== minLengthB) {
|
|
639
593
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "minLength", propertyA.minLength, minLengthB, this._compareDirection));
|
|
640
594
|
}
|
|
641
595
|
// valid for primitive and enumeration properties
|
|
642
|
-
const maxLengthB = propertyB
|
|
596
|
+
const maxLengthB = propertyB.isPrimitive() ? propertyB.maxLength : undefined;
|
|
643
597
|
if (propertyA.maxLength !== maxLengthB) {
|
|
644
598
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "maxLength", propertyA.maxLength, maxLengthB, this._compareDirection));
|
|
645
599
|
}
|
|
646
|
-
const minValueB = propertyB
|
|
600
|
+
const minValueB = propertyB.isPrimitive() ? propertyB.minValue : undefined;
|
|
647
601
|
if (propertyA.minValue !== minValueB) {
|
|
648
602
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "minValue", propertyA.minValue, minValueB, this._compareDirection));
|
|
649
603
|
}
|
|
650
|
-
const maxValueB = propertyB
|
|
604
|
+
const maxValueB = propertyB.isPrimitive() ? propertyB.maxValue : undefined;
|
|
651
605
|
if (propertyA.maxValue !== maxValueB) {
|
|
652
606
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "maxValue", propertyA.maxValue, maxValueB, this._compareDirection));
|
|
653
607
|
}
|
|
654
|
-
const extendedTypeNameB = propertyB
|
|
608
|
+
const extendedTypeNameB = propertyB.isPrimitive() ? propertyB.extendedTypeName : undefined;
|
|
655
609
|
if (propertyA.extendedTypeName !== extendedTypeNameB) {
|
|
656
610
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "extendedTypeName", propertyA.extendedTypeName, extendedTypeNameB, this._compareDirection));
|
|
657
611
|
}
|
|
658
612
|
}
|
|
659
613
|
if (propertyA.isStruct()) {
|
|
660
614
|
const structA = propertyA.structClass;
|
|
661
|
-
const structB = propertyB
|
|
615
|
+
const structB = propertyB.isStruct() ? propertyB.structClass : undefined;
|
|
662
616
|
if (structA || structB) {
|
|
663
|
-
const structNameA = structA
|
|
664
|
-
const structNameB = structB
|
|
617
|
+
const structNameA = structA.fullName;
|
|
618
|
+
const structNameB = structB?.fullName;
|
|
665
619
|
if (structNameA !== structNameB) {
|
|
666
|
-
const areSameByName = this.areItemsSameByName(structA.key, structB?.key, propertyA.schema.name, propertyB
|
|
620
|
+
const areSameByName = this.areItemsSameByName(structA.key, structB?.key, propertyA.schema.name, propertyB.schema.name);
|
|
667
621
|
if (!areSameByName) {
|
|
668
622
|
promises.push(this._reporter.reportPropertyDelta(propertyA, "structClass", structNameA, structNameB, this._compareDirection));
|
|
669
623
|
}
|
|
@@ -674,13 +628,6 @@ class SchemaComparer {
|
|
|
674
628
|
}
|
|
675
629
|
async compareEnumerators(enumeratorA, enumeratorB, enumA, enumB) {
|
|
676
630
|
const promises = [];
|
|
677
|
-
if (!enumB || !enumeratorB) {
|
|
678
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "description", enumeratorA.description, undefined, this._compareDirection));
|
|
679
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "label", enumeratorA.label, undefined, this._compareDirection));
|
|
680
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "value", enumeratorA.value, undefined, this._compareDirection));
|
|
681
|
-
await Promise.all(promises);
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
631
|
if (enumeratorA.description !== enumeratorB.description)
|
|
685
632
|
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "description", enumeratorA.description, enumeratorB.description, this._compareDirection));
|
|
686
633
|
if (!labelsMatch(enumeratorA.label, enumeratorB.label))
|
|
@@ -691,16 +638,16 @@ class SchemaComparer {
|
|
|
691
638
|
await Promise.all(promises);
|
|
692
639
|
}
|
|
693
640
|
async compareFormatUnits(formatA, formatB) {
|
|
694
|
-
if (!formatA.units)
|
|
641
|
+
if (!formatA.units || !formatB)
|
|
695
642
|
return;
|
|
696
643
|
const promises = [];
|
|
697
644
|
for (const unitA of formatA.units) {
|
|
698
|
-
const unitB = formatB
|
|
645
|
+
const unitB = formatB.units ? formatB.units.find((u) => this.areItemsSameByName(unitA[0], u[0], formatA.schema.name, formatB.schema.name)) : undefined;
|
|
699
646
|
if (!unitB) {
|
|
700
647
|
promises.push(this._reporter.reportFormatUnitMissing(formatA, unitA[0], this._compareDirection));
|
|
701
648
|
continue;
|
|
702
649
|
}
|
|
703
|
-
if (this._compareDirection === SchemaCompareDirection.Backward
|
|
650
|
+
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
704
651
|
continue;
|
|
705
652
|
if (unitA[1] !== unitB[1]) {
|
|
706
653
|
const labelA = unitA[1];
|
|
@@ -710,6 +657,19 @@ class SchemaComparer {
|
|
|
710
657
|
}
|
|
711
658
|
await Promise.all(promises);
|
|
712
659
|
}
|
|
660
|
+
areOverrideFormatsSameByName(itemKeyA, itemKeyB, topLevelSchemaNameA, topLevelSchemaNameB) {
|
|
661
|
+
if (itemKeyA.units) {
|
|
662
|
+
for (const unitA of itemKeyA.units) {
|
|
663
|
+
if (!itemKeyB.units
|
|
664
|
+
|| -1 === itemKeyB.units.findIndex((unitB) => this.areItemsSameByName(unitA[0], unitB[0], topLevelSchemaNameA, topLevelSchemaNameB)
|
|
665
|
+
&& unitA[1] === unitB[1]))
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
const itemA = ecschema_metadata_1.OverrideFormat.isOverrideFormat(itemKeyA) ? itemKeyA.parent : itemKeyA;
|
|
670
|
+
const itemB = ecschema_metadata_1.OverrideFormat.isOverrideFormat(itemKeyB) ? itemKeyB.parent : itemKeyB;
|
|
671
|
+
return itemKeyA.precision === itemKeyB.precision && this.areItemsSameByName(itemA, itemB, topLevelSchemaNameA, topLevelSchemaNameB);
|
|
672
|
+
}
|
|
713
673
|
/**
|
|
714
674
|
* Compares two item keys.
|
|
715
675
|
* @param itemKeyA item key A to compare to.
|
|
@@ -721,8 +681,16 @@ class SchemaComparer {
|
|
|
721
681
|
areItemsSameByName(itemKeyA, itemKeyB, topLevelSchemaNameA, topLevelSchemaNameB) {
|
|
722
682
|
const nameA = itemKeyA ? itemKeyA.name : undefined;
|
|
723
683
|
const nameB = itemKeyB ? itemKeyB.name : undefined;
|
|
724
|
-
const schemaNameA = itemKeyA
|
|
725
|
-
|
|
684
|
+
const schemaNameA = itemKeyA
|
|
685
|
+
? ecschema_metadata_1.SchemaItem.isSchemaItem(itemKeyA)
|
|
686
|
+
? itemKeyA.schema.name
|
|
687
|
+
: itemKeyA.schemaName
|
|
688
|
+
: undefined;
|
|
689
|
+
const schemaNameB = itemKeyB
|
|
690
|
+
? ecschema_metadata_1.SchemaItem.isSchemaItem(itemKeyB)
|
|
691
|
+
? itemKeyB.schema.name
|
|
692
|
+
: itemKeyB.schemaName
|
|
693
|
+
: undefined;
|
|
726
694
|
return (nameA === nameB && schemaNameA === topLevelSchemaNameA && schemaNameB === topLevelSchemaNameB) || (nameA === nameB && schemaNameA === schemaNameB);
|
|
727
695
|
}
|
|
728
696
|
/**
|
|
@@ -732,13 +700,23 @@ class SchemaComparer {
|
|
|
732
700
|
* @param containerB container in which to look for classNameA.
|
|
733
701
|
* @returns true if a same classA is in containerB, otherwise false.
|
|
734
702
|
*/
|
|
735
|
-
containerHasClass(
|
|
703
|
+
containerHasClass(attributeA, containerA, containerB) {
|
|
736
704
|
if (containerB && containerB.customAttributes) {
|
|
737
705
|
for (const caB of containerB.customAttributes) {
|
|
738
|
-
const
|
|
739
|
-
const classItemKeyA = containerA.schema.getSchemaItemKey(
|
|
740
|
-
const classItemKeyB = containerB.schema.getSchemaItemKey(
|
|
741
|
-
|
|
706
|
+
const attributeB = caB[1];
|
|
707
|
+
const classItemKeyA = containerA.schema.getSchemaItemKey(attributeA.className);
|
|
708
|
+
const classItemKeyB = containerB.schema.getSchemaItemKey(attributeB.className);
|
|
709
|
+
if (this.areItemsSameByName(classItemKeyA, classItemKeyB, containerA.schema.name, containerB.schema.name)) {
|
|
710
|
+
return Object.keys(attributeA).every((property) => {
|
|
711
|
+
const propertyName = property.toString();
|
|
712
|
+
const valueA = attributeA[propertyName];
|
|
713
|
+
const valueB = attributeB[propertyName];
|
|
714
|
+
return propertyName === "className"
|
|
715
|
+
|| valueA === valueB
|
|
716
|
+
|| Array.isArray(valueA) && Array.isArray(valueB) && valueA.length === valueB.length
|
|
717
|
+
&& valueA.every((val, idx) => val === valueB[idx]);
|
|
718
|
+
});
|
|
719
|
+
}
|
|
742
720
|
}
|
|
743
721
|
}
|
|
744
722
|
return false;
|