@itwin/ecschema-editing 3.4.0-dev.56 → 3.4.0-dev.58
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/Constants.d.ts +20 -20
- package/lib/cjs/Editing/Constants.js +60 -60
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
- package/lib/cjs/Editing/CustomAttributes.js +59 -59
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +54 -54
- package/lib/cjs/Editing/ECClasses.js +269 -269
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +112 -112
- package/lib/cjs/Editing/Editor.js +166 -166
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +25 -25
- package/lib/cjs/Editing/Entities.js +116 -116
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +21 -21
- package/lib/cjs/Editing/Enumerations.js +66 -66
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts +21 -21
- package/lib/cjs/Editing/Formats.js +61 -61
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
- package/lib/cjs/Editing/InvertedUnits.js +82 -82
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
- package/lib/cjs/Editing/KindOfQuantities.js +78 -78
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +22 -22
- package/lib/cjs/Editing/Mixins.js +84 -84
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
- package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
- package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
- package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
- package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.d.ts +15 -15
- package/lib/cjs/Editing/Phenomena.js +44 -44
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
- package/lib/cjs/Editing/PropertyCategories.js +51 -51
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
- package/lib/cjs/Editing/RelationshipClasses.js +68 -68
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +19 -19
- package/lib/cjs/Editing/Structs.js +57 -57
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
- package/lib/cjs/Editing/UnitSystems.js +41 -41
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.d.ts +15 -15
- package/lib/cjs/Editing/Units.js +58 -58
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
- package/lib/cjs/Validation/Diagnostic.js +310 -310
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
- package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.d.ts +448 -448
- package/lib/cjs/Validation/ECRules.js +593 -593
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
- package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.d.ts +64 -64
- package/lib/cjs/Validation/Rules.js +9 -9
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
- package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
- package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
- package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
- package/lib/cjs/Validation/SchemaComparer.js +666 -666
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
- package/lib/cjs/Validation/SchemaValidater.js +61 -61
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
- package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
- package/lib/cjs/Validation/SchemaWalker.js +51 -51
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +33 -33
- package/lib/cjs/ecschema-editing.js +54 -54
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +10 -10
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -1,667 +1,667 @@
|
|
|
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 Comparison
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SchemaComparer = exports.SchemaCompareDirection = void 0;
|
|
11
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
-
const core_quantity_1 = require("@itwin/core-quantity");
|
|
13
|
-
const SchemaCompareResultDelegate_1 = require("./SchemaCompareResultDelegate");
|
|
14
|
-
const SchemaCompareVisitor_1 = require("./SchemaCompareVisitor");
|
|
15
|
-
const SchemaWalker_1 = require("./SchemaWalker");
|
|
16
|
-
/**
|
|
17
|
-
* Enum that identifies if Schema A is being iterated (Forward) or
|
|
18
|
-
* Schema B is being iterated (Backward);
|
|
19
|
-
* @alpha
|
|
20
|
-
*/
|
|
21
|
-
var SchemaCompareDirection;
|
|
22
|
-
(function (SchemaCompareDirection) {
|
|
23
|
-
SchemaCompareDirection[SchemaCompareDirection["Forward"] = 0] = "Forward";
|
|
24
|
-
SchemaCompareDirection[SchemaCompareDirection["Backward"] = 1] = "Backward";
|
|
25
|
-
})(SchemaCompareDirection = exports.SchemaCompareDirection || (exports.SchemaCompareDirection = {}));
|
|
26
|
-
function labelsMatch(label1, label2) {
|
|
27
|
-
label1 = label1 === undefined ? "" : label1;
|
|
28
|
-
label2 = label2 === undefined ? "" : label2;
|
|
29
|
-
return label1 === label2;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Compares EC Schemas and reports differences using the [[IDiagnosticReporter]] objects
|
|
33
|
-
* specified.
|
|
34
|
-
* @alpha
|
|
35
|
-
*/
|
|
36
|
-
class SchemaComparer {
|
|
37
|
-
/**
|
|
38
|
-
* Initializes a new SchemaComparer instance.
|
|
39
|
-
* @param reporters The [[IDiagnosticReporter]] object(s) to use to report the results.
|
|
40
|
-
*/
|
|
41
|
-
constructor(...reporters) {
|
|
42
|
-
this._compareDirection = SchemaCompareDirection.Forward;
|
|
43
|
-
this._reporters = reporters;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Compares two schemas to identify differences.
|
|
47
|
-
* @param schemaA The first Schema.
|
|
48
|
-
* @param schemaB The second Schema.
|
|
49
|
-
*/
|
|
50
|
-
async compareSchemas(schemaA, schemaB) {
|
|
51
|
-
this._reporter = new SchemaCompareResultDelegate_1.SchemaCompareResultDelegate(schemaA, schemaB, ...this._reporters);
|
|
52
|
-
let visitor = new SchemaCompareVisitor_1.SchemaCompareVisitor(this, schemaB);
|
|
53
|
-
let walker = new SchemaWalker_1.SchemaWalker(visitor);
|
|
54
|
-
await walker.traverseSchema(schemaA);
|
|
55
|
-
this._compareDirection = SchemaCompareDirection.Backward;
|
|
56
|
-
visitor = new SchemaCompareVisitor_1.SchemaCompareVisitor(this, schemaA);
|
|
57
|
-
walker = new SchemaWalker_1.SchemaWalker(visitor);
|
|
58
|
-
await walker.traverseSchema(schemaB);
|
|
59
|
-
this._compareDirection = SchemaCompareDirection.Forward;
|
|
60
|
-
this._reporter.compareComplete();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Compares two schemas to identify differences between property values.
|
|
64
|
-
* @param schemaA The first Schema.
|
|
65
|
-
* @param schemaB The second Schema.
|
|
66
|
-
*/
|
|
67
|
-
async compareSchemaProps(schemaA, schemaB) {
|
|
68
|
-
const promises = [];
|
|
69
|
-
for (const ref of schemaA.references) {
|
|
70
|
-
const refB = await schemaB.getReference(ref.fullName);
|
|
71
|
-
if (!refB)
|
|
72
|
-
promises.push(this._reporter.reportSchemaReferenceMissing(schemaA, ref, this._compareDirection));
|
|
73
|
-
else if (!refB.schemaKey.matches(ref.schemaKey))
|
|
74
|
-
promises.push(this._reporter.reportSchemaReferenceDelta(schemaA, ref, ref.schemaKey.version.toString(), refB.schemaKey.version.toString(), this._compareDirection));
|
|
75
|
-
}
|
|
76
|
-
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
77
|
-
return;
|
|
78
|
-
if (schemaA.schemaKey.toString() !== schemaB.schemaKey.toString())
|
|
79
|
-
promises.push(this._reporter.reportSchemaDelta(schemaA, "schemaKey", schemaA.schemaKey.toString(), schemaB.schemaKey.toString(), this._compareDirection));
|
|
80
|
-
if (schemaA.alias !== schemaB.alias)
|
|
81
|
-
promises.push(this._reporter.reportSchemaDelta(schemaA, "alias", schemaA.alias, schemaB.alias, this._compareDirection));
|
|
82
|
-
if (schemaA.description !== schemaB.description)
|
|
83
|
-
promises.push(this._reporter.reportSchemaDelta(schemaA, "description", schemaA.description, schemaB.description, this._compareDirection));
|
|
84
|
-
if (schemaA.label !== schemaB.label)
|
|
85
|
-
promises.push(this._reporter.reportSchemaDelta(schemaA, "label", schemaA.label, schemaB.label, this._compareDirection));
|
|
86
|
-
await Promise.all(promises);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Compares two SchemaItems to identify differences between property values.
|
|
90
|
-
* @param schemaItemA The first SchemaItem.
|
|
91
|
-
* @param schemaItemB The second SchemaItem.
|
|
92
|
-
*/
|
|
93
|
-
async compareSchemaItems(schemaItemA, schemaItemB) {
|
|
94
|
-
const promises = [];
|
|
95
|
-
if (!schemaItemB) {
|
|
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", (0, ecschema_metadata_1.schemaItemTypeToString)(schemaItemA.schemaItemType), undefined, this._compareDirection));
|
|
100
|
-
await Promise.all(promises);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
104
|
-
return;
|
|
105
|
-
if (schemaItemA.description !== schemaItemB.description)
|
|
106
|
-
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "description", schemaItemA.description, schemaItemB.description, this._compareDirection));
|
|
107
|
-
if (!labelsMatch(schemaItemA.label, schemaItemB.label))
|
|
108
|
-
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "label", schemaItemA.label, schemaItemB.label, this._compareDirection));
|
|
109
|
-
if (schemaItemA.schemaItemType !== schemaItemB.schemaItemType) {
|
|
110
|
-
const aType = (0, ecschema_metadata_1.schemaItemTypeToString)(schemaItemA.schemaItemType);
|
|
111
|
-
const bType = (0, ecschema_metadata_1.schemaItemTypeToString)(schemaItemB.schemaItemType);
|
|
112
|
-
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "schemaItemType", aType, bType, this._compareDirection));
|
|
113
|
-
}
|
|
114
|
-
await Promise.all(promises);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Compares two ECClasses to identify differences between property values.
|
|
118
|
-
* @param classA The first ECClass.
|
|
119
|
-
* @param classB The second ECClass.
|
|
120
|
-
*/
|
|
121
|
-
async compareClasses(classA, classB) {
|
|
122
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && classB)
|
|
123
|
-
return;
|
|
124
|
-
const promises = [];
|
|
125
|
-
const modifierB = classB ? classB.modifier : undefined;
|
|
126
|
-
if (classA.modifier !== modifierB) {
|
|
127
|
-
const aMod = (0, ecschema_metadata_1.classModifierToString)(classA.modifier);
|
|
128
|
-
const bMod = modifierB !== undefined ? (0, ecschema_metadata_1.classModifierToString)(modifierB) : undefined;
|
|
129
|
-
promises.push(this._reporter.reportClassDelta(classA, "modifier", aMod, bMod, this._compareDirection));
|
|
130
|
-
}
|
|
131
|
-
const baseClassB = classB ? classB.baseClass : undefined;
|
|
132
|
-
if (classA.baseClass || baseClassB) {
|
|
133
|
-
const nameA = classA.baseClass ? classA.baseClass.fullName : undefined;
|
|
134
|
-
const nameB = baseClassB ? baseClassB.fullName : undefined;
|
|
135
|
-
if (nameA !== nameB) {
|
|
136
|
-
const baseA = await classA.baseClass;
|
|
137
|
-
const baseB = baseClassB ? await baseClassB : undefined;
|
|
138
|
-
promises.push(this._reporter.reportBaseClassDelta(classA, baseA, baseB, this._compareDirection));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
await Promise.all(promises);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Compares two ECProperties to identify differences between property values.
|
|
145
|
-
* @param propertyA The first ECProperty.
|
|
146
|
-
* @param propertyB The second ECProperty.
|
|
147
|
-
*/
|
|
148
|
-
async compareProperties(propertyA, propertyB) {
|
|
149
|
-
const promises = [];
|
|
150
|
-
if (!propertyB) {
|
|
151
|
-
promises.push(this._reporter.reportPropertyMissing(propertyA, this._compareDirection));
|
|
152
|
-
if (undefined !== propertyA.label)
|
|
153
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "label", propertyA.label, undefined, this._compareDirection));
|
|
154
|
-
if (undefined !== propertyA.description)
|
|
155
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "description", propertyA.description, undefined, this._compareDirection));
|
|
156
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "priority", propertyA.priority, undefined, this._compareDirection));
|
|
157
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "isReadOnly", propertyA.isReadOnly, undefined, this._compareDirection));
|
|
158
|
-
const catKeyA = propertyA.category ? (await propertyA.category).key : undefined;
|
|
159
|
-
const catKeyAText = catKeyA ? catKeyA.fullName : undefined;
|
|
160
|
-
if (undefined !== catKeyAText)
|
|
161
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "category", catKeyAText, undefined, this._compareDirection));
|
|
162
|
-
const koqKeyA = propertyA.kindOfQuantity ? (await propertyA.kindOfQuantity).key : undefined;
|
|
163
|
-
const koqKeyAText = koqKeyA ? koqKeyA.fullName : undefined;
|
|
164
|
-
if (undefined !== koqKeyAText)
|
|
165
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity", koqKeyAText, undefined, this._compareDirection));
|
|
166
|
-
await this.comparePropertyType(propertyA, undefined);
|
|
167
|
-
await Promise.all(promises);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
171
|
-
return;
|
|
172
|
-
if (!labelsMatch(propertyA.label, propertyB.label))
|
|
173
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "label", propertyA.label, propertyB.label, this._compareDirection));
|
|
174
|
-
if (propertyA.description !== propertyB.description)
|
|
175
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "description", propertyA.description, propertyB.description, this._compareDirection));
|
|
176
|
-
if (propertyA.isReadOnly !== propertyB.isReadOnly)
|
|
177
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "isReadOnly", propertyA.isReadOnly, propertyB.isReadOnly, this._compareDirection));
|
|
178
|
-
if (propertyA.priority !== propertyB.priority)
|
|
179
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "priority", propertyA.priority, propertyB.priority, this._compareDirection));
|
|
180
|
-
if (propertyA.category || propertyB.category) {
|
|
181
|
-
const catKeyA = propertyA.category ? (await propertyA.category).key : undefined;
|
|
182
|
-
const catKeyB = propertyB.category ? (await propertyB.category).key : undefined;
|
|
183
|
-
const catKeyAText = catKeyA ? catKeyA.fullName : undefined;
|
|
184
|
-
const catKeyBText = catKeyB ? catKeyB.fullName : undefined;
|
|
185
|
-
if (catKeyAText !== catKeyBText) {
|
|
186
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "category", catKeyAText, catKeyBText, this._compareDirection));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (propertyA.kindOfQuantity || propertyB.kindOfQuantity) {
|
|
190
|
-
const koqKeyA = propertyA.kindOfQuantity ? (await propertyA.kindOfQuantity).key : undefined;
|
|
191
|
-
const koqKeyB = propertyB.kindOfQuantity ? (await propertyB.kindOfQuantity).key : undefined;
|
|
192
|
-
const koqKeyAText = koqKeyA ? koqKeyA.fullName : undefined;
|
|
193
|
-
const koqKeyBText = koqKeyB ? koqKeyB.fullName : undefined;
|
|
194
|
-
if (koqKeyAText !== koqKeyBText) {
|
|
195
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity", koqKeyAText, koqKeyBText, this._compareDirection));
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
promises.push(this.comparePropertyType(propertyA, propertyB));
|
|
199
|
-
await Promise.all(promises);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Compares two EntityClass objects to identify differences between property values.
|
|
203
|
-
* @param entityA
|
|
204
|
-
* @param entityB
|
|
205
|
-
*/
|
|
206
|
-
async compareEntityClasses(entityA, entityB) {
|
|
207
|
-
const promises = [];
|
|
208
|
-
for (const mixinA of entityA.mixins) {
|
|
209
|
-
if (!entityB || -1 === entityB.mixins.findIndex((m) => m.fullName === mixinA.fullName))
|
|
210
|
-
promises.push(this._reporter.reportEntityMixinMissing(entityA, await mixinA, this._compareDirection));
|
|
211
|
-
}
|
|
212
|
-
await Promise.all(promises);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Compares two Mixin objects to identify differences between property values.
|
|
216
|
-
* @param mixinA
|
|
217
|
-
* @param mixinB
|
|
218
|
-
*/
|
|
219
|
-
async compareMixins(mixinA, mixinB) {
|
|
220
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && mixinB)
|
|
221
|
-
return;
|
|
222
|
-
if (mixinA.appliesTo) {
|
|
223
|
-
const appliesToA = mixinA.appliesTo.fullName;
|
|
224
|
-
const appliesToB = mixinB ? mixinB.appliesTo ? mixinB.appliesTo.fullName : undefined : undefined;
|
|
225
|
-
if (appliesToA !== appliesToB)
|
|
226
|
-
await this._reporter.reportMixinDelta(mixinA, "appliesTo", appliesToA, appliesToB, this._compareDirection);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Compares two RelationshipClass objects to identify differences between property values.
|
|
231
|
-
* @param relationshipA
|
|
232
|
-
* @param relationshipB
|
|
233
|
-
*/
|
|
234
|
-
async compareRelationshipClasses(relationshipA, relationshipB) {
|
|
235
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && relationshipB)
|
|
236
|
-
return;
|
|
237
|
-
const promises = [];
|
|
238
|
-
const strengthB = relationshipB ? relationshipB.strength : undefined;
|
|
239
|
-
if (relationshipA.strength !== strengthB) {
|
|
240
|
-
const strengthAString = (0, ecschema_metadata_1.strengthToString)(relationshipA.strength);
|
|
241
|
-
const strengthBString = strengthB !== undefined ? (0, ecschema_metadata_1.strengthToString)(strengthB) : undefined;
|
|
242
|
-
promises.push(this._reporter.reportRelationshipClassDelta(relationshipA, "strength", strengthAString, strengthBString, this._compareDirection));
|
|
243
|
-
}
|
|
244
|
-
const directionB = relationshipB ? relationshipB.strengthDirection : undefined;
|
|
245
|
-
if (relationshipA.strengthDirection !== directionB) {
|
|
246
|
-
const directionAString = (0, ecschema_metadata_1.strengthDirectionToString)(relationshipA.strengthDirection);
|
|
247
|
-
const directionBString = directionB !== undefined ? (0, ecschema_metadata_1.strengthDirectionToString)(directionB) : undefined;
|
|
248
|
-
promises.push(this._reporter.reportRelationshipClassDelta(relationshipA, "strengthDirection", directionAString, directionBString, this._compareDirection));
|
|
249
|
-
}
|
|
250
|
-
await Promise.all(promises);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Compares two RelationshipConstraint objects to identify differences between property values.
|
|
254
|
-
* @param relationshipConstraintA
|
|
255
|
-
* @param relationshipConstraintB
|
|
256
|
-
*/
|
|
257
|
-
async compareRelationshipConstraints(constraintA, constraintB) {
|
|
258
|
-
const promises = [];
|
|
259
|
-
if (constraintA.constraintClasses) {
|
|
260
|
-
for (const classA of constraintA.constraintClasses) {
|
|
261
|
-
if (!constraintB || !constraintB.constraintClasses || -1 === constraintB.constraintClasses.findIndex((c) => c.matchesFullName(classA.fullName)))
|
|
262
|
-
promises.push(this._reporter.reportRelationshipConstraintClassMissing(constraintA, await classA, this._compareDirection));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && constraintB) {
|
|
266
|
-
await Promise.all(promises);
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const constraintBMultiplicity = constraintB ? constraintB.multiplicity : undefined;
|
|
270
|
-
if (constraintA.multiplicity || constraintBMultiplicity) {
|
|
271
|
-
const multiplicityA = constraintA.multiplicity ? constraintA.multiplicity.toString() : undefined;
|
|
272
|
-
const multiplicityB = constraintBMultiplicity ? constraintBMultiplicity.toString() : undefined;
|
|
273
|
-
if (multiplicityA !== multiplicityB)
|
|
274
|
-
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "multiplicity", multiplicityA, multiplicityB, this._compareDirection));
|
|
275
|
-
}
|
|
276
|
-
const constraintBRoleLabel = constraintB ? constraintB.roleLabel : undefined;
|
|
277
|
-
if (constraintA.roleLabel !== constraintBRoleLabel)
|
|
278
|
-
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "roleLabel", constraintA.roleLabel, constraintBRoleLabel, this._compareDirection));
|
|
279
|
-
const constraintBPolymorphic = constraintB ? constraintB.polymorphic : undefined;
|
|
280
|
-
if (constraintA.polymorphic !== constraintBPolymorphic)
|
|
281
|
-
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "polymorphic", constraintA.polymorphic, constraintBPolymorphic, this._compareDirection));
|
|
282
|
-
const constraintBAbstractConstraint = constraintB ? constraintB.abstractConstraint : undefined;
|
|
283
|
-
if (constraintA.abstractConstraint || constraintBAbstractConstraint) {
|
|
284
|
-
const abstractA = constraintA.abstractConstraint ? constraintA.abstractConstraint.fullName : undefined;
|
|
285
|
-
const abstractB = constraintBAbstractConstraint ? constraintBAbstractConstraint.fullName : undefined;
|
|
286
|
-
if (abstractA !== abstractB) {
|
|
287
|
-
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "abstractConstraint", abstractA, abstractB, this._compareDirection));
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
await Promise.all(promises);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Compares two CustomAttributeClass objects to identify differences between property values.
|
|
294
|
-
* @param customAttributeClassA
|
|
295
|
-
* @param customAttributeClassB
|
|
296
|
-
*/
|
|
297
|
-
async compareCustomAttributeClasses(customAttributeClassA, customAttributeClassB) {
|
|
298
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && customAttributeClassB)
|
|
299
|
-
return;
|
|
300
|
-
const containerTypeB = customAttributeClassB ? customAttributeClassB.containerType : undefined;
|
|
301
|
-
if (customAttributeClassA.containerType !== containerTypeB) {
|
|
302
|
-
const typeA = (0, ecschema_metadata_1.containerTypeToString)(customAttributeClassA.containerType);
|
|
303
|
-
const typeB = containerTypeB !== undefined ? (0, ecschema_metadata_1.containerTypeToString)(containerTypeB) : undefined;
|
|
304
|
-
await this._reporter.reportCustomAttributeClassDelta(customAttributeClassA, "appliesTo", typeA, typeB, this._compareDirection);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Compares two CustomAttributeContainerProps objects to identify differences between property values.
|
|
309
|
-
* @param containerA
|
|
310
|
-
* @param containerB
|
|
311
|
-
*/
|
|
312
|
-
async compareCustomAttributeContainers(containerA, containerB) {
|
|
313
|
-
const promises = [];
|
|
314
|
-
if (containerA.customAttributes) {
|
|
315
|
-
for (const ca of containerA.customAttributes) {
|
|
316
|
-
if (!containerB || !containerB.customAttributes || !containerB.customAttributes.has(ca[0]))
|
|
317
|
-
promises.push(this._reporter.reportCustomAttributeInstanceClassMissing(containerA, ca[1], this._compareDirection));
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
await Promise.all(promises);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Compares two Enumeration objects to identify differences between property values.
|
|
324
|
-
* @param enumA
|
|
325
|
-
* @param enumB
|
|
326
|
-
*/
|
|
327
|
-
async compareEnumerations(enumA, enumB) {
|
|
328
|
-
const promises = [];
|
|
329
|
-
for (const enumeratorA of enumA.enumerators) {
|
|
330
|
-
const enumeratorB = enumB ? enumB.enumerators.find((e) => e.name === enumeratorA.name) : undefined;
|
|
331
|
-
if (!enumeratorB) {
|
|
332
|
-
promises.push(this._reporter.reportEnumeratorMissing(enumA, enumeratorA, this._compareDirection));
|
|
333
|
-
promises.push(this.compareEnumerators(enumeratorA, enumeratorB, enumA, enumB));
|
|
334
|
-
}
|
|
335
|
-
else if (this._compareDirection === SchemaCompareDirection.Forward) {
|
|
336
|
-
promises.push(this.compareEnumerators(enumeratorA, enumeratorB, enumA, enumB));
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && enumB) {
|
|
340
|
-
await Promise.all(promises);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
const typeB = enumB ? enumB.type : undefined;
|
|
344
|
-
if (enumA.type !== typeB) {
|
|
345
|
-
const typeAString = enumA.type ? (0, ecschema_metadata_1.primitiveTypeToString)(enumA.type) : undefined;
|
|
346
|
-
const typeBString = typeB !== undefined ? (0, ecschema_metadata_1.primitiveTypeToString)(typeB) : undefined;
|
|
347
|
-
promises.push(this._reporter.reportEnumerationDelta(enumA, "type", typeAString, typeBString, this._compareDirection));
|
|
348
|
-
}
|
|
349
|
-
const isStrictB = enumB ? enumB.isStrict : undefined;
|
|
350
|
-
if (enumA.isStrict !== isStrictB)
|
|
351
|
-
promises.push(this._reporter.reportEnumerationDelta(enumA, "isStrict", enumA.isStrict, isStrictB, this._compareDirection));
|
|
352
|
-
await Promise.all(promises);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Compares two KindOfQuantity objects to identify differences between property values.
|
|
356
|
-
* @param koqA
|
|
357
|
-
* @param koqB
|
|
358
|
-
*/
|
|
359
|
-
async compareKindOfQuantities(koqA, koqB) {
|
|
360
|
-
const promises = [];
|
|
361
|
-
if (koqA.presentationFormats) {
|
|
362
|
-
for (const unit of koqA.presentationFormats) {
|
|
363
|
-
if (!koqB || !koqB.presentationFormats || -1 === koqB.presentationFormats.findIndex((u) => u.fullName === unit.fullName))
|
|
364
|
-
promises.push(this._reporter.reportPresentationUnitMissing(koqA, unit, this._compareDirection));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && koqB) {
|
|
368
|
-
await Promise.all(promises);
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const errorB = koqB ? koqB.relativeError : undefined;
|
|
372
|
-
if (koqA.relativeError !== errorB) {
|
|
373
|
-
promises.push(this._reporter.reportKoqDelta(koqA, "relativeError", koqA.relativeError, errorB, this._compareDirection));
|
|
374
|
-
}
|
|
375
|
-
const unitB = koqB ? koqB.persistenceUnit : undefined;
|
|
376
|
-
if (koqA.persistenceUnit || unitB) {
|
|
377
|
-
const unitNameA = koqA.persistenceUnit ? koqA.persistenceUnit.fullName : undefined;
|
|
378
|
-
const unitNameB = unitB ? unitB.fullName : undefined;
|
|
379
|
-
if (unitNameA !== unitNameB) {
|
|
380
|
-
promises.push(this._reporter.reportKoqDelta(koqA, "persistenceUnit", unitNameA, unitNameB, this._compareDirection));
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
await Promise.all(promises);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Compares two PropertyCategory objects to identify differences between property values.
|
|
387
|
-
* @param categoryA
|
|
388
|
-
* @param categoryB
|
|
389
|
-
*/
|
|
390
|
-
async comparePropertyCategories(categoryA, categoryB) {
|
|
391
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && categoryB)
|
|
392
|
-
return;
|
|
393
|
-
const priorityB = categoryB ? categoryB.priority : undefined;
|
|
394
|
-
if (categoryA.priority !== priorityB)
|
|
395
|
-
await this._reporter.reportPropertyCategoryDelta(categoryA, "priority", categoryA.priority, priorityB, this._compareDirection);
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Compares two Format objects to identify differences between property values.
|
|
399
|
-
* @param formatA
|
|
400
|
-
* @param formatB
|
|
401
|
-
*/
|
|
402
|
-
async compareFormats(formatA, formatB) {
|
|
403
|
-
const promises = [];
|
|
404
|
-
promises.push(this.compareFormatUnits(formatA, formatB));
|
|
405
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && formatB) {
|
|
406
|
-
await Promise.all(promises);
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
const roundFactorB = formatB ? formatB.roundFactor : undefined;
|
|
410
|
-
if (formatA.roundFactor !== roundFactorB)
|
|
411
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "roundFactor", formatA.roundFactor, roundFactorB, this._compareDirection));
|
|
412
|
-
const typeB = formatB ? formatB.type : undefined;
|
|
413
|
-
if (formatA.type !== typeB) {
|
|
414
|
-
const typeAString = (0, core_quantity_1.formatTypeToString)(formatA.type);
|
|
415
|
-
const typeBString = typeB !== undefined ? (0, core_quantity_1.formatTypeToString)(typeB) : undefined;
|
|
416
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "type", typeAString, typeBString, this._compareDirection));
|
|
417
|
-
}
|
|
418
|
-
const precisionB = formatB ? formatB.precision : undefined;
|
|
419
|
-
if (formatA.precision !== precisionB)
|
|
420
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "precision", formatA.precision, precisionB, this._compareDirection));
|
|
421
|
-
const minWidthB = formatB ? formatB.minWidth : undefined;
|
|
422
|
-
if (formatA.minWidth !== minWidthB)
|
|
423
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "minWidth", formatA.minWidth, minWidthB, this._compareDirection));
|
|
424
|
-
const scientificTypeB = formatB ? formatB.scientificType : undefined;
|
|
425
|
-
if (formatA.scientificType !== scientificTypeB) {
|
|
426
|
-
const typeAString = formatA.scientificType !== undefined ? (0, core_quantity_1.scientificTypeToString)(formatA.scientificType) : undefined;
|
|
427
|
-
const typeBString = scientificTypeB !== undefined ? (0, core_quantity_1.scientificTypeToString)(scientificTypeB) : undefined;
|
|
428
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "scientificType", typeAString, typeBString, this._compareDirection));
|
|
429
|
-
}
|
|
430
|
-
const showSignOptionB = formatB ? formatB.showSignOption : undefined;
|
|
431
|
-
if (formatA.showSignOption !== showSignOptionB) {
|
|
432
|
-
const optionA = (0, core_quantity_1.showSignOptionToString)(formatA.showSignOption);
|
|
433
|
-
const optionB = showSignOptionB !== undefined ? (0, core_quantity_1.showSignOptionToString)(showSignOptionB) : undefined;
|
|
434
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "showSignOption", optionA, optionB, this._compareDirection));
|
|
435
|
-
}
|
|
436
|
-
const decimalSeparatorB = formatB ? formatB.decimalSeparator : undefined;
|
|
437
|
-
if (formatA.decimalSeparator !== decimalSeparatorB)
|
|
438
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "decimalSeparator", formatA.decimalSeparator, decimalSeparatorB, this._compareDirection));
|
|
439
|
-
const thousandSeparatorB = formatB ? formatB.thousandSeparator : undefined;
|
|
440
|
-
if (formatA.thousandSeparator !== thousandSeparatorB)
|
|
441
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "thousandSeparator", formatA.thousandSeparator, thousandSeparatorB, this._compareDirection));
|
|
442
|
-
const uomSeparatorB = formatB ? formatB.uomSeparator : undefined;
|
|
443
|
-
if (formatA.uomSeparator !== uomSeparatorB)
|
|
444
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "uomSeparator", formatA.uomSeparator, uomSeparatorB, this._compareDirection));
|
|
445
|
-
const stationSeparatorB = formatB ? formatB.stationSeparator : undefined;
|
|
446
|
-
if (formatA.stationSeparator !== stationSeparatorB)
|
|
447
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "stationSeparator", formatA.stationSeparator, stationSeparatorB, this._compareDirection));
|
|
448
|
-
const stationOffsetSizeB = formatB ? formatB.stationOffsetSize : undefined;
|
|
449
|
-
if (formatA.stationOffsetSize !== stationOffsetSizeB)
|
|
450
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "stationOffsetSize", formatA.stationOffsetSize, stationOffsetSizeB, this._compareDirection));
|
|
451
|
-
const formatTraitsB = formatB ? formatB.formatTraits : undefined;
|
|
452
|
-
if (formatA.formatTraits !== formatTraitsB) {
|
|
453
|
-
const traitsA = (0, core_quantity_1.formatTraitsToArray)(formatA.formatTraits);
|
|
454
|
-
const traitsB = formatTraitsB !== undefined ? (0, core_quantity_1.formatTraitsToArray)(formatTraitsB) : undefined;
|
|
455
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "formatTraits", traitsA.toString(), traitsB ? traitsB.toString() : undefined, this._compareDirection));
|
|
456
|
-
}
|
|
457
|
-
const spacerB = formatB ? formatB.spacer : undefined;
|
|
458
|
-
if (formatA.spacer !== spacerB)
|
|
459
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "spacer", formatA.spacer, spacerB, this._compareDirection));
|
|
460
|
-
const includeZeroB = formatB ? formatB.includeZero : undefined;
|
|
461
|
-
if (formatA.includeZero !== includeZeroB)
|
|
462
|
-
promises.push(this._reporter.reportFormatDelta(formatA, "includeZero", formatA.includeZero, includeZeroB, this._compareDirection));
|
|
463
|
-
await Promise.all(promises);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Compares two Unit objects to identify differences between property values.
|
|
467
|
-
* @param unitA
|
|
468
|
-
* @param unitB
|
|
469
|
-
*/
|
|
470
|
-
async compareUnits(unitA, unitB) {
|
|
471
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && unitB)
|
|
472
|
-
return;
|
|
473
|
-
const promises = [];
|
|
474
|
-
const phenomenonB = unitB ? unitB.phenomenon : undefined;
|
|
475
|
-
if (unitA.phenomenon || phenomenonB) {
|
|
476
|
-
const fullNameA = unitA.phenomenon ? unitA.phenomenon.fullName : undefined;
|
|
477
|
-
const fullNameB = phenomenonB ? phenomenonB.fullName : undefined;
|
|
478
|
-
if (fullNameA !== fullNameB)
|
|
479
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "phenomenon", fullNameA, fullNameB, this._compareDirection));
|
|
480
|
-
}
|
|
481
|
-
const unitSystemB = unitB ? unitB.unitSystem : undefined;
|
|
482
|
-
if (unitA.unitSystem || unitSystemB) {
|
|
483
|
-
const fullNameA = unitA.unitSystem ? unitA.unitSystem.fullName : undefined;
|
|
484
|
-
const fullNameB = unitSystemB ? unitSystemB.fullName : undefined;
|
|
485
|
-
if (fullNameA !== fullNameB)
|
|
486
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "unitSystem", fullNameA, fullNameB, this._compareDirection));
|
|
487
|
-
}
|
|
488
|
-
const definitionB = unitB ? unitB.definition : undefined;
|
|
489
|
-
if (unitA.definition !== definitionB)
|
|
490
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "definition", unitA.definition, definitionB, this._compareDirection));
|
|
491
|
-
const numeratorB = unitB ? unitB.numerator : undefined;
|
|
492
|
-
if (unitA.numerator !== numeratorB)
|
|
493
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "numerator", unitA.numerator, numeratorB, this._compareDirection));
|
|
494
|
-
const denominatorB = unitB ? unitB.denominator : undefined;
|
|
495
|
-
if (unitA.denominator !== denominatorB)
|
|
496
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "denominator", unitA.denominator, denominatorB, this._compareDirection));
|
|
497
|
-
const offsetB = unitB ? unitB.offset : undefined;
|
|
498
|
-
if (unitA.offset !== offsetB)
|
|
499
|
-
promises.push(this._reporter.reportUnitDelta(unitA, "offset", unitA.offset, offsetB, this._compareDirection));
|
|
500
|
-
await Promise.all(promises);
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Compares two InvertedUnit objects to identify differences between property values.
|
|
504
|
-
* @param invertedUnitA
|
|
505
|
-
* @param invertedUnitB
|
|
506
|
-
*/
|
|
507
|
-
async compareInvertedUnits(invertedUnitA, invertedUnitB) {
|
|
508
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && invertedUnitB)
|
|
509
|
-
return;
|
|
510
|
-
const promises = [];
|
|
511
|
-
const invertsUnitB = invertedUnitB ? invertedUnitB.invertsUnit : undefined;
|
|
512
|
-
if (invertedUnitA.invertsUnit || invertsUnitB) {
|
|
513
|
-
const fullNameA = invertedUnitA.invertsUnit ? invertedUnitA.invertsUnit.fullName : undefined;
|
|
514
|
-
const fullNameB = invertsUnitB ? invertsUnitB.fullName : undefined;
|
|
515
|
-
if (fullNameA !== fullNameB)
|
|
516
|
-
promises.push(this._reporter.reportInvertedUnitDelta(invertedUnitA, "invertsUnit", fullNameA, fullNameB, this._compareDirection));
|
|
517
|
-
}
|
|
518
|
-
const unitSystemB = invertedUnitB ? invertedUnitB.unitSystem : undefined;
|
|
519
|
-
if (invertedUnitA.unitSystem || unitSystemB) {
|
|
520
|
-
const fullNameA = invertedUnitA.unitSystem ? invertedUnitA.unitSystem.fullName : undefined;
|
|
521
|
-
const fullNameB = unitSystemB ? unitSystemB.fullName : undefined;
|
|
522
|
-
if (fullNameA !== fullNameB)
|
|
523
|
-
promises.push(this._reporter.reportInvertedUnitDelta(invertedUnitA, "unitSystem", fullNameA, fullNameB, this._compareDirection));
|
|
524
|
-
}
|
|
525
|
-
await Promise.all(promises);
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Compares two Phenomenon objects to identify differences between property values.
|
|
529
|
-
* @param phenomenonA
|
|
530
|
-
* @param phenomenonB
|
|
531
|
-
*/
|
|
532
|
-
async comparePhenomenons(phenomenonA, phenomenonB) {
|
|
533
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && phenomenonB)
|
|
534
|
-
return;
|
|
535
|
-
const definitionB = phenomenonB ? phenomenonB.definition : undefined;
|
|
536
|
-
if (phenomenonA.definition !== definitionB)
|
|
537
|
-
await this._reporter.reportPhenomenonDelta(phenomenonA, "definition", phenomenonA.definition, definitionB, this._compareDirection);
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Compares two Constant objects to identify differences between property values.
|
|
541
|
-
* @param constantA
|
|
542
|
-
* @param constantB
|
|
543
|
-
*/
|
|
544
|
-
async compareConstants(constantA, constantB) {
|
|
545
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && constantB)
|
|
546
|
-
return;
|
|
547
|
-
const promises = [];
|
|
548
|
-
const phenomenonB = constantB ? constantB.phenomenon : undefined;
|
|
549
|
-
if (constantA.phenomenon || phenomenonB) {
|
|
550
|
-
const fullNameA = constantA.phenomenon ? constantA.phenomenon.fullName : undefined;
|
|
551
|
-
const fullNameB = phenomenonB ? phenomenonB.fullName : undefined;
|
|
552
|
-
if (fullNameA !== fullNameB)
|
|
553
|
-
promises.push(this._reporter.reportConstantDelta(constantA, "phenomenon", fullNameA, fullNameB, this._compareDirection));
|
|
554
|
-
}
|
|
555
|
-
const definitionB = constantB ? constantB.definition : undefined;
|
|
556
|
-
if (constantA.definition !== definitionB)
|
|
557
|
-
promises.push(this._reporter.reportConstantDelta(constantA, "definition", constantA.definition, definitionB, this._compareDirection));
|
|
558
|
-
const numeratorB = constantB ? constantB.numerator : undefined;
|
|
559
|
-
if (constantA.numerator !== numeratorB)
|
|
560
|
-
promises.push(this._reporter.reportConstantDelta(constantA, "numerator", constantA.numerator, numeratorB, this._compareDirection));
|
|
561
|
-
const denominatorB = constantB ? constantB.denominator : undefined;
|
|
562
|
-
if (constantA.denominator !== denominatorB)
|
|
563
|
-
promises.push(this._reporter.reportConstantDelta(constantA, "denominator", constantA.denominator, denominatorB, this._compareDirection));
|
|
564
|
-
await Promise.all(promises);
|
|
565
|
-
}
|
|
566
|
-
async comparePropertyType(propertyA, propertyB) {
|
|
567
|
-
const promises = [];
|
|
568
|
-
const propertyTypeA = (0, ecschema_metadata_1.propertyTypeToString)(propertyA.propertyType);
|
|
569
|
-
const propertyTypeB = propertyB !== undefined ? (0, ecschema_metadata_1.propertyTypeToString)(propertyB.propertyType) : undefined;
|
|
570
|
-
if (propertyTypeA !== propertyTypeB) {
|
|
571
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "type", propertyTypeA, propertyTypeB, this._compareDirection));
|
|
572
|
-
}
|
|
573
|
-
if (propertyA.isArray()) {
|
|
574
|
-
const minOccursB = propertyB && propertyB.isArray() ? propertyB.minOccurs : undefined;
|
|
575
|
-
if (propertyA.minOccurs !== minOccursB) {
|
|
576
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "minOccurs", propertyA.minOccurs, minOccursB, this._compareDirection));
|
|
577
|
-
}
|
|
578
|
-
const maxOccursB = propertyB && propertyB.isArray() ? propertyB.maxOccurs : undefined;
|
|
579
|
-
if (propertyA.maxOccurs !== maxOccursB) {
|
|
580
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "maxOccurs", propertyA.maxOccurs, maxOccursB, this._compareDirection));
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
if (propertyA.isEnumeration()) {
|
|
584
|
-
const enumerationB = propertyB && propertyB.isEnumeration() ? propertyB.enumeration : undefined;
|
|
585
|
-
if (propertyA.enumeration || enumerationB) {
|
|
586
|
-
const enumA = propertyA.enumeration ? propertyA.enumeration.fullName : undefined;
|
|
587
|
-
const enumB = enumerationB ? enumerationB.fullName : undefined;
|
|
588
|
-
if (enumA !== enumB)
|
|
589
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "enumeration", enumA, enumB, this._compareDirection));
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if (propertyA.isNavigation()) {
|
|
593
|
-
const strengthDirectionB = propertyB && propertyB.isNavigation() ? propertyB.direction : undefined;
|
|
594
|
-
if (propertyA.direction !== strengthDirectionB) {
|
|
595
|
-
const dirA = (0, ecschema_metadata_1.strengthDirectionToString)(propertyA.direction);
|
|
596
|
-
const dirB = strengthDirectionB !== undefined ? (0, ecschema_metadata_1.strengthDirectionToString)(strengthDirectionB) : undefined;
|
|
597
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "direction", dirA, dirB, this._compareDirection));
|
|
598
|
-
}
|
|
599
|
-
if (propertyA.relationshipClass) { // eslint-disable-line @typescript-eslint/no-misused-promises
|
|
600
|
-
const relationshipClassB = propertyB && propertyB.isNavigation() ? propertyB.relationshipClass : undefined;
|
|
601
|
-
const relA = propertyA.relationshipClass.fullName;
|
|
602
|
-
const relB = relationshipClassB ? relationshipClassB.fullName : undefined;
|
|
603
|
-
if (relA !== relB)
|
|
604
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "relationshipClass", relA, relB, this._compareDirection));
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
if (propertyA.isPrimitive()) {
|
|
608
|
-
const primitiveTypeB = propertyB && propertyB.isPrimitive() ? propertyB.primitiveType : undefined;
|
|
609
|
-
if (propertyA.primitiveType !== primitiveTypeB) {
|
|
610
|
-
const aType = (0, ecschema_metadata_1.primitiveTypeToString)(propertyA.primitiveType);
|
|
611
|
-
const bType = primitiveTypeB !== undefined ? (0, ecschema_metadata_1.primitiveTypeToString)(primitiveTypeB) : undefined;
|
|
612
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "primitiveType", aType, bType, this._compareDirection));
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
if (propertyA.isStruct()) {
|
|
616
|
-
const structA = propertyA.structClass;
|
|
617
|
-
const structB = propertyB && propertyB.isStruct() ? propertyB.structClass : undefined;
|
|
618
|
-
if (structA || structB) {
|
|
619
|
-
const structNameA = structA ? structA.fullName : undefined;
|
|
620
|
-
const structNameB = structB ? structB.fullName : undefined;
|
|
621
|
-
if (structNameA !== structNameB)
|
|
622
|
-
promises.push(this._reporter.reportPropertyDelta(propertyA, "structClass", structNameA, structNameB, this._compareDirection));
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
await Promise.all(promises);
|
|
626
|
-
}
|
|
627
|
-
async compareEnumerators(enumeratorA, enumeratorB, enumA, enumB) {
|
|
628
|
-
const promises = [];
|
|
629
|
-
if (!enumB || !enumeratorB) {
|
|
630
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "description", enumeratorA.description, undefined, this._compareDirection));
|
|
631
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "label", enumeratorA.label, undefined, this._compareDirection));
|
|
632
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "value", enumeratorA.value, undefined, this._compareDirection));
|
|
633
|
-
await Promise.all(promises);
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (enumeratorA.description !== enumeratorB.description)
|
|
637
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "description", enumeratorA.description, enumeratorB.description, this._compareDirection));
|
|
638
|
-
if (!labelsMatch(enumeratorA.label, enumeratorB.label))
|
|
639
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "label", enumeratorA.label, enumeratorB.label, this._compareDirection));
|
|
640
|
-
// No need to compare values if the type is different (which will be reported separately)
|
|
641
|
-
if (enumA.type === enumB.type && enumeratorA.value !== enumeratorB.value)
|
|
642
|
-
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "value", enumeratorA.value, enumeratorB.value, this._compareDirection));
|
|
643
|
-
await Promise.all(promises);
|
|
644
|
-
}
|
|
645
|
-
async compareFormatUnits(formatA, formatB) {
|
|
646
|
-
if (!formatA.units)
|
|
647
|
-
return;
|
|
648
|
-
const promises = [];
|
|
649
|
-
for (const unitA of formatA.units) {
|
|
650
|
-
const unitB = formatB && formatB.units ? formatB.units.find((u) => u[0].fullName === unitA[0].fullName) : undefined;
|
|
651
|
-
if (!unitB) {
|
|
652
|
-
promises.push(this._reporter.reportFormatUnitMissing(formatA, unitA[0], this._compareDirection));
|
|
653
|
-
continue;
|
|
654
|
-
}
|
|
655
|
-
if (this._compareDirection === SchemaCompareDirection.Backward && formatB)
|
|
656
|
-
continue;
|
|
657
|
-
if (unitA[1] !== unitB[1]) {
|
|
658
|
-
const labelA = unitA[1];
|
|
659
|
-
const labelB = unitB[1];
|
|
660
|
-
promises.push(this._reporter.reportUnitLabelOverrideDelta(formatA, unitB[0], labelA, labelB, this._compareDirection));
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
await Promise.all(promises);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
exports.SchemaComparer = SchemaComparer;
|
|
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 Comparison
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SchemaComparer = exports.SchemaCompareDirection = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const core_quantity_1 = require("@itwin/core-quantity");
|
|
13
|
+
const SchemaCompareResultDelegate_1 = require("./SchemaCompareResultDelegate");
|
|
14
|
+
const SchemaCompareVisitor_1 = require("./SchemaCompareVisitor");
|
|
15
|
+
const SchemaWalker_1 = require("./SchemaWalker");
|
|
16
|
+
/**
|
|
17
|
+
* Enum that identifies if Schema A is being iterated (Forward) or
|
|
18
|
+
* Schema B is being iterated (Backward);
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
21
|
+
var SchemaCompareDirection;
|
|
22
|
+
(function (SchemaCompareDirection) {
|
|
23
|
+
SchemaCompareDirection[SchemaCompareDirection["Forward"] = 0] = "Forward";
|
|
24
|
+
SchemaCompareDirection[SchemaCompareDirection["Backward"] = 1] = "Backward";
|
|
25
|
+
})(SchemaCompareDirection = exports.SchemaCompareDirection || (exports.SchemaCompareDirection = {}));
|
|
26
|
+
function labelsMatch(label1, label2) {
|
|
27
|
+
label1 = label1 === undefined ? "" : label1;
|
|
28
|
+
label2 = label2 === undefined ? "" : label2;
|
|
29
|
+
return label1 === label2;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Compares EC Schemas and reports differences using the [[IDiagnosticReporter]] objects
|
|
33
|
+
* specified.
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
class SchemaComparer {
|
|
37
|
+
/**
|
|
38
|
+
* Initializes a new SchemaComparer instance.
|
|
39
|
+
* @param reporters The [[IDiagnosticReporter]] object(s) to use to report the results.
|
|
40
|
+
*/
|
|
41
|
+
constructor(...reporters) {
|
|
42
|
+
this._compareDirection = SchemaCompareDirection.Forward;
|
|
43
|
+
this._reporters = reporters;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compares two schemas to identify differences.
|
|
47
|
+
* @param schemaA The first Schema.
|
|
48
|
+
* @param schemaB The second Schema.
|
|
49
|
+
*/
|
|
50
|
+
async compareSchemas(schemaA, schemaB) {
|
|
51
|
+
this._reporter = new SchemaCompareResultDelegate_1.SchemaCompareResultDelegate(schemaA, schemaB, ...this._reporters);
|
|
52
|
+
let visitor = new SchemaCompareVisitor_1.SchemaCompareVisitor(this, schemaB);
|
|
53
|
+
let walker = new SchemaWalker_1.SchemaWalker(visitor);
|
|
54
|
+
await walker.traverseSchema(schemaA);
|
|
55
|
+
this._compareDirection = SchemaCompareDirection.Backward;
|
|
56
|
+
visitor = new SchemaCompareVisitor_1.SchemaCompareVisitor(this, schemaA);
|
|
57
|
+
walker = new SchemaWalker_1.SchemaWalker(visitor);
|
|
58
|
+
await walker.traverseSchema(schemaB);
|
|
59
|
+
this._compareDirection = SchemaCompareDirection.Forward;
|
|
60
|
+
this._reporter.compareComplete();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Compares two schemas to identify differences between property values.
|
|
64
|
+
* @param schemaA The first Schema.
|
|
65
|
+
* @param schemaB The second Schema.
|
|
66
|
+
*/
|
|
67
|
+
async compareSchemaProps(schemaA, schemaB) {
|
|
68
|
+
const promises = [];
|
|
69
|
+
for (const ref of schemaA.references) {
|
|
70
|
+
const refB = await schemaB.getReference(ref.fullName);
|
|
71
|
+
if (!refB)
|
|
72
|
+
promises.push(this._reporter.reportSchemaReferenceMissing(schemaA, ref, this._compareDirection));
|
|
73
|
+
else if (!refB.schemaKey.matches(ref.schemaKey))
|
|
74
|
+
promises.push(this._reporter.reportSchemaReferenceDelta(schemaA, ref, ref.schemaKey.version.toString(), refB.schemaKey.version.toString(), this._compareDirection));
|
|
75
|
+
}
|
|
76
|
+
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
77
|
+
return;
|
|
78
|
+
if (schemaA.schemaKey.toString() !== schemaB.schemaKey.toString())
|
|
79
|
+
promises.push(this._reporter.reportSchemaDelta(schemaA, "schemaKey", schemaA.schemaKey.toString(), schemaB.schemaKey.toString(), this._compareDirection));
|
|
80
|
+
if (schemaA.alias !== schemaB.alias)
|
|
81
|
+
promises.push(this._reporter.reportSchemaDelta(schemaA, "alias", schemaA.alias, schemaB.alias, this._compareDirection));
|
|
82
|
+
if (schemaA.description !== schemaB.description)
|
|
83
|
+
promises.push(this._reporter.reportSchemaDelta(schemaA, "description", schemaA.description, schemaB.description, this._compareDirection));
|
|
84
|
+
if (schemaA.label !== schemaB.label)
|
|
85
|
+
promises.push(this._reporter.reportSchemaDelta(schemaA, "label", schemaA.label, schemaB.label, this._compareDirection));
|
|
86
|
+
await Promise.all(promises);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Compares two SchemaItems to identify differences between property values.
|
|
90
|
+
* @param schemaItemA The first SchemaItem.
|
|
91
|
+
* @param schemaItemB The second SchemaItem.
|
|
92
|
+
*/
|
|
93
|
+
async compareSchemaItems(schemaItemA, schemaItemB) {
|
|
94
|
+
const promises = [];
|
|
95
|
+
if (!schemaItemB) {
|
|
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", (0, ecschema_metadata_1.schemaItemTypeToString)(schemaItemA.schemaItemType), undefined, this._compareDirection));
|
|
100
|
+
await Promise.all(promises);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
104
|
+
return;
|
|
105
|
+
if (schemaItemA.description !== schemaItemB.description)
|
|
106
|
+
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "description", schemaItemA.description, schemaItemB.description, this._compareDirection));
|
|
107
|
+
if (!labelsMatch(schemaItemA.label, schemaItemB.label))
|
|
108
|
+
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "label", schemaItemA.label, schemaItemB.label, this._compareDirection));
|
|
109
|
+
if (schemaItemA.schemaItemType !== schemaItemB.schemaItemType) {
|
|
110
|
+
const aType = (0, ecschema_metadata_1.schemaItemTypeToString)(schemaItemA.schemaItemType);
|
|
111
|
+
const bType = (0, ecschema_metadata_1.schemaItemTypeToString)(schemaItemB.schemaItemType);
|
|
112
|
+
promises.push(this._reporter.reportSchemaItemDelta(schemaItemA, "schemaItemType", aType, bType, this._compareDirection));
|
|
113
|
+
}
|
|
114
|
+
await Promise.all(promises);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Compares two ECClasses to identify differences between property values.
|
|
118
|
+
* @param classA The first ECClass.
|
|
119
|
+
* @param classB The second ECClass.
|
|
120
|
+
*/
|
|
121
|
+
async compareClasses(classA, classB) {
|
|
122
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && classB)
|
|
123
|
+
return;
|
|
124
|
+
const promises = [];
|
|
125
|
+
const modifierB = classB ? classB.modifier : undefined;
|
|
126
|
+
if (classA.modifier !== modifierB) {
|
|
127
|
+
const aMod = (0, ecschema_metadata_1.classModifierToString)(classA.modifier);
|
|
128
|
+
const bMod = modifierB !== undefined ? (0, ecschema_metadata_1.classModifierToString)(modifierB) : undefined;
|
|
129
|
+
promises.push(this._reporter.reportClassDelta(classA, "modifier", aMod, bMod, this._compareDirection));
|
|
130
|
+
}
|
|
131
|
+
const baseClassB = classB ? classB.baseClass : undefined;
|
|
132
|
+
if (classA.baseClass || baseClassB) {
|
|
133
|
+
const nameA = classA.baseClass ? classA.baseClass.fullName : undefined;
|
|
134
|
+
const nameB = baseClassB ? baseClassB.fullName : undefined;
|
|
135
|
+
if (nameA !== nameB) {
|
|
136
|
+
const baseA = await classA.baseClass;
|
|
137
|
+
const baseB = baseClassB ? await baseClassB : undefined;
|
|
138
|
+
promises.push(this._reporter.reportBaseClassDelta(classA, baseA, baseB, this._compareDirection));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
await Promise.all(promises);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Compares two ECProperties to identify differences between property values.
|
|
145
|
+
* @param propertyA The first ECProperty.
|
|
146
|
+
* @param propertyB The second ECProperty.
|
|
147
|
+
*/
|
|
148
|
+
async compareProperties(propertyA, propertyB) {
|
|
149
|
+
const promises = [];
|
|
150
|
+
if (!propertyB) {
|
|
151
|
+
promises.push(this._reporter.reportPropertyMissing(propertyA, this._compareDirection));
|
|
152
|
+
if (undefined !== propertyA.label)
|
|
153
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "label", propertyA.label, undefined, this._compareDirection));
|
|
154
|
+
if (undefined !== propertyA.description)
|
|
155
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "description", propertyA.description, undefined, this._compareDirection));
|
|
156
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "priority", propertyA.priority, undefined, this._compareDirection));
|
|
157
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "isReadOnly", propertyA.isReadOnly, undefined, this._compareDirection));
|
|
158
|
+
const catKeyA = propertyA.category ? (await propertyA.category).key : undefined;
|
|
159
|
+
const catKeyAText = catKeyA ? catKeyA.fullName : undefined;
|
|
160
|
+
if (undefined !== catKeyAText)
|
|
161
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "category", catKeyAText, undefined, this._compareDirection));
|
|
162
|
+
const koqKeyA = propertyA.kindOfQuantity ? (await propertyA.kindOfQuantity).key : undefined;
|
|
163
|
+
const koqKeyAText = koqKeyA ? koqKeyA.fullName : undefined;
|
|
164
|
+
if (undefined !== koqKeyAText)
|
|
165
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity", koqKeyAText, undefined, this._compareDirection));
|
|
166
|
+
await this.comparePropertyType(propertyA, undefined);
|
|
167
|
+
await Promise.all(promises);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (this._compareDirection === SchemaCompareDirection.Backward)
|
|
171
|
+
return;
|
|
172
|
+
if (!labelsMatch(propertyA.label, propertyB.label))
|
|
173
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "label", propertyA.label, propertyB.label, this._compareDirection));
|
|
174
|
+
if (propertyA.description !== propertyB.description)
|
|
175
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "description", propertyA.description, propertyB.description, this._compareDirection));
|
|
176
|
+
if (propertyA.isReadOnly !== propertyB.isReadOnly)
|
|
177
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "isReadOnly", propertyA.isReadOnly, propertyB.isReadOnly, this._compareDirection));
|
|
178
|
+
if (propertyA.priority !== propertyB.priority)
|
|
179
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "priority", propertyA.priority, propertyB.priority, this._compareDirection));
|
|
180
|
+
if (propertyA.category || propertyB.category) {
|
|
181
|
+
const catKeyA = propertyA.category ? (await propertyA.category).key : undefined;
|
|
182
|
+
const catKeyB = propertyB.category ? (await propertyB.category).key : undefined;
|
|
183
|
+
const catKeyAText = catKeyA ? catKeyA.fullName : undefined;
|
|
184
|
+
const catKeyBText = catKeyB ? catKeyB.fullName : undefined;
|
|
185
|
+
if (catKeyAText !== catKeyBText) {
|
|
186
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "category", catKeyAText, catKeyBText, this._compareDirection));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (propertyA.kindOfQuantity || propertyB.kindOfQuantity) {
|
|
190
|
+
const koqKeyA = propertyA.kindOfQuantity ? (await propertyA.kindOfQuantity).key : undefined;
|
|
191
|
+
const koqKeyB = propertyB.kindOfQuantity ? (await propertyB.kindOfQuantity).key : undefined;
|
|
192
|
+
const koqKeyAText = koqKeyA ? koqKeyA.fullName : undefined;
|
|
193
|
+
const koqKeyBText = koqKeyB ? koqKeyB.fullName : undefined;
|
|
194
|
+
if (koqKeyAText !== koqKeyBText) {
|
|
195
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "kindOfQuantity", koqKeyAText, koqKeyBText, this._compareDirection));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
promises.push(this.comparePropertyType(propertyA, propertyB));
|
|
199
|
+
await Promise.all(promises);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Compares two EntityClass objects to identify differences between property values.
|
|
203
|
+
* @param entityA
|
|
204
|
+
* @param entityB
|
|
205
|
+
*/
|
|
206
|
+
async compareEntityClasses(entityA, entityB) {
|
|
207
|
+
const promises = [];
|
|
208
|
+
for (const mixinA of entityA.mixins) {
|
|
209
|
+
if (!entityB || -1 === entityB.mixins.findIndex((m) => m.fullName === mixinA.fullName))
|
|
210
|
+
promises.push(this._reporter.reportEntityMixinMissing(entityA, await mixinA, this._compareDirection));
|
|
211
|
+
}
|
|
212
|
+
await Promise.all(promises);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Compares two Mixin objects to identify differences between property values.
|
|
216
|
+
* @param mixinA
|
|
217
|
+
* @param mixinB
|
|
218
|
+
*/
|
|
219
|
+
async compareMixins(mixinA, mixinB) {
|
|
220
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && mixinB)
|
|
221
|
+
return;
|
|
222
|
+
if (mixinA.appliesTo) {
|
|
223
|
+
const appliesToA = mixinA.appliesTo.fullName;
|
|
224
|
+
const appliesToB = mixinB ? mixinB.appliesTo ? mixinB.appliesTo.fullName : undefined : undefined;
|
|
225
|
+
if (appliesToA !== appliesToB)
|
|
226
|
+
await this._reporter.reportMixinDelta(mixinA, "appliesTo", appliesToA, appliesToB, this._compareDirection);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Compares two RelationshipClass objects to identify differences between property values.
|
|
231
|
+
* @param relationshipA
|
|
232
|
+
* @param relationshipB
|
|
233
|
+
*/
|
|
234
|
+
async compareRelationshipClasses(relationshipA, relationshipB) {
|
|
235
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && relationshipB)
|
|
236
|
+
return;
|
|
237
|
+
const promises = [];
|
|
238
|
+
const strengthB = relationshipB ? relationshipB.strength : undefined;
|
|
239
|
+
if (relationshipA.strength !== strengthB) {
|
|
240
|
+
const strengthAString = (0, ecschema_metadata_1.strengthToString)(relationshipA.strength);
|
|
241
|
+
const strengthBString = strengthB !== undefined ? (0, ecschema_metadata_1.strengthToString)(strengthB) : undefined;
|
|
242
|
+
promises.push(this._reporter.reportRelationshipClassDelta(relationshipA, "strength", strengthAString, strengthBString, this._compareDirection));
|
|
243
|
+
}
|
|
244
|
+
const directionB = relationshipB ? relationshipB.strengthDirection : undefined;
|
|
245
|
+
if (relationshipA.strengthDirection !== directionB) {
|
|
246
|
+
const directionAString = (0, ecschema_metadata_1.strengthDirectionToString)(relationshipA.strengthDirection);
|
|
247
|
+
const directionBString = directionB !== undefined ? (0, ecschema_metadata_1.strengthDirectionToString)(directionB) : undefined;
|
|
248
|
+
promises.push(this._reporter.reportRelationshipClassDelta(relationshipA, "strengthDirection", directionAString, directionBString, this._compareDirection));
|
|
249
|
+
}
|
|
250
|
+
await Promise.all(promises);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Compares two RelationshipConstraint objects to identify differences between property values.
|
|
254
|
+
* @param relationshipConstraintA
|
|
255
|
+
* @param relationshipConstraintB
|
|
256
|
+
*/
|
|
257
|
+
async compareRelationshipConstraints(constraintA, constraintB) {
|
|
258
|
+
const promises = [];
|
|
259
|
+
if (constraintA.constraintClasses) {
|
|
260
|
+
for (const classA of constraintA.constraintClasses) {
|
|
261
|
+
if (!constraintB || !constraintB.constraintClasses || -1 === constraintB.constraintClasses.findIndex((c) => c.matchesFullName(classA.fullName)))
|
|
262
|
+
promises.push(this._reporter.reportRelationshipConstraintClassMissing(constraintA, await classA, this._compareDirection));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && constraintB) {
|
|
266
|
+
await Promise.all(promises);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const constraintBMultiplicity = constraintB ? constraintB.multiplicity : undefined;
|
|
270
|
+
if (constraintA.multiplicity || constraintBMultiplicity) {
|
|
271
|
+
const multiplicityA = constraintA.multiplicity ? constraintA.multiplicity.toString() : undefined;
|
|
272
|
+
const multiplicityB = constraintBMultiplicity ? constraintBMultiplicity.toString() : undefined;
|
|
273
|
+
if (multiplicityA !== multiplicityB)
|
|
274
|
+
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "multiplicity", multiplicityA, multiplicityB, this._compareDirection));
|
|
275
|
+
}
|
|
276
|
+
const constraintBRoleLabel = constraintB ? constraintB.roleLabel : undefined;
|
|
277
|
+
if (constraintA.roleLabel !== constraintBRoleLabel)
|
|
278
|
+
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "roleLabel", constraintA.roleLabel, constraintBRoleLabel, this._compareDirection));
|
|
279
|
+
const constraintBPolymorphic = constraintB ? constraintB.polymorphic : undefined;
|
|
280
|
+
if (constraintA.polymorphic !== constraintBPolymorphic)
|
|
281
|
+
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "polymorphic", constraintA.polymorphic, constraintBPolymorphic, this._compareDirection));
|
|
282
|
+
const constraintBAbstractConstraint = constraintB ? constraintB.abstractConstraint : undefined;
|
|
283
|
+
if (constraintA.abstractConstraint || constraintBAbstractConstraint) {
|
|
284
|
+
const abstractA = constraintA.abstractConstraint ? constraintA.abstractConstraint.fullName : undefined;
|
|
285
|
+
const abstractB = constraintBAbstractConstraint ? constraintBAbstractConstraint.fullName : undefined;
|
|
286
|
+
if (abstractA !== abstractB) {
|
|
287
|
+
promises.push(this._reporter.reportRelationshipConstraintDelta(constraintA, "abstractConstraint", abstractA, abstractB, this._compareDirection));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
await Promise.all(promises);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Compares two CustomAttributeClass objects to identify differences between property values.
|
|
294
|
+
* @param customAttributeClassA
|
|
295
|
+
* @param customAttributeClassB
|
|
296
|
+
*/
|
|
297
|
+
async compareCustomAttributeClasses(customAttributeClassA, customAttributeClassB) {
|
|
298
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && customAttributeClassB)
|
|
299
|
+
return;
|
|
300
|
+
const containerTypeB = customAttributeClassB ? customAttributeClassB.containerType : undefined;
|
|
301
|
+
if (customAttributeClassA.containerType !== containerTypeB) {
|
|
302
|
+
const typeA = (0, ecschema_metadata_1.containerTypeToString)(customAttributeClassA.containerType);
|
|
303
|
+
const typeB = containerTypeB !== undefined ? (0, ecschema_metadata_1.containerTypeToString)(containerTypeB) : undefined;
|
|
304
|
+
await this._reporter.reportCustomAttributeClassDelta(customAttributeClassA, "appliesTo", typeA, typeB, this._compareDirection);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Compares two CustomAttributeContainerProps objects to identify differences between property values.
|
|
309
|
+
* @param containerA
|
|
310
|
+
* @param containerB
|
|
311
|
+
*/
|
|
312
|
+
async compareCustomAttributeContainers(containerA, containerB) {
|
|
313
|
+
const promises = [];
|
|
314
|
+
if (containerA.customAttributes) {
|
|
315
|
+
for (const ca of containerA.customAttributes) {
|
|
316
|
+
if (!containerB || !containerB.customAttributes || !containerB.customAttributes.has(ca[0]))
|
|
317
|
+
promises.push(this._reporter.reportCustomAttributeInstanceClassMissing(containerA, ca[1], this._compareDirection));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
await Promise.all(promises);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Compares two Enumeration objects to identify differences between property values.
|
|
324
|
+
* @param enumA
|
|
325
|
+
* @param enumB
|
|
326
|
+
*/
|
|
327
|
+
async compareEnumerations(enumA, enumB) {
|
|
328
|
+
const promises = [];
|
|
329
|
+
for (const enumeratorA of enumA.enumerators) {
|
|
330
|
+
const enumeratorB = enumB ? enumB.enumerators.find((e) => e.name === enumeratorA.name) : undefined;
|
|
331
|
+
if (!enumeratorB) {
|
|
332
|
+
promises.push(this._reporter.reportEnumeratorMissing(enumA, enumeratorA, this._compareDirection));
|
|
333
|
+
promises.push(this.compareEnumerators(enumeratorA, enumeratorB, enumA, enumB));
|
|
334
|
+
}
|
|
335
|
+
else if (this._compareDirection === SchemaCompareDirection.Forward) {
|
|
336
|
+
promises.push(this.compareEnumerators(enumeratorA, enumeratorB, enumA, enumB));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && enumB) {
|
|
340
|
+
await Promise.all(promises);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const typeB = enumB ? enumB.type : undefined;
|
|
344
|
+
if (enumA.type !== typeB) {
|
|
345
|
+
const typeAString = enumA.type ? (0, ecschema_metadata_1.primitiveTypeToString)(enumA.type) : undefined;
|
|
346
|
+
const typeBString = typeB !== undefined ? (0, ecschema_metadata_1.primitiveTypeToString)(typeB) : undefined;
|
|
347
|
+
promises.push(this._reporter.reportEnumerationDelta(enumA, "type", typeAString, typeBString, this._compareDirection));
|
|
348
|
+
}
|
|
349
|
+
const isStrictB = enumB ? enumB.isStrict : undefined;
|
|
350
|
+
if (enumA.isStrict !== isStrictB)
|
|
351
|
+
promises.push(this._reporter.reportEnumerationDelta(enumA, "isStrict", enumA.isStrict, isStrictB, this._compareDirection));
|
|
352
|
+
await Promise.all(promises);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Compares two KindOfQuantity objects to identify differences between property values.
|
|
356
|
+
* @param koqA
|
|
357
|
+
* @param koqB
|
|
358
|
+
*/
|
|
359
|
+
async compareKindOfQuantities(koqA, koqB) {
|
|
360
|
+
const promises = [];
|
|
361
|
+
if (koqA.presentationFormats) {
|
|
362
|
+
for (const unit of koqA.presentationFormats) {
|
|
363
|
+
if (!koqB || !koqB.presentationFormats || -1 === koqB.presentationFormats.findIndex((u) => u.fullName === unit.fullName))
|
|
364
|
+
promises.push(this._reporter.reportPresentationUnitMissing(koqA, unit, this._compareDirection));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && koqB) {
|
|
368
|
+
await Promise.all(promises);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const errorB = koqB ? koqB.relativeError : undefined;
|
|
372
|
+
if (koqA.relativeError !== errorB) {
|
|
373
|
+
promises.push(this._reporter.reportKoqDelta(koqA, "relativeError", koqA.relativeError, errorB, this._compareDirection));
|
|
374
|
+
}
|
|
375
|
+
const unitB = koqB ? koqB.persistenceUnit : undefined;
|
|
376
|
+
if (koqA.persistenceUnit || unitB) {
|
|
377
|
+
const unitNameA = koqA.persistenceUnit ? koqA.persistenceUnit.fullName : undefined;
|
|
378
|
+
const unitNameB = unitB ? unitB.fullName : undefined;
|
|
379
|
+
if (unitNameA !== unitNameB) {
|
|
380
|
+
promises.push(this._reporter.reportKoqDelta(koqA, "persistenceUnit", unitNameA, unitNameB, this._compareDirection));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
await Promise.all(promises);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Compares two PropertyCategory objects to identify differences between property values.
|
|
387
|
+
* @param categoryA
|
|
388
|
+
* @param categoryB
|
|
389
|
+
*/
|
|
390
|
+
async comparePropertyCategories(categoryA, categoryB) {
|
|
391
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && categoryB)
|
|
392
|
+
return;
|
|
393
|
+
const priorityB = categoryB ? categoryB.priority : undefined;
|
|
394
|
+
if (categoryA.priority !== priorityB)
|
|
395
|
+
await this._reporter.reportPropertyCategoryDelta(categoryA, "priority", categoryA.priority, priorityB, this._compareDirection);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Compares two Format objects to identify differences between property values.
|
|
399
|
+
* @param formatA
|
|
400
|
+
* @param formatB
|
|
401
|
+
*/
|
|
402
|
+
async compareFormats(formatA, formatB) {
|
|
403
|
+
const promises = [];
|
|
404
|
+
promises.push(this.compareFormatUnits(formatA, formatB));
|
|
405
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && formatB) {
|
|
406
|
+
await Promise.all(promises);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const roundFactorB = formatB ? formatB.roundFactor : undefined;
|
|
410
|
+
if (formatA.roundFactor !== roundFactorB)
|
|
411
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "roundFactor", formatA.roundFactor, roundFactorB, this._compareDirection));
|
|
412
|
+
const typeB = formatB ? formatB.type : undefined;
|
|
413
|
+
if (formatA.type !== typeB) {
|
|
414
|
+
const typeAString = (0, core_quantity_1.formatTypeToString)(formatA.type);
|
|
415
|
+
const typeBString = typeB !== undefined ? (0, core_quantity_1.formatTypeToString)(typeB) : undefined;
|
|
416
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "type", typeAString, typeBString, this._compareDirection));
|
|
417
|
+
}
|
|
418
|
+
const precisionB = formatB ? formatB.precision : undefined;
|
|
419
|
+
if (formatA.precision !== precisionB)
|
|
420
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "precision", formatA.precision, precisionB, this._compareDirection));
|
|
421
|
+
const minWidthB = formatB ? formatB.minWidth : undefined;
|
|
422
|
+
if (formatA.minWidth !== minWidthB)
|
|
423
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "minWidth", formatA.minWidth, minWidthB, this._compareDirection));
|
|
424
|
+
const scientificTypeB = formatB ? formatB.scientificType : undefined;
|
|
425
|
+
if (formatA.scientificType !== scientificTypeB) {
|
|
426
|
+
const typeAString = formatA.scientificType !== undefined ? (0, core_quantity_1.scientificTypeToString)(formatA.scientificType) : undefined;
|
|
427
|
+
const typeBString = scientificTypeB !== undefined ? (0, core_quantity_1.scientificTypeToString)(scientificTypeB) : undefined;
|
|
428
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "scientificType", typeAString, typeBString, this._compareDirection));
|
|
429
|
+
}
|
|
430
|
+
const showSignOptionB = formatB ? formatB.showSignOption : undefined;
|
|
431
|
+
if (formatA.showSignOption !== showSignOptionB) {
|
|
432
|
+
const optionA = (0, core_quantity_1.showSignOptionToString)(formatA.showSignOption);
|
|
433
|
+
const optionB = showSignOptionB !== undefined ? (0, core_quantity_1.showSignOptionToString)(showSignOptionB) : undefined;
|
|
434
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "showSignOption", optionA, optionB, this._compareDirection));
|
|
435
|
+
}
|
|
436
|
+
const decimalSeparatorB = formatB ? formatB.decimalSeparator : undefined;
|
|
437
|
+
if (formatA.decimalSeparator !== decimalSeparatorB)
|
|
438
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "decimalSeparator", formatA.decimalSeparator, decimalSeparatorB, this._compareDirection));
|
|
439
|
+
const thousandSeparatorB = formatB ? formatB.thousandSeparator : undefined;
|
|
440
|
+
if (formatA.thousandSeparator !== thousandSeparatorB)
|
|
441
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "thousandSeparator", formatA.thousandSeparator, thousandSeparatorB, this._compareDirection));
|
|
442
|
+
const uomSeparatorB = formatB ? formatB.uomSeparator : undefined;
|
|
443
|
+
if (formatA.uomSeparator !== uomSeparatorB)
|
|
444
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "uomSeparator", formatA.uomSeparator, uomSeparatorB, this._compareDirection));
|
|
445
|
+
const stationSeparatorB = formatB ? formatB.stationSeparator : undefined;
|
|
446
|
+
if (formatA.stationSeparator !== stationSeparatorB)
|
|
447
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "stationSeparator", formatA.stationSeparator, stationSeparatorB, this._compareDirection));
|
|
448
|
+
const stationOffsetSizeB = formatB ? formatB.stationOffsetSize : undefined;
|
|
449
|
+
if (formatA.stationOffsetSize !== stationOffsetSizeB)
|
|
450
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "stationOffsetSize", formatA.stationOffsetSize, stationOffsetSizeB, this._compareDirection));
|
|
451
|
+
const formatTraitsB = formatB ? formatB.formatTraits : undefined;
|
|
452
|
+
if (formatA.formatTraits !== formatTraitsB) {
|
|
453
|
+
const traitsA = (0, core_quantity_1.formatTraitsToArray)(formatA.formatTraits);
|
|
454
|
+
const traitsB = formatTraitsB !== undefined ? (0, core_quantity_1.formatTraitsToArray)(formatTraitsB) : undefined;
|
|
455
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "formatTraits", traitsA.toString(), traitsB ? traitsB.toString() : undefined, this._compareDirection));
|
|
456
|
+
}
|
|
457
|
+
const spacerB = formatB ? formatB.spacer : undefined;
|
|
458
|
+
if (formatA.spacer !== spacerB)
|
|
459
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "spacer", formatA.spacer, spacerB, this._compareDirection));
|
|
460
|
+
const includeZeroB = formatB ? formatB.includeZero : undefined;
|
|
461
|
+
if (formatA.includeZero !== includeZeroB)
|
|
462
|
+
promises.push(this._reporter.reportFormatDelta(formatA, "includeZero", formatA.includeZero, includeZeroB, this._compareDirection));
|
|
463
|
+
await Promise.all(promises);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Compares two Unit objects to identify differences between property values.
|
|
467
|
+
* @param unitA
|
|
468
|
+
* @param unitB
|
|
469
|
+
*/
|
|
470
|
+
async compareUnits(unitA, unitB) {
|
|
471
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && unitB)
|
|
472
|
+
return;
|
|
473
|
+
const promises = [];
|
|
474
|
+
const phenomenonB = unitB ? unitB.phenomenon : undefined;
|
|
475
|
+
if (unitA.phenomenon || phenomenonB) {
|
|
476
|
+
const fullNameA = unitA.phenomenon ? unitA.phenomenon.fullName : undefined;
|
|
477
|
+
const fullNameB = phenomenonB ? phenomenonB.fullName : undefined;
|
|
478
|
+
if (fullNameA !== fullNameB)
|
|
479
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "phenomenon", fullNameA, fullNameB, this._compareDirection));
|
|
480
|
+
}
|
|
481
|
+
const unitSystemB = unitB ? unitB.unitSystem : undefined;
|
|
482
|
+
if (unitA.unitSystem || unitSystemB) {
|
|
483
|
+
const fullNameA = unitA.unitSystem ? unitA.unitSystem.fullName : undefined;
|
|
484
|
+
const fullNameB = unitSystemB ? unitSystemB.fullName : undefined;
|
|
485
|
+
if (fullNameA !== fullNameB)
|
|
486
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "unitSystem", fullNameA, fullNameB, this._compareDirection));
|
|
487
|
+
}
|
|
488
|
+
const definitionB = unitB ? unitB.definition : undefined;
|
|
489
|
+
if (unitA.definition !== definitionB)
|
|
490
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "definition", unitA.definition, definitionB, this._compareDirection));
|
|
491
|
+
const numeratorB = unitB ? unitB.numerator : undefined;
|
|
492
|
+
if (unitA.numerator !== numeratorB)
|
|
493
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "numerator", unitA.numerator, numeratorB, this._compareDirection));
|
|
494
|
+
const denominatorB = unitB ? unitB.denominator : undefined;
|
|
495
|
+
if (unitA.denominator !== denominatorB)
|
|
496
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "denominator", unitA.denominator, denominatorB, this._compareDirection));
|
|
497
|
+
const offsetB = unitB ? unitB.offset : undefined;
|
|
498
|
+
if (unitA.offset !== offsetB)
|
|
499
|
+
promises.push(this._reporter.reportUnitDelta(unitA, "offset", unitA.offset, offsetB, this._compareDirection));
|
|
500
|
+
await Promise.all(promises);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Compares two InvertedUnit objects to identify differences between property values.
|
|
504
|
+
* @param invertedUnitA
|
|
505
|
+
* @param invertedUnitB
|
|
506
|
+
*/
|
|
507
|
+
async compareInvertedUnits(invertedUnitA, invertedUnitB) {
|
|
508
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && invertedUnitB)
|
|
509
|
+
return;
|
|
510
|
+
const promises = [];
|
|
511
|
+
const invertsUnitB = invertedUnitB ? invertedUnitB.invertsUnit : undefined;
|
|
512
|
+
if (invertedUnitA.invertsUnit || invertsUnitB) {
|
|
513
|
+
const fullNameA = invertedUnitA.invertsUnit ? invertedUnitA.invertsUnit.fullName : undefined;
|
|
514
|
+
const fullNameB = invertsUnitB ? invertsUnitB.fullName : undefined;
|
|
515
|
+
if (fullNameA !== fullNameB)
|
|
516
|
+
promises.push(this._reporter.reportInvertedUnitDelta(invertedUnitA, "invertsUnit", fullNameA, fullNameB, this._compareDirection));
|
|
517
|
+
}
|
|
518
|
+
const unitSystemB = invertedUnitB ? invertedUnitB.unitSystem : undefined;
|
|
519
|
+
if (invertedUnitA.unitSystem || unitSystemB) {
|
|
520
|
+
const fullNameA = invertedUnitA.unitSystem ? invertedUnitA.unitSystem.fullName : undefined;
|
|
521
|
+
const fullNameB = unitSystemB ? unitSystemB.fullName : undefined;
|
|
522
|
+
if (fullNameA !== fullNameB)
|
|
523
|
+
promises.push(this._reporter.reportInvertedUnitDelta(invertedUnitA, "unitSystem", fullNameA, fullNameB, this._compareDirection));
|
|
524
|
+
}
|
|
525
|
+
await Promise.all(promises);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Compares two Phenomenon objects to identify differences between property values.
|
|
529
|
+
* @param phenomenonA
|
|
530
|
+
* @param phenomenonB
|
|
531
|
+
*/
|
|
532
|
+
async comparePhenomenons(phenomenonA, phenomenonB) {
|
|
533
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && phenomenonB)
|
|
534
|
+
return;
|
|
535
|
+
const definitionB = phenomenonB ? phenomenonB.definition : undefined;
|
|
536
|
+
if (phenomenonA.definition !== definitionB)
|
|
537
|
+
await this._reporter.reportPhenomenonDelta(phenomenonA, "definition", phenomenonA.definition, definitionB, this._compareDirection);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Compares two Constant objects to identify differences between property values.
|
|
541
|
+
* @param constantA
|
|
542
|
+
* @param constantB
|
|
543
|
+
*/
|
|
544
|
+
async compareConstants(constantA, constantB) {
|
|
545
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && constantB)
|
|
546
|
+
return;
|
|
547
|
+
const promises = [];
|
|
548
|
+
const phenomenonB = constantB ? constantB.phenomenon : undefined;
|
|
549
|
+
if (constantA.phenomenon || phenomenonB) {
|
|
550
|
+
const fullNameA = constantA.phenomenon ? constantA.phenomenon.fullName : undefined;
|
|
551
|
+
const fullNameB = phenomenonB ? phenomenonB.fullName : undefined;
|
|
552
|
+
if (fullNameA !== fullNameB)
|
|
553
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "phenomenon", fullNameA, fullNameB, this._compareDirection));
|
|
554
|
+
}
|
|
555
|
+
const definitionB = constantB ? constantB.definition : undefined;
|
|
556
|
+
if (constantA.definition !== definitionB)
|
|
557
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "definition", constantA.definition, definitionB, this._compareDirection));
|
|
558
|
+
const numeratorB = constantB ? constantB.numerator : undefined;
|
|
559
|
+
if (constantA.numerator !== numeratorB)
|
|
560
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "numerator", constantA.numerator, numeratorB, this._compareDirection));
|
|
561
|
+
const denominatorB = constantB ? constantB.denominator : undefined;
|
|
562
|
+
if (constantA.denominator !== denominatorB)
|
|
563
|
+
promises.push(this._reporter.reportConstantDelta(constantA, "denominator", constantA.denominator, denominatorB, this._compareDirection));
|
|
564
|
+
await Promise.all(promises);
|
|
565
|
+
}
|
|
566
|
+
async comparePropertyType(propertyA, propertyB) {
|
|
567
|
+
const promises = [];
|
|
568
|
+
const propertyTypeA = (0, ecschema_metadata_1.propertyTypeToString)(propertyA.propertyType);
|
|
569
|
+
const propertyTypeB = propertyB !== undefined ? (0, ecschema_metadata_1.propertyTypeToString)(propertyB.propertyType) : undefined;
|
|
570
|
+
if (propertyTypeA !== propertyTypeB) {
|
|
571
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "type", propertyTypeA, propertyTypeB, this._compareDirection));
|
|
572
|
+
}
|
|
573
|
+
if (propertyA.isArray()) {
|
|
574
|
+
const minOccursB = propertyB && propertyB.isArray() ? propertyB.minOccurs : undefined;
|
|
575
|
+
if (propertyA.minOccurs !== minOccursB) {
|
|
576
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "minOccurs", propertyA.minOccurs, minOccursB, this._compareDirection));
|
|
577
|
+
}
|
|
578
|
+
const maxOccursB = propertyB && propertyB.isArray() ? propertyB.maxOccurs : undefined;
|
|
579
|
+
if (propertyA.maxOccurs !== maxOccursB) {
|
|
580
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "maxOccurs", propertyA.maxOccurs, maxOccursB, this._compareDirection));
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (propertyA.isEnumeration()) {
|
|
584
|
+
const enumerationB = propertyB && propertyB.isEnumeration() ? propertyB.enumeration : undefined;
|
|
585
|
+
if (propertyA.enumeration || enumerationB) {
|
|
586
|
+
const enumA = propertyA.enumeration ? propertyA.enumeration.fullName : undefined;
|
|
587
|
+
const enumB = enumerationB ? enumerationB.fullName : undefined;
|
|
588
|
+
if (enumA !== enumB)
|
|
589
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "enumeration", enumA, enumB, this._compareDirection));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (propertyA.isNavigation()) {
|
|
593
|
+
const strengthDirectionB = propertyB && propertyB.isNavigation() ? propertyB.direction : undefined;
|
|
594
|
+
if (propertyA.direction !== strengthDirectionB) {
|
|
595
|
+
const dirA = (0, ecschema_metadata_1.strengthDirectionToString)(propertyA.direction);
|
|
596
|
+
const dirB = strengthDirectionB !== undefined ? (0, ecschema_metadata_1.strengthDirectionToString)(strengthDirectionB) : undefined;
|
|
597
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "direction", dirA, dirB, this._compareDirection));
|
|
598
|
+
}
|
|
599
|
+
if (propertyA.relationshipClass) { // eslint-disable-line @typescript-eslint/no-misused-promises
|
|
600
|
+
const relationshipClassB = propertyB && propertyB.isNavigation() ? propertyB.relationshipClass : undefined;
|
|
601
|
+
const relA = propertyA.relationshipClass.fullName;
|
|
602
|
+
const relB = relationshipClassB ? relationshipClassB.fullName : undefined;
|
|
603
|
+
if (relA !== relB)
|
|
604
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "relationshipClass", relA, relB, this._compareDirection));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (propertyA.isPrimitive()) {
|
|
608
|
+
const primitiveTypeB = propertyB && propertyB.isPrimitive() ? propertyB.primitiveType : undefined;
|
|
609
|
+
if (propertyA.primitiveType !== primitiveTypeB) {
|
|
610
|
+
const aType = (0, ecschema_metadata_1.primitiveTypeToString)(propertyA.primitiveType);
|
|
611
|
+
const bType = primitiveTypeB !== undefined ? (0, ecschema_metadata_1.primitiveTypeToString)(primitiveTypeB) : undefined;
|
|
612
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "primitiveType", aType, bType, this._compareDirection));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (propertyA.isStruct()) {
|
|
616
|
+
const structA = propertyA.structClass;
|
|
617
|
+
const structB = propertyB && propertyB.isStruct() ? propertyB.structClass : undefined;
|
|
618
|
+
if (structA || structB) {
|
|
619
|
+
const structNameA = structA ? structA.fullName : undefined;
|
|
620
|
+
const structNameB = structB ? structB.fullName : undefined;
|
|
621
|
+
if (structNameA !== structNameB)
|
|
622
|
+
promises.push(this._reporter.reportPropertyDelta(propertyA, "structClass", structNameA, structNameB, this._compareDirection));
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
await Promise.all(promises);
|
|
626
|
+
}
|
|
627
|
+
async compareEnumerators(enumeratorA, enumeratorB, enumA, enumB) {
|
|
628
|
+
const promises = [];
|
|
629
|
+
if (!enumB || !enumeratorB) {
|
|
630
|
+
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "description", enumeratorA.description, undefined, this._compareDirection));
|
|
631
|
+
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "label", enumeratorA.label, undefined, this._compareDirection));
|
|
632
|
+
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "value", enumeratorA.value, undefined, this._compareDirection));
|
|
633
|
+
await Promise.all(promises);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (enumeratorA.description !== enumeratorB.description)
|
|
637
|
+
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "description", enumeratorA.description, enumeratorB.description, this._compareDirection));
|
|
638
|
+
if (!labelsMatch(enumeratorA.label, enumeratorB.label))
|
|
639
|
+
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "label", enumeratorA.label, enumeratorB.label, this._compareDirection));
|
|
640
|
+
// No need to compare values if the type is different (which will be reported separately)
|
|
641
|
+
if (enumA.type === enumB.type && enumeratorA.value !== enumeratorB.value)
|
|
642
|
+
promises.push(this._reporter.reportEnumeratorDelta(enumA, enumeratorA, "value", enumeratorA.value, enumeratorB.value, this._compareDirection));
|
|
643
|
+
await Promise.all(promises);
|
|
644
|
+
}
|
|
645
|
+
async compareFormatUnits(formatA, formatB) {
|
|
646
|
+
if (!formatA.units)
|
|
647
|
+
return;
|
|
648
|
+
const promises = [];
|
|
649
|
+
for (const unitA of formatA.units) {
|
|
650
|
+
const unitB = formatB && formatB.units ? formatB.units.find((u) => u[0].fullName === unitA[0].fullName) : undefined;
|
|
651
|
+
if (!unitB) {
|
|
652
|
+
promises.push(this._reporter.reportFormatUnitMissing(formatA, unitA[0], this._compareDirection));
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (this._compareDirection === SchemaCompareDirection.Backward && formatB)
|
|
656
|
+
continue;
|
|
657
|
+
if (unitA[1] !== unitB[1]) {
|
|
658
|
+
const labelA = unitA[1];
|
|
659
|
+
const labelB = unitB[1];
|
|
660
|
+
promises.push(this._reporter.reportUnitLabelOverrideDelta(formatA, unitB[0], labelA, labelB, this._compareDirection));
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
await Promise.all(promises);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
exports.SchemaComparer = SchemaComparer;
|
|
667
667
|
//# sourceMappingURL=SchemaComparer.js.map
|