@itwin/ecschema-editing 5.0.0-dev.7 → 5.0.0-dev.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/lib/cjs/Differencing/Errors.js +6 -0
- package/lib/cjs/Differencing/Errors.js.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +3 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +2 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -3
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +57 -11
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +33 -4
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +55 -5
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +78 -19
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +5 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Differencing/Utils.js.map +1 -1
- package/lib/cjs/Editing/Constants.d.ts +2 -1
- package/lib/cjs/Editing/Constants.d.ts.map +1 -1
- package/lib/cjs/Editing/Constants.js +4 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +2 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +3 -0
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +6 -0
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +48 -35
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +2 -2
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +32 -21
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +2 -1
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +18 -14
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +2 -1
- package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
- package/lib/cjs/Editing/Enumerations.js +6 -3
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Exception.js +35 -6
- package/lib/cjs/Editing/Exception.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts +2 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +5 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +2 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js +10 -6
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +11 -7
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +2 -1
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +13 -9
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +8 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.d.ts +2 -1
- package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
- package/lib/cjs/Editing/Phenomena.js +3 -0
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts +2 -2
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +6 -4
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +2 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js +5 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +1 -0
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +17 -10
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +2 -2
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +8 -11
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +2 -1
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +3 -0
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +2 -1
- package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js +3 -0
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.d.ts +2 -1
- package/lib/cjs/Editing/Units.d.ts.map +1 -1
- package/lib/cjs/Editing/Units.js +5 -2
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +4 -4
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +7 -6
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/NameMapping.d.ts +22 -0
- package/lib/cjs/Merging/Edits/NameMapping.d.ts.map +1 -0
- package/lib/cjs/Merging/Edits/NameMapping.js +54 -0
- package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -0
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js +1 -260
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +9 -6
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.js +19 -14
- package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +1 -2
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.js +2 -2
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/cjs/Merging/FormatMerger.d.ts +24 -0
- package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/FormatMerger.js +143 -0
- package/lib/cjs/Merging/FormatMerger.js.map +1 -0
- package/lib/cjs/Merging/InvertedUnitMerger.d.ts +14 -0
- package/lib/cjs/Merging/InvertedUnitMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/InvertedUnitMerger.js +45 -0
- package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -5
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +1 -1
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +28 -26
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +4 -4
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +5 -3
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +40 -5
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +14 -8
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js +42 -17
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js +2 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitMerger.d.ts +14 -0
- package/lib/cjs/Merging/UnitMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/UnitMerger.js +62 -0
- package/lib/cjs/Merging/UnitMerger.js.map +1 -0
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.d.ts +11 -0
- package/lib/cjs/Merging/Utils.d.ts.map +1 -1
- package/lib/cjs/Merging/Utils.js +23 -3
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +18 -16
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js +3 -0
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js +39 -69
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +2 -2
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +4 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +23 -23
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +22 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +30 -5
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.js +1 -4
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js +3 -4
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js +4 -0
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +10 -10
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.applyRenamePropertyEdit = applyRenamePropertyEdit;
|
|
11
11
|
exports.applyRenameSchemaItemEdit = applyRenameSchemaItemEdit;
|
|
12
|
-
const SchemaDifference_1 = require("../../Differencing/SchemaDifference");
|
|
13
12
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
14
13
|
const Utils = require("../../Differencing/Utils");
|
|
15
14
|
/**
|
|
@@ -38,7 +37,7 @@ function applyRenamePropertyEdit(result, edit) {
|
|
|
38
37
|
/**
|
|
39
38
|
* @internal
|
|
40
39
|
*/
|
|
41
|
-
function applyRenameSchemaItemEdit(result, edit
|
|
40
|
+
function applyRenameSchemaItemEdit(result, edit) {
|
|
42
41
|
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(edit.key);
|
|
43
42
|
if (!result.sourceSchemaName.startsWith(schemaName)) {
|
|
44
43
|
return;
|
|
@@ -57,57 +56,6 @@ function applyRenameSchemaItemEdit(result, edit, postProcessing) {
|
|
|
57
56
|
result.conflicts.splice(conflictIndex, 1);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
postProcessing(() => {
|
|
61
|
-
renameSchemaItem(result, edit, itemDifference.schemaType);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function renameSchemaItem(result, edit, schemaType) {
|
|
65
|
-
const schemaKey = ecschema_metadata_1.SchemaKey.parseString(result.sourceSchemaName);
|
|
66
|
-
const [_schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(edit.key);
|
|
67
|
-
const oldKey = new ecschema_metadata_1.SchemaItemKey(itemName, schemaKey);
|
|
68
|
-
const newKey = new ecschema_metadata_1.SchemaItemKey(edit.value, schemaKey);
|
|
69
|
-
switch (schemaType) {
|
|
70
|
-
case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
|
|
71
|
-
renameCustomAttributeClassName(result, oldKey, newKey);
|
|
72
|
-
break;
|
|
73
|
-
case ecschema_metadata_1.SchemaItemType.EntityClass:
|
|
74
|
-
renameEntityClassName(result, oldKey, newKey);
|
|
75
|
-
break;
|
|
76
|
-
case ecschema_metadata_1.SchemaItemType.Enumeration:
|
|
77
|
-
renameEnumerationName(result, oldKey, newKey);
|
|
78
|
-
break;
|
|
79
|
-
case ecschema_metadata_1.SchemaItemType.Format:
|
|
80
|
-
break;
|
|
81
|
-
case ecschema_metadata_1.SchemaItemType.InvertedUnit:
|
|
82
|
-
break;
|
|
83
|
-
case ecschema_metadata_1.SchemaItemType.KindOfQuantity:
|
|
84
|
-
renameKindOfQuantityName(result, oldKey, newKey);
|
|
85
|
-
break;
|
|
86
|
-
case ecschema_metadata_1.SchemaItemType.Mixin:
|
|
87
|
-
renameMixinName(result, oldKey, newKey);
|
|
88
|
-
break;
|
|
89
|
-
case ecschema_metadata_1.SchemaItemType.Phenomenon:
|
|
90
|
-
renamePhenomenonName(result, oldKey, newKey);
|
|
91
|
-
break;
|
|
92
|
-
case ecschema_metadata_1.SchemaItemType.PropertyCategory:
|
|
93
|
-
renamePropertyCategoryName(result, oldKey, newKey);
|
|
94
|
-
break;
|
|
95
|
-
case ecschema_metadata_1.SchemaItemType.RelationshipClass:
|
|
96
|
-
renameRelationshipClassName(result, oldKey, newKey);
|
|
97
|
-
break;
|
|
98
|
-
case ecschema_metadata_1.SchemaItemType.StructClass:
|
|
99
|
-
renameStructClassName(result, oldKey, newKey);
|
|
100
|
-
break;
|
|
101
|
-
case ecschema_metadata_1.SchemaItemType.Unit:
|
|
102
|
-
break;
|
|
103
|
-
case ecschema_metadata_1.SchemaItemType.UnitSystem:
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function renameBaseClass(difference, oldKey, newKey) {
|
|
108
|
-
if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {
|
|
109
|
-
difference.baseClass = newKey.fullName;
|
|
110
|
-
}
|
|
111
59
|
}
|
|
112
60
|
function renameName(change, oldName, newName) {
|
|
113
61
|
if (change.itemName === oldName) {
|
|
@@ -115,211 +63,4 @@ function renameName(change, oldName, newName) {
|
|
|
115
63
|
schemaItemDifference.itemName = newName;
|
|
116
64
|
}
|
|
117
65
|
}
|
|
118
|
-
function renameRelationshipConstraint(change, oldKey, newKey) {
|
|
119
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
|
|
120
|
-
const constraintProps = [change.difference.source, change.difference.target];
|
|
121
|
-
for (const props of constraintProps) {
|
|
122
|
-
if (props) {
|
|
123
|
-
if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {
|
|
124
|
-
props.abstractConstraint = newKey.fullName;
|
|
125
|
-
}
|
|
126
|
-
if (props.constraintClasses !== undefined) {
|
|
127
|
-
for (let i = 0; i < props.constraintClasses.length; i++) {
|
|
128
|
-
if (oldKey.matchesFullName(props.constraintClasses[i]))
|
|
129
|
-
props.constraintClasses[i] = newKey.fullName;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
for (let i = 0; i < change.difference.length; i++) {
|
|
137
|
-
if (oldKey.matchesFullName(change.difference[i]))
|
|
138
|
-
change.difference[i] = newKey.fullName;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function renamePropertyCategoryName({ differences }, oldKey, newKey) {
|
|
143
|
-
for (const entry of differences) {
|
|
144
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.PropertyCategory) {
|
|
145
|
-
renameName(entry, oldKey.name, newKey.name);
|
|
146
|
-
}
|
|
147
|
-
if (Utils.isClassDifference(entry) && entry.difference.properties) {
|
|
148
|
-
for (const property of entry.difference.properties) {
|
|
149
|
-
if (property.category && oldKey.matchesFullName(property.category)) {
|
|
150
|
-
const props = property;
|
|
151
|
-
props.category = newKey.fullName;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.Property) {
|
|
156
|
-
if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {
|
|
157
|
-
entry.difference.category = newKey.fullName;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function renameKindOfQuantityName({ differences }, oldKey, newKey) {
|
|
163
|
-
for (const entry of differences) {
|
|
164
|
-
if (Utils.isClassDifference(entry) && entry.difference.properties) {
|
|
165
|
-
for (const property of entry.difference.properties) {
|
|
166
|
-
if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {
|
|
167
|
-
const props = property;
|
|
168
|
-
props.kindOfQuantity = newKey.fullName;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.Property) {
|
|
173
|
-
if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {
|
|
174
|
-
entry.difference.kindOfQuantity = newKey.fullName;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function renameEnumerationName({ differences }, oldKey, newKey) {
|
|
180
|
-
for (const change of differences) {
|
|
181
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
182
|
-
for (const property of change.difference.properties) {
|
|
183
|
-
if (property.type === "PrimitiveProperty" || property.type === "PrimitiveArrayProperty") {
|
|
184
|
-
const props = property;
|
|
185
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
186
|
-
props.typeName = newKey.fullName;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && (change.difference.type === "PrimitiveProperty" || change.difference.type === "PrimitiveArrayProperty")) {
|
|
191
|
-
const props = change.difference;
|
|
192
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
193
|
-
props.typeName = newKey.fullName;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function renamePhenomenonName({ differences }, oldKey, newKey) {
|
|
198
|
-
for (const entry of differences) {
|
|
199
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Constant || entry.schemaType === ecschema_metadata_1.SchemaItemType.Unit) {
|
|
200
|
-
if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))
|
|
201
|
-
entry.difference.phenomenon = newKey.fullName;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function renameStructClassName({ differences }, oldKey, newKey) {
|
|
206
|
-
for (const change of differences) {
|
|
207
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.StructClass) {
|
|
208
|
-
renameBaseClass(change.difference, oldKey, newKey);
|
|
209
|
-
}
|
|
210
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
211
|
-
for (const property of change.difference.properties) {
|
|
212
|
-
if (property.type === "StructProperty" || property.type === "StructArrayProperty") {
|
|
213
|
-
const props = property;
|
|
214
|
-
;
|
|
215
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
216
|
-
props.typeName = newKey.fullName;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && (change.difference.type === "StructProperty" || change.difference.type === "StructArrayProperty")) {
|
|
221
|
-
const props = change.difference;
|
|
222
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
223
|
-
props.typeName = newKey.fullName;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function renameCustomAttributeClassName({ differences }, oldKey, newKey) {
|
|
228
|
-
for (const change of differences) {
|
|
229
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.CustomAttributeClass) {
|
|
230
|
-
renameBaseClass(change.difference, oldKey, newKey);
|
|
231
|
-
}
|
|
232
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.CustomAttributeInstance) {
|
|
233
|
-
if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {
|
|
234
|
-
change.difference.className = newKey.fullName;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property || Utils.isClassDifference(change)) {
|
|
238
|
-
if (change.difference.customAttributes) {
|
|
239
|
-
for (const customAttribute of change.difference.customAttributes) {
|
|
240
|
-
if (oldKey.matchesFullName(customAttribute.className))
|
|
241
|
-
customAttribute.className = newKey.fullName;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
246
|
-
for (const property of change.difference.properties) {
|
|
247
|
-
if (property.customAttributes) {
|
|
248
|
-
for (const customAttribute of property.customAttributes) {
|
|
249
|
-
if (oldKey.matchesFullName(customAttribute.className))
|
|
250
|
-
customAttribute.className = newKey.fullName;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// https://github.com/iTwin/itwinjs-core/issues/7020
|
|
256
|
-
/* if (change.schemaType === SchemaItemType.RelationshipClass) {
|
|
257
|
-
const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];
|
|
258
|
-
for (const props of constraintProps) {
|
|
259
|
-
if (props.customAttributes !== undefined) {
|
|
260
|
-
for (const customAttribute of props.customAttributes) {
|
|
261
|
-
if (oldKey.matchesFullName(customAttribute.className))
|
|
262
|
-
customAttribute.className = newKey.fullName;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
} */
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
function renameRelationshipClassName({ differences }, oldKey, newKey) {
|
|
270
|
-
for (const change of differences) {
|
|
271
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
|
|
272
|
-
renameBaseClass(change.difference, oldKey, newKey);
|
|
273
|
-
}
|
|
274
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && change.difference.type === "NavigationProperty") {
|
|
275
|
-
const props = change.difference;
|
|
276
|
-
if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))
|
|
277
|
-
props.relationshipName = newKey.fullName;
|
|
278
|
-
}
|
|
279
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
280
|
-
for (const property of change.difference.properties) {
|
|
281
|
-
if (property.type === "NavigationProperty") {
|
|
282
|
-
const props = property;
|
|
283
|
-
if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))
|
|
284
|
-
props.relationshipName = newKey.fullName;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass || change.schemaType === SchemaDifference_1.SchemaOtherTypes.RelationshipConstraintClass) {
|
|
289
|
-
renameRelationshipConstraint(change, oldKey, newKey);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function renameEntityClassName({ differences }, oldKey, newKey) {
|
|
294
|
-
for (const entry of differences) {
|
|
295
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.EntityClass) {
|
|
296
|
-
renameName(entry, oldKey.name, newKey.name);
|
|
297
|
-
renameBaseClass(entry.difference, oldKey, newKey);
|
|
298
|
-
}
|
|
299
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Mixin) {
|
|
300
|
-
if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))
|
|
301
|
-
entry.difference.appliesTo = newKey.fullName;
|
|
302
|
-
}
|
|
303
|
-
if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {
|
|
304
|
-
renameRelationshipConstraint(entry, oldKey, newKey);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function renameMixinName({ differences }, oldKey, newKey) {
|
|
309
|
-
for (const entry of differences) {
|
|
310
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Mixin) {
|
|
311
|
-
renameBaseClass(entry.difference, oldKey, newKey);
|
|
312
|
-
}
|
|
313
|
-
if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.EntityClassMixin) {
|
|
314
|
-
for (let i = 0; i < entry.difference.length; i++) {
|
|
315
|
-
if (oldKey.matchesFullName(entry.difference[i])) {
|
|
316
|
-
entry.difference[i] = newKey.fullName;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {
|
|
321
|
-
renameRelationshipConstraint(entry, oldKey, newKey);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
66
|
//# sourceMappingURL=RenameEditHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAcH,0DAuBC;AAKD,8DA2BC;AAlED,0EAAyP;AACzP,gEAA0P;AAC1P,kDAAkD;AAMlD;;GAEG;AACH,SA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AI,WAAW,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,UAAU,KAAK,kCAAc,CAAC,KAAK,EAAE,CAAC;YAC9C,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,KAAK,CAAC,UAAU,KAAK,mCAAgB,CAAC,gBAAgB,EAAE,CAAC;YAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,IAAI,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,6BAA6B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,KAAK,CAAC,EAAE,CAAC;YACvG,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\r\nimport { AnyClassItemDifference, AnySchemaItemDifference, ClassPropertyDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, SchemaDifferenceResult, SchemaOtherTypes, SchemaType } from \"../../Differencing/SchemaDifference\";\r\nimport { NavigationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, RelationshipConstraintProps, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps, StructPropertyProps } from \"@itwin/ecschema-metadata\";\r\nimport * as Utils from \"../../Differencing/Utils\";\r\n\r\ntype Editable<T extends object> = {\r\n -readonly [P in keyof T]: T[P];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\r\n const [schemaName, itemName, path] = edit.key.split(\".\") as [string, string, string];\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\r\n });\r\n\r\n const propertyDifference = difference as Editable<ClassPropertyDifference>;\r\n if (propertyDifference === undefined) {\r\n return;\r\n }\r\n\r\n propertyDifference.path = edit.value;\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, postProcessing: (cb: () => void) => void) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName;\r\n });\r\n\r\n const itemDifference = difference as AnySchemaItemDifference;\r\n if (itemDifference === undefined) {\r\n return;\r\n }\r\n\r\n renameName(itemDifference, itemName, edit.value);\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n\r\n postProcessing(() => {\r\n renameSchemaItem(result, edit, itemDifference.schemaType);\r\n });\r\n}\r\n\r\nfunction renameSchemaItem(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, schemaType: SchemaType) {\r\n const schemaKey = SchemaKey.parseString(result.sourceSchemaName);\r\n const [_schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n const oldKey = new SchemaItemKey(itemName, schemaKey);\r\n const newKey = new SchemaItemKey(edit.value, schemaKey);\r\n\r\n switch (schemaType) {\r\n case SchemaItemType.CustomAttributeClass:\r\n renameCustomAttributeClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.EntityClass:\r\n renameEntityClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n renameEnumerationName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Format:\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n renameKindOfQuantityName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Mixin:\r\n renameMixinName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n renamePhenomenonName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n renamePropertyCategoryName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n renameRelationshipClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.StructClass:\r\n renameStructClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Unit:\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n break;\r\n }\r\n}\r\n\r\nfunction renameBaseClass(difference: AnyClassItemDifference[\"difference\"], oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {\r\n difference.baseClass = newKey.fullName;\r\n }\r\n}\r\n\r\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\r\n if (change.itemName === oldName) {\r\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\r\n schemaItemDifference.itemName = newName;\r\n }\r\n}\r\n\r\nfunction renameRelationshipConstraint(change: RelationshipClassDifference | RelationshipConstraintClassDifference, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\r\n for (const props of constraintProps) {\r\n if (props) {\r\n if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {\r\n props.abstractConstraint = newKey.fullName;\r\n }\r\n if (props.constraintClasses !== undefined) {\r\n for (let i = 0; i < props.constraintClasses.length; i++) {\r\n if (oldKey.matchesFullName(props.constraintClasses[i]))\r\n props.constraintClasses[i] = newKey.fullName;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < change.difference.length; i++) {\r\n if (oldKey.matchesFullName(change.difference[i]))\r\n change.difference[i] = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renamePropertyCategoryName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.PropertyCategory) {\r\n renameName(entry, oldKey.name, newKey.name);\r\n }\r\n\r\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\r\n for (const property of entry.difference.properties) {\r\n if (property.category && oldKey.matchesFullName(property.category)) {\r\n const props = property as Editable<typeof property>;\r\n props.category = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.Property) {\r\n if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {\r\n entry.difference.category = newKey.fullName;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction renameKindOfQuantityName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\r\n for (const property of entry.difference.properties) {\r\n if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {\r\n const props = property as Editable<typeof property>;\r\n props.kindOfQuantity = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.Property) {\r\n if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {\r\n entry.difference.kindOfQuantity = newKey.fullName;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction renameEnumerationName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"PrimitiveProperty\" || property.type === \"PrimitiveArrayProperty\") {\r\n const props = property as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && (\r\n change.difference.type === \"PrimitiveProperty\" || change.difference.type === \"PrimitiveArrayProperty\"\r\n )) {\r\n const props = change.difference as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renamePhenomenonName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.Constant || entry.schemaType === SchemaItemType.Unit) {\r\n if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))\r\n entry.difference.phenomenon = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renameStructClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.StructClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"StructProperty\" || property.type === \"StructArrayProperty\") {\r\n const props = property as Editable<StructPropertyProps | StructArrayPropertyProps>;;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && (\r\n change.difference.type === \"StructProperty\" || change.difference.type === \"StructArrayProperty\"\r\n )) {\r\n const props = change.difference as Editable<StructPropertyProps | StructArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renameCustomAttributeClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.CustomAttributeClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.CustomAttributeInstance) {\r\n if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {\r\n change.difference.className = newKey.fullName;\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property || Utils.isClassDifference(change)) {\r\n if (change.difference.customAttributes) {\r\n for (const customAttribute of change.difference.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.customAttributes) {\r\n for (const customAttribute of property.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n }\r\n // https://github.com/iTwin/itwinjs-core/issues/7020\r\n /* if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\r\n for (const props of constraintProps) {\r\n if (props.customAttributes !== undefined) {\r\n for (const customAttribute of props.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n } */\r\n }\r\n}\r\n\r\nfunction renameRelationshipClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && change.difference.type === \"NavigationProperty\") {\r\n const props = change.difference as Editable<NavigationPropertyProps>;\r\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\r\n props.relationshipName = newKey.fullName;\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"NavigationProperty\") {\r\n const props = property as Editable<NavigationPropertyProps>;\r\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\r\n props.relationshipName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaItemType.RelationshipClass || change.schemaType === SchemaOtherTypes.RelationshipConstraintClass) {\r\n renameRelationshipConstraint(change, oldKey, newKey);\r\n }\r\n }\r\n}\r\n\r\nfunction renameEntityClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.EntityClass) {\r\n renameName(entry, oldKey.name, newKey.name);\r\n renameBaseClass(entry.difference, oldKey, newKey);\r\n }\r\n\r\n if (entry.schemaType === SchemaItemType.Mixin) {\r\n if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))\r\n entry.difference.appliesTo = newKey.fullName;\r\n }\r\n\r\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\r\n renameRelationshipConstraint(entry, oldKey, newKey);\r\n }\r\n }\r\n}\r\n\r\nfunction renameMixinName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.Mixin) {\r\n renameBaseClass(entry.difference, oldKey, newKey);\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.EntityClassMixin) {\r\n for (let i = 0; i < entry.difference.length; i++) {\r\n if (oldKey.matchesFullName(entry.difference[i])) {\r\n entry.difference[i] = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\r\n renameRelationshipConstraint(entry, oldKey, newKey);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAcH,0DAuBC;AAKD,8DAuBC;AA7DD,gEAAsD;AACtD,kDAAkD;AAMlD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,MAA8B,EAAE,IAAwB;IAC9F,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAA6B,CAAC;IACrF,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACnD,OAAO,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IACpI,CAAC,CAAC,CAAC;IAE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Aa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,cAAc,CAAC,CAAC;QACjG,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,OAAe,EAAE,OAAe;IACnF,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,oBAAoB,GAAG,MAA2C,CAAC;QACzE,oBAAoB,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\nimport { AnySchemaItemDifference, ClassPropertyDifference,SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { SchemaItem } from \"@itwin/ecschema-metadata\";\nimport * as Utils from \"../../Differencing/Utils\";\n\ntype Editable<T extends object> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\n const [schemaName, itemName, path] = edit.key.split(\".\") as [string, string, string];\n if (!result.sourceSchemaName.startsWith(schemaName)) {\n return;\n }\n\n const difference = result.differences.find((entry) => {\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\n });\n\n const propertyDifference = difference as Editable<ClassPropertyDifference>;\n if (propertyDifference === undefined) {\n return;\n }\n\n propertyDifference.path = edit.value;\n\n if (result.conflicts) {\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);\n if (conflictIndex > -1) {\n result.conflicts.splice(conflictIndex, 1);\n }\n }\n}\n\n/**\n * @internal\n */\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit) {\n const [schemaName, itemName] = SchemaItem.parseFullName(edit.key);\n if (!result.sourceSchemaName.startsWith(schemaName)) {\n return;\n }\n\n const difference = result.differences.find((entry) => {\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName;\n });\n\n const itemDifference = difference as AnySchemaItemDifference;\n if (itemDifference === undefined) {\n return;\n }\n\n renameName(itemDifference, itemName, edit.value);\n\n if (result.conflicts) {\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);\n if (conflictIndex > -1) {\n result.conflicts.splice(conflictIndex, 1);\n }\n }\n}\n\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\n if (change.itemName === oldName) {\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\n schemaItemDifference.itemName = newName;\n }\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Merging
|
|
3
3
|
*/
|
|
4
|
+
import type { ECClass, SchemaItem } from "@itwin/ecschema-metadata";
|
|
4
5
|
import type { SchemaDifferenceResult } from "../../Differencing/SchemaDifference";
|
|
6
|
+
import { NameMapping } from "./NameMapping";
|
|
5
7
|
/**
|
|
6
8
|
* An enumeration that has all the schema edit names.
|
|
7
9
|
* @alpha
|
|
@@ -48,19 +50,19 @@ declare abstract class Editor {
|
|
|
48
50
|
protected add(edit: AnySchemaEdits): void;
|
|
49
51
|
}
|
|
50
52
|
declare class PropertyEditor extends Editor {
|
|
51
|
-
rename(
|
|
52
|
-
skip(
|
|
53
|
+
rename(ecClass: ECClass, propertyName: string, newName: string): void;
|
|
54
|
+
skip(ecClass: ECClass, propertyName: string): void;
|
|
53
55
|
}
|
|
54
56
|
declare class ItemEditor extends Editor {
|
|
55
|
-
rename(
|
|
56
|
-
skip(
|
|
57
|
+
rename(schemaItem: SchemaItem, newName: string): void;
|
|
58
|
+
skip(schemaItem: SchemaItem): void;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class
|
|
60
62
|
* is to support saving of edits and load them again if needed.
|
|
61
63
|
* @alpha
|
|
62
64
|
*/
|
|
63
|
-
export declare class SchemaEdits {
|
|
65
|
+
export declare class SchemaEdits implements Iterable<AnySchemaEdits> {
|
|
64
66
|
private readonly _edits;
|
|
65
67
|
readonly properties: PropertyEditor;
|
|
66
68
|
readonly items: ItemEditor;
|
|
@@ -71,8 +73,9 @@ export declare class SchemaEdits {
|
|
|
71
73
|
/**
|
|
72
74
|
* @internal
|
|
73
75
|
*/
|
|
74
|
-
applyTo(differenceResult: SchemaDifferenceResult): Promise<void>;
|
|
76
|
+
applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void>;
|
|
75
77
|
toJSON(): ReadonlyArray<AnySchemaEdits>;
|
|
78
|
+
[Symbol.iterator](): Iterator<AnySchemaEdits>;
|
|
76
79
|
}
|
|
77
80
|
export {};
|
|
78
81
|
//# sourceMappingURL=SchemaEdits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEdits.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaEdits.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,E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C,QAAQ,CAAC,MAAM,CAAwB;IAE/C,SAAgB,UAAU,EAAE,cAAc,CAAC;IAC3C,SAAgB,KAAK,EAAE,UAAU,CAAC;IAElC;;OAEG;gBACS,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC;IAWtD;;OAEG;IACU,OAAO,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhG,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC;IAIvC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC;CAGrD"}
|
|
@@ -21,6 +21,7 @@ var SchemaEditType;
|
|
|
21
21
|
SchemaEditType["Skip"] = "Skip";
|
|
22
22
|
})(SchemaEditType || (exports.SchemaEditType = SchemaEditType = {}));
|
|
23
23
|
class Editor {
|
|
24
|
+
_edits;
|
|
24
25
|
constructor(edits) {
|
|
25
26
|
this._edits = edits;
|
|
26
27
|
}
|
|
@@ -37,32 +38,32 @@ class Editor {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
class PropertyEditor extends Editor {
|
|
40
|
-
rename(
|
|
41
|
+
rename(ecClass, propertyName, newName) {
|
|
41
42
|
this.add({
|
|
42
43
|
type: SchemaEditType.RenameProperty,
|
|
43
|
-
key: `${
|
|
44
|
+
key: `${ecClass.fullName}.${propertyName}`,
|
|
44
45
|
value: newName,
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
skip(
|
|
48
|
+
skip(ecClass, propertyName) {
|
|
48
49
|
this.add({
|
|
49
50
|
type: SchemaEditType.Skip,
|
|
50
|
-
key: `${
|
|
51
|
+
key: `${ecClass.fullName}.${propertyName}`,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
class ItemEditor extends Editor {
|
|
55
|
-
rename(
|
|
56
|
+
rename(schemaItem, newName) {
|
|
56
57
|
this.add({
|
|
57
58
|
type: SchemaEditType.RenameSchemaItem,
|
|
58
|
-
key:
|
|
59
|
+
key: schemaItem.key.fullName,
|
|
59
60
|
value: newName,
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
skip(
|
|
63
|
+
skip(schemaItem) {
|
|
63
64
|
this.add({
|
|
64
65
|
type: SchemaEditType.Skip,
|
|
65
|
-
key:
|
|
66
|
+
key: schemaItem.fullName,
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -72,6 +73,9 @@ class ItemEditor extends Editor {
|
|
|
72
73
|
* @alpha
|
|
73
74
|
*/
|
|
74
75
|
class SchemaEdits {
|
|
76
|
+
_edits;
|
|
77
|
+
properties;
|
|
78
|
+
items;
|
|
75
79
|
/**
|
|
76
80
|
* @alpha
|
|
77
81
|
*/
|
|
@@ -86,26 +90,27 @@ class SchemaEdits {
|
|
|
86
90
|
/**
|
|
87
91
|
* @internal
|
|
88
92
|
*/
|
|
89
|
-
async applyTo(differenceResult) {
|
|
90
|
-
const postProcessing = [];
|
|
93
|
+
async applyTo(differenceResult, nameMapping) {
|
|
91
94
|
for (const schemaEdit of this._edits) {
|
|
92
95
|
if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {
|
|
93
|
-
(0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit
|
|
96
|
+
(0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit);
|
|
97
|
+
nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);
|
|
94
98
|
}
|
|
95
99
|
if (schemaEdit.type === SchemaEditType.RenameProperty) {
|
|
96
100
|
(0, RenameEditHandler_1.applyRenamePropertyEdit)(differenceResult, schemaEdit);
|
|
101
|
+
nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);
|
|
97
102
|
}
|
|
98
103
|
if (schemaEdit.type === SchemaEditType.Skip) {
|
|
99
104
|
(0, SkipEditHandler_1.applySkipEdit)(differenceResult, schemaEdit);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
for (const callback of postProcessing) {
|
|
103
|
-
callback();
|
|
104
|
-
}
|
|
105
107
|
}
|
|
106
108
|
toJSON() {
|
|
107
109
|
return this._edits;
|
|
108
110
|
}
|
|
111
|
+
[Symbol.iterator]() {
|
|
112
|
+
return this._edits[Symbol.iterator]();
|
|
113
|
+
}
|
|
109
114
|
}
|
|
110
115
|
exports.SchemaEdits = SchemaEdits;
|
|
111
116
|
//# sourceMappingURL=SchemaEdits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,2DAAyF;AACzF,uDAAkD;AAElD;;;GAGG;AACH,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,mDAAiC,CAAA;IACjC,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAwCD,MAAe,MAAM;IACF,MAAM,CAAwB;IAE/C,YAAY,KAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAES,GAAG,CAAC,IAAoB;QAChC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,OAAO,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC;QAC5D,CAAC,CAAC,CAAC;QAEH,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,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C;QAClC,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,gBAAwC,EAAE,WAAwB;QACrF,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;gBACxD,IAAA,6CAAyB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;gBACxD,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAC/D,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;gBACtD,IAAA,2CAAuB,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;gBACtD,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YACnE,CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAA,+BAAa,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;CACF;AA9CD,kCA8CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { ECClass, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport type { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { NameMapping } from \"./NameMapping\";\nimport { applyRenamePropertyEdit, applyRenameSchemaItemEdit } from \"./RenameEditHandler\";\nimport { applySkipEdit } from \"./SkipEditHandler\";\n\n/**\n * An enumeration that has all the schema edit names.\n * @alpha\n */\nexport enum SchemaEditType {\n RenameSchemaItem = \"RenameSchemaItem\",\n RenameProperty = \"RenameProperty\",\n Skip = \"Skip\",\n}\n\n/**\n * Schema edit entry to rename a schema item.\n * @alpha\n */\nexport interface RenameSchemaItemEdit {\n type: SchemaEditType.RenameSchemaItem;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to rename a property of a class.\n * @alpha\n */\nexport interface RenamePropertyEdit {\n type: SchemaEditType.RenameProperty;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to skip a certain schema element matching the given key.\n * @alpha\n */\nexport interface SkipEdit {\n type: SchemaEditType.Skip;\n key: string;\n}\n\n/**\n * Union for all supported edits that can be applied to a schema.\n * @alpha\n */\nexport type AnySchemaEdits =\n SkipEdit |\n RenameSchemaItemEdit |\n RenamePropertyEdit;\n\nabstract class Editor {\n private readonly _edits: Array<AnySchemaEdits>;\n\n constructor(edits: Array<AnySchemaEdits>) {\n this._edits = edits;\n }\n\n protected add(edit: AnySchemaEdits) {\n const overrideEntry = this._edits.findIndex((entry) => {\n return entry.type === edit.type && entry.key === edit.key;\n });\n\n if (overrideEntry > -1) {\n this._edits[overrideEntry] = edit;\n } else {\n this._edits.push(edit);\n }\n }\n}\n\nclass PropertyEditor extends Editor {\n\n public rename(ecClass: ECClass, propertyName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameProperty,\n key: `${ecClass.fullName}.${propertyName}`,\n value: newName,\n });\n }\n\n public skip(ecClass: ECClass, propertyName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: `${ecClass.fullName}.${propertyName}`,\n });\n }\n}\n\nclass ItemEditor extends Editor {\n public rename(schemaItem: SchemaItem, newName: string) {\n this.add({\n type: SchemaEditType.RenameSchemaItem,\n key: schemaItem.key.fullName,\n value: newName,\n });\n }\n\n public skip(schemaItem: SchemaItem) {\n this.add({\n type: SchemaEditType.Skip,\n key: schemaItem.fullName,\n });\n }\n}\n\n/**\n * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class\n * is to support saving of edits and load them again if needed.\n * @alpha\n */\nexport class SchemaEdits implements Iterable<AnySchemaEdits> {\n private readonly _edits: Array<AnySchemaEdits>;\n\n public readonly properties: PropertyEditor;\n public readonly items: ItemEditor;\n\n /**\n * @alpha\n */\n constructor(initialize?: ReadonlyArray<AnySchemaEdits>) {\n this._edits = [];\n\n if (initialize) {\n this._edits.push(...initialize);\n }\n\n this.items = new ItemEditor(this._edits);\n this.properties = new PropertyEditor(this._edits);\n }\n\n /**\n * @internal\n */\n public async applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void> {\n for (const schemaEdit of this._edits) {\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\n applyRenameSchemaItemEdit(differenceResult, schemaEdit);\n nameMapping.addItemMapping(schemaEdit.key, schemaEdit.value);\n }\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\n applyRenamePropertyEdit(differenceResult, schemaEdit);\n nameMapping.addPropertyMapping(schemaEdit.key, schemaEdit.value);\n }\n if (schemaEdit.type === SchemaEditType.Skip) {\n applySkipEdit(differenceResult, schemaEdit);\n }\n }\n }\n\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\n return this._edits;\n }\n\n public [Symbol.iterator](): Iterator<AnySchemaEdits> {\n return this._edits[Symbol.iterator]();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":";A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EAAE,CAAC;QACtC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB;IAChF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,sBAAsB,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB,EAAE,QAAgB;IACzG,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAaH,sCAkBC;AAzBD;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,MAA8B,EAAE,IAAc;IAC1E,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG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CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,sBAAsB,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB,EAAE,QAAgB;IACzG,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { AnySchemaDifference, SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport type { AnySchemaDifferenceConflict } from \"../../Differencing/SchemaConflicts\";\nimport type { SkipEdit } from \"./SchemaEdits\";\n\n/**\n * Applies a skip edit to the schema differences. It basically removes all entries that\n * that are associated with the item to skip.\n * @param result The result of a schema differencing run\n * @param edit The skip edit to be applied.\n * @internal\n */\nexport function applySkipEdit(result: SchemaDifferenceResult, edit: SkipEdit) {\n const [schemaName, itemName, pathName] = edit.key.split(\".\") as [string, string, string | undefined];\n if (!result.sourceSchemaName.startsWith(schemaName)) {\n return;\n }\n\n const foundIndices = pathName !== undefined\n ? findRelatedItemEntries(result, itemName, pathName)\n : findItemEntries(result, itemName);\n\n const skippedDifferences: AnySchemaDifference[] = [];\n for (const index of foundIndices.reverse()) {\n skippedDifferences.push(...result.differences.splice(index, 1));\n }\n\n if (result.conflicts) {\n removeRelatedConflicts(result.conflicts, skippedDifferences);\n }\n}\n\nfunction removeRelatedConflicts(conflicts: AnySchemaDifferenceConflict[], skippedDifferences: AnySchemaDifference[]) {\n const indices: number[] = [];\n conflicts.forEach((conflict, index) => {\n if (skippedDifferences.includes(conflict.difference)) {\n indices.push(index);\n }\n });\n\n for (const index of indices.reverse()) {\n conflicts.splice(index, 1);\n }\n}\n\nfunction findItemEntries({ differences }: SchemaDifferenceResult, itemName: string): number[] {\n const found: number[] = [];\n differences.forEach((difference, index) => {\n if (\"itemName\" in difference && difference.itemName === itemName) {\n found.push(index);\n }\n });\n return found;\n}\n\nfunction findRelatedItemEntries({ differences }: SchemaDifferenceResult, itemName: string, pathName: string): number[] {\n const found: number[] = [];\n differences.forEach((difference, index) => {\n if (\"itemName\" in difference && difference.itemName === itemName && \"path\" in difference && difference.path === pathName) {\n found.push(index);\n }\n });\n return found;\n}\n\n"]}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addEntityClass = addEntityClass;
|
|
4
4
|
exports.modifyEntityClass = modifyEntityClass;
|
|
5
5
|
exports.addClassMixins = addClassMixins;
|
|
6
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
7
6
|
const ClassMerger_1 = require("./ClassMerger");
|
|
8
7
|
const Utils_1 = require("./Utils");
|
|
9
8
|
/**
|
|
@@ -38,7 +37,7 @@ async function modifyEntityClass(context, change, itemKey) {
|
|
|
38
37
|
async function addClassMixins(context, change) {
|
|
39
38
|
for (const mixinFullName of change.difference) {
|
|
40
39
|
const mixinKey = await (0, Utils_1.updateSchemaItemKey)(context, mixinFullName);
|
|
41
|
-
const entityKey =
|
|
40
|
+
const entityKey = (0, Utils_1.toItemKey)(context, change.itemName);
|
|
42
41
|
await context.editor.entities.addMixin(entityKey, mixinKey);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;AA1CD,+CAA4C;AAC5C,mCAAyD;AAEzD;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACrE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QAEjC,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IAClF,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,IAAA,iBAAS,EAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { toItemKey, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new EntityClass into the target schema.\n * @internal\n */\nexport async function addEntityClass(context: SchemaMergeContext, change: EntityClassDifference) {\n await context.editor.entities.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n schemaItemType: change.schemaType,\n\n ...change.difference,\n });\n}\n\n/**\n * Merges differences to an existing EntityClass in the target schema.\n * @internal\n */\nexport async function modifyEntityClass(context: SchemaMergeContext, change: EntityClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableEntityClass;\n if(change.difference.mixins !== undefined) {\n for(const mixin of change.difference.mixins) {\n const mixinKey = await updateSchemaItemKey(context, mixin);\n await context.editor.entities.addMixin(itemKey, mixinKey);\n }\n }\n\n return modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges Mixins to Entity Class schema items.\n * @internal\n */\nexport async function addClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\n for(const mixinFullName of change.difference) {\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\n const entityKey = toItemKey(context, change.itemName);\n await context.editor.entities.addMixin(entityKey, mixinKey);\n }\n}\n"]}
|
|
@@ -19,7 +19,7 @@ async function addEnumeration(context, change) {
|
|
|
19
19
|
throw new Error("Enumerations must define whether enumeration is strict.");
|
|
20
20
|
}
|
|
21
21
|
if (change.difference.enumerators === undefined) {
|
|
22
|
-
throw new Error("Enumerations must define at least
|
|
22
|
+
throw new Error("Enumerations must define at least one enumerator.");
|
|
23
23
|
}
|
|
24
24
|
await context.editor.enumerations.createFromProps(context.targetSchemaKey, {
|
|
25
25
|
...change.difference,
|