@itwin/ecschema-editing 4.6.0-dev.6 → 4.6.0-dev.8
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/Differencing/SchemaConflicts.d.ts +2 -2
- package/lib/cjs/Differencing/SchemaConflicts.js +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +9 -6
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +213 -161
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +354 -78
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +184 -11
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- 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.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts.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.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.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.d.ts +2 -0
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.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/MutablePhenomenon.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts.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.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts.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.d.ts +2 -0
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.d.ts +4 -7
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +26 -23
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +10 -18
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +148 -155
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts +4 -8
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +59 -40
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +16 -13
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +66 -34
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +10 -7
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +41 -29
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.d.ts +9 -9
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +77 -48
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +4 -11
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +57 -53
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts +4 -7
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +24 -25
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts +8 -0
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PhenomenonMerger.js +37 -0
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +8 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.js +34 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -0
- package/lib/cjs/Merging/PropertyMerger.d.ts +6 -14
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +212 -287
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +16 -10
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +121 -112
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +26 -51
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +106 -88
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +21 -9
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +74 -88
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +5 -5
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js +33 -15
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.d.ts +8 -0
- package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/UnitSystemMerger.js +26 -0
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -0
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.d.ts +23 -23
- package/lib/cjs/Validation/ECRules.d.ts.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 +1 -1
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +3 -3
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
- package/public/locales/en/ECSchemaEditing.json +26 -26
- package/lib/cjs/Merging/SchemaItemFactory.d.ts +0 -15
- package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +0 -1
- package/lib/cjs/Merging/SchemaItemFactory.js +0 -82
- package/lib/cjs/Merging/SchemaItemFactory.js.map +0 -1
- package/lib/cjs/Merging/StructClassMerger.d.ts +0 -10
- package/lib/cjs/Merging/StructClassMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/StructClassMerger.js +0 -13
- package/lib/cjs/Merging/StructClassMerger.js.map +0 -1
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type RelationshipClassDifference, type RelationshipConstraintClassDifference, type RelationshipConstraintDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
|
|
3
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
3
4
|
import { SchemaItemEditResults } from "../Editing/Editor";
|
|
4
|
-
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
5
5
|
/**
|
|
6
|
+
* Defines a merge handler to merge RelationshipClass schema items.
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export declare const relationshipClassMerger: SchemaItemMergerHandler<RelationshipClassDifference>;
|
|
10
|
+
/**
|
|
11
|
+
* Merges differences of a Relationship constraint.
|
|
12
|
+
* This only supports modify as the RelationshipConstraints are always set on the Relationship classes.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference): Promise<SchemaItemEditResults>;
|
|
16
|
+
/**
|
|
17
|
+
* Merges differences of a Relationship constraint classes.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<SchemaItemEditResults>;
|
|
15
21
|
//# sourceMappingURL=RelationshipClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,qCAAqC,EAAE,KAAK,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEvK,OAAO,EAAoB,KAAK,uBAAuB,EAAuB,MAAM,oBAAoB,CAAC;AAEzG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBAAuB,CAAC,2BAA2B,CA4BxF,CAAC;AAgCF;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gCAAgC,kCAsCtH;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,qCAAqC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmBjK"}
|
|
@@ -1,132 +1,141 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
-
*--------------------------------------------------------------------------------------------*/
|
|
7
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
3
|
+
exports.mergeRelationshipClassConstraint = exports.mergeRelationshipConstraint = exports.relationshipClassMerger = void 0;
|
|
4
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
8
5
|
const ClassMerger_1 = require("./ClassMerger");
|
|
9
|
-
const
|
|
6
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
10
7
|
/**
|
|
8
|
+
* Defines a merge handler to merge RelationshipClass schema items.
|
|
11
9
|
* @internal
|
|
12
10
|
*/
|
|
13
|
-
|
|
14
|
-
async
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
|
|
18
|
-
const mutableRelationship = ecClass;
|
|
19
|
-
switch (attributeName) {
|
|
20
|
-
case "strength":
|
|
21
|
-
if (attributeOldValue === undefined) {
|
|
22
|
-
const strength = (0, ecschema_metadata_1.parseStrength)(attributeNewValue);
|
|
23
|
-
if (strength === undefined) {
|
|
24
|
-
return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strength value '${attributeNewValue}' has been provided.` };
|
|
25
|
-
}
|
|
26
|
-
mutableRelationship.setStrength(strength);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return { errorMessage: `Changing the relationship '${ecClass.name}' strength is not supported.` };
|
|
30
|
-
case "strengthDirection":
|
|
31
|
-
if (attributeOldValue === undefined) {
|
|
32
|
-
const strengthDirection = (0, ecschema_metadata_1.parseStrengthDirection)(attributeNewValue);
|
|
33
|
-
if (strengthDirection === undefined) {
|
|
34
|
-
return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strengthDirection value '${attributeNewValue}' has been provided.` };
|
|
35
|
-
}
|
|
36
|
-
mutableRelationship.setStrengthDirection(strengthDirection);
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return { errorMessage: `Changing the relationship '${ecClass.name}' strengthDirection is not supported.` };
|
|
11
|
+
exports.relationshipClassMerger = {
|
|
12
|
+
async add(context, change) {
|
|
13
|
+
if (change.difference.strength === undefined) {
|
|
14
|
+
return { errorMessage: "RelationshipClass must define strength" };
|
|
40
15
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
async mergeConstraintAttributes(constraint, attributeName, attributeNewValue, attributeOldValue) {
|
|
44
|
-
switch (attributeName) {
|
|
45
|
-
case "multiplicity":
|
|
46
|
-
if (attributeOldValue === undefined) {
|
|
47
|
-
const multiplicity = ecschema_metadata_1.RelationshipMultiplicity.fromString(attributeNewValue);
|
|
48
|
-
if (multiplicity === undefined) {
|
|
49
|
-
return { errorMessage: `An invalid relationship constraint multiplicity value '${attributeNewValue}' has been provided.` };
|
|
50
|
-
}
|
|
51
|
-
return this.context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);
|
|
52
|
-
}
|
|
53
|
-
return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };
|
|
54
|
-
case "polymorphic":
|
|
55
|
-
if (attributeOldValue === undefined || attributeNewValue === true) {
|
|
56
|
-
return this.context.editor.relationships.setConstraintPolymorphic(constraint, attributeNewValue);
|
|
57
|
-
}
|
|
58
|
-
return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' polymorphic is not supported.` };
|
|
59
|
-
case "roleLabel":
|
|
60
|
-
constraint.roleLabel = attributeNewValue;
|
|
61
|
-
return true;
|
|
62
|
-
case "abstractConstraint":
|
|
63
|
-
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(attributeNewValue);
|
|
64
|
-
const itemKey = new ecschema_metadata_1.SchemaItemKey(itemName, this.context.sourceSchema.schemaKey.compareByName(schemaName)
|
|
65
|
-
? this.context.targetSchema.schemaKey
|
|
66
|
-
: new ecschema_metadata_1.SchemaKey(schemaName));
|
|
67
|
-
const abstractConstraint = await this.context.targetSchema.lookupItem(itemKey);
|
|
68
|
-
if (abstractConstraint === undefined) {
|
|
69
|
-
return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${attributeNewValue} in the context schema.` };
|
|
70
|
-
}
|
|
71
|
-
return this.context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);
|
|
16
|
+
if (change.difference.strengthDirection === undefined) {
|
|
17
|
+
return { errorMessage: "RelationshipClass must define strengthDirection" };
|
|
72
18
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
19
|
+
if (change.difference.source === undefined) {
|
|
20
|
+
return { errorMessage: "RelationshipClass must define a source constraint" };
|
|
21
|
+
}
|
|
22
|
+
if (change.difference.target === undefined) {
|
|
23
|
+
return { errorMessage: "RelationshipClass must define a target constraint" };
|
|
24
|
+
}
|
|
25
|
+
return context.editor.relationships.createFromProps(context.targetSchemaKey, {
|
|
26
|
+
...change.difference,
|
|
27
|
+
name: change.itemName,
|
|
28
|
+
schemaItemType: change.schemaType,
|
|
29
|
+
strength: change.difference.strength,
|
|
30
|
+
strengthDirection: change.difference.strengthDirection,
|
|
31
|
+
source: change.difference.source,
|
|
32
|
+
target: change.difference.target,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
async modify(context, change, itemKey, item) {
|
|
36
|
+
return modifyRelationshipClass(context, change, itemKey, item);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
async function modifyRelationshipClass(context, change, itemKey, item) {
|
|
40
|
+
// The following modifications will only be applied if the items gets modified
|
|
41
|
+
// and not the 2nd pass when adding a RelationshipClass.
|
|
42
|
+
if (change.changeType === "modify") {
|
|
43
|
+
if (change.difference.strength !== undefined) {
|
|
44
|
+
if (item.strength === undefined) {
|
|
45
|
+
const strength = (0, ecschema_metadata_1.parseStrength)(change.difference.strength);
|
|
46
|
+
if (strength === undefined) {
|
|
47
|
+
return { itemKey, errorMessage: `An invalid relationship class strength value '${change.difference.strength}' has been provided.` };
|
|
96
48
|
}
|
|
49
|
+
item.setStrength(strength);
|
|
50
|
+
return { itemKey };
|
|
97
51
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
52
|
+
return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strength is not supported.` };
|
|
53
|
+
}
|
|
54
|
+
if (change.difference.strengthDirection !== undefined) {
|
|
55
|
+
if (item.strengthDirection === undefined) {
|
|
56
|
+
const strengthDirection = (0, ecschema_metadata_1.parseStrengthDirection)(change.difference.strengthDirection);
|
|
57
|
+
if (strengthDirection === undefined) {
|
|
58
|
+
return { itemKey, errorMessage: `An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.` };
|
|
104
59
|
}
|
|
60
|
+
item.setStrengthDirection(strengthDirection);
|
|
61
|
+
return { itemKey };
|
|
105
62
|
}
|
|
63
|
+
return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strengthDirection is not supported.` };
|
|
106
64
|
}
|
|
107
|
-
return { itemKey: constraint.relationshipClass.key };
|
|
108
65
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
66
|
+
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Merges differences of a Relationship constraint.
|
|
70
|
+
* This only supports modify as the RelationshipConstraints are always set on the Relationship classes.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
async function mergeRelationshipConstraint(context, change) {
|
|
74
|
+
if (change.changeType !== "modify") {
|
|
75
|
+
return { errorMessage: "RelationshipConstraints can only be modified." };
|
|
76
|
+
}
|
|
77
|
+
const item = await (0, SchemaItemMerger_1.locateSchemaItem)(context, change.itemName, ecschema_metadata_1.SchemaItemType.RelationshipClass);
|
|
78
|
+
const constraint = item[parseConstraint(change.path)];
|
|
79
|
+
if (change.difference.roleLabel !== undefined) {
|
|
80
|
+
constraint.roleLabel = change.difference.roleLabel;
|
|
81
|
+
}
|
|
82
|
+
if (change.difference.polymorphic !== undefined) {
|
|
83
|
+
const result = await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);
|
|
84
|
+
if (result.errorMessage) {
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (change.difference.multiplicity !== undefined) {
|
|
89
|
+
if (constraint.multiplicity === undefined) {
|
|
90
|
+
const multiplicity = ecschema_metadata_1.RelationshipMultiplicity.fromString(change.difference.multiplicity);
|
|
91
|
+
if (multiplicity === undefined) {
|
|
92
|
+
return { errorMessage: `An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.` };
|
|
120
93
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
94
|
+
const result = await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);
|
|
95
|
+
if (result.errorMessage) {
|
|
96
|
+
return result;
|
|
126
97
|
}
|
|
127
98
|
}
|
|
128
|
-
return {
|
|
99
|
+
return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };
|
|
100
|
+
}
|
|
101
|
+
if (change.difference.abstractConstraint !== undefined) {
|
|
102
|
+
const itemKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, change.difference.abstractConstraint);
|
|
103
|
+
const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey);
|
|
104
|
+
if (abstractConstraint === undefined) {
|
|
105
|
+
return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.` };
|
|
106
|
+
}
|
|
107
|
+
return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);
|
|
129
108
|
}
|
|
109
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
110
|
+
}
|
|
111
|
+
exports.mergeRelationshipConstraint = mergeRelationshipConstraint;
|
|
112
|
+
/**
|
|
113
|
+
* Merges differences of a Relationship constraint classes.
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
async function mergeRelationshipClassConstraint(context, change) {
|
|
117
|
+
if (change.changeType !== "add") {
|
|
118
|
+
return { errorMessage: `Change type ${change.changeType} is not supported for Relationship constraint classes.` };
|
|
119
|
+
}
|
|
120
|
+
const item = await (0, SchemaItemMerger_1.locateSchemaItem)(context, change.itemName, ecschema_metadata_1.SchemaItemType.RelationshipClass);
|
|
121
|
+
const constraint = item[parseConstraint(change.path)];
|
|
122
|
+
for (const constraintName of change.difference) {
|
|
123
|
+
const constraintClassKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, constraintName);
|
|
124
|
+
const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey);
|
|
125
|
+
if (constraintClass === undefined) {
|
|
126
|
+
return { errorMessage: `Could not locate relationship constraint class ${constraintClassKey.name}` };
|
|
127
|
+
}
|
|
128
|
+
const result = await context.editor.relationships.addConstraintClass(constraint, constraintClass);
|
|
129
|
+
if (result.errorMessage) {
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { itemKey: constraint.relationshipClass.key };
|
|
134
|
+
}
|
|
135
|
+
exports.mergeRelationshipClassConstraint = mergeRelationshipClassConstraint;
|
|
136
|
+
function parseConstraint(path) {
|
|
137
|
+
return path.startsWith("$source")
|
|
138
|
+
? "source"
|
|
139
|
+
: "target";
|
|
130
140
|
}
|
|
131
|
-
exports.default = RelationshipClassMerger;
|
|
132
141
|
//# sourceMappingURL=RelationshipClassMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAgN;AAChN,+CAA4C;AAK5C,mEAAgE;AAEhE;;GAEG;AACH,MAAqB,uBAAwB,SAAQ,yB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E;oBACtC,OAAO,OAAO,CAAC;iBAChB;aACF;SACF;QAED,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;IACvD,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QAC1E,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,EAAE;YAExF,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAoB,OAAO,CAAC,CAAC;YACjG,IAAI,iBAAiB,KAAK,SAAS,EAAE;gBACnC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,2CAA2C,OAAO,CAAC,IAAI,yBAAyB,EAAE,CAAC;aACpH;YAED,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,EAAE;gBAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,CAAC;gBACrH,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;oBACrC,OAAO,MAAM,CAAC;iBACf;aACF;YAED,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,EAAE;gBAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,CAAC;gBACrH,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;oBACrC,OAAO,MAAM,CAAC;iBACf;aACF;SACF;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AAxID,0CAwIC","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\nimport { EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraint, RelationshipMultiplicity, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { ClassMerger } from \"./ClassMerger\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { ClassChanges, RelationshipConstraintChanges } from \"../Validation/SchemaChanges\";\r\nimport { MutableRelationshipClass } from \"@itwin/ecschema-metadata/src/Metadata/RelationshipClass\";\r\nimport { MutableRelationshipConstraint } from \"../Editing/Mutable/MutableRelationshipClass\";\r\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class RelationshipClassMerger extends ClassMerger<RelationshipClass> {\r\n\r\n protected override async create(schemaKey: SchemaKey, ecClass: RelationshipClass): Promise<SchemaItemEditResults> {\r\n return this.context.editor.relationships.create(schemaKey, ecClass.name, ecClass.modifier, ecClass.strength, ecClass.strengthDirection);\r\n }\r\n\r\n protected override async mergeAttributes(ecClass: RelationshipClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n const mutableRelationship = ecClass as unknown as MutableRelationshipClass;\r\n switch(attributeName) {\r\n case \"strength\":\r\n if (attributeOldValue === undefined) {\r\n const strength = parseStrength(attributeNewValue);\r\n if (strength === undefined) {\r\n return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strength value '${attributeNewValue}' has been provided.` };\r\n }\r\n mutableRelationship.setStrength(strength);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the relationship '${ecClass.name}' strength is not supported.` };\r\n\r\n case \"strengthDirection\":\r\n if (attributeOldValue === undefined) {\r\n const strengthDirection = parseStrengthDirection(attributeNewValue);\r\n if (strengthDirection === undefined) {\r\n return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strengthDirection value '${attributeNewValue}' has been provided.` };\r\n }\r\n mutableRelationship.setStrengthDirection(strengthDirection);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the relationship '${ecClass.name}' strengthDirection is not supported.` };\r\n }\r\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n\r\n private async mergeConstraintAttributes(constraint: RelationshipConstraint, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n switch(attributeName) {\r\n case \"multiplicity\":\r\n if (attributeOldValue === undefined) {\r\n const multiplicity = RelationshipMultiplicity.fromString(attributeNewValue);\r\n if (multiplicity === undefined) {\r\n return { errorMessage: `An invalid relationship constraint multiplicity value '${attributeNewValue}' has been provided.` };\r\n }\r\n return this.context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\r\n }\r\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };\r\n\r\n case \"polymorphic\":\r\n if (attributeOldValue === undefined || attributeNewValue === true) {\r\n return this.context.editor.relationships.setConstraintPolymorphic(constraint, attributeNewValue);\r\n }\r\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' polymorphic is not supported.` };\r\n\r\n case \"roleLabel\":\r\n (constraint as MutableRelationshipConstraint).roleLabel = attributeNewValue;\r\n return true;\r\n\r\n case \"abstractConstraint\":\r\n const [schemaName, itemName] = SchemaItem.parseFullName(attributeNewValue);\r\n const itemKey = new SchemaItemKey(itemName, this.context.sourceSchema.schemaKey.compareByName(schemaName)\r\n ? this.context.targetSchema.schemaKey\r\n : new SchemaKey(schemaName));\r\n\r\n const abstractConstraint = await this.context.targetSchema.lookupItem<Mixin | EntityClass | RelationshipClass>(itemKey);\r\n if (abstractConstraint === undefined) {\r\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${attributeNewValue} in the context schema.`};\r\n }\r\n return this.context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\r\n }\r\n return false;\r\n }\r\n\r\n private async mergeConstraintChanges(constraint: RelationshipConstraint, constraintChanges: IterableIterator<RelationshipConstraintChanges>): Promise<SchemaItemEditResults> {\r\n for (const change of constraintChanges) {\r\n\r\n for (const constraintClassChange of change.constraintClassChanges) {\r\n const ecClass = constraintClassChange.diagnostic.messageArgs![0];\r\n const itemKey = new SchemaItemKey(ecClass.name, this.context.sourceSchema.schemaKey.matches(ecClass.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : ecClass.schema.schemaKey);\r\n\r\n const constaintClass = await this.context.targetSchema.lookupItem<Mixin | EntityClass | RelationshipClass>(itemKey);\r\n if (constaintClass === undefined) {\r\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the constraint class ${itemKey.fullName} in the context schema.` };\r\n }\r\n const results = await this.context.editor.relationships.addConstraintClass(constraint, constaintClass);\r\n if (results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n\r\n for (const propertyValueChange of change.propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = propertyValueChange.diagnostic.messageArgs!;\r\n const results = await this.mergeConstraintAttributes(constraint, attributeName, attributeNewValue, attributeOldValue);\r\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n\r\n if (change.customAttributeChanges.size > 0) {\r\n const results = await mergeCustomAttributes(this.context, change.customAttributeChanges.values(), async (ca) => {\r\n return this.context.editor.relationships.addCustomAttributeToConstraint(constraint, ca);\r\n });\r\n if (results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n }\r\n\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults> {\r\n if (changes.sourceConstraintChanges.size > 0 || changes.targetConstraintChanges.size > 0) {\r\n\r\n const relationshipClass = await this.context.targetSchema.lookupItem<RelationshipClass>(itemKey);\r\n if (relationshipClass === undefined) {\r\n return { itemKey, errorMessage: `Unable to locate the relationship class ${itemKey.name} in the context schema.` };\r\n }\r\n\r\n if (changes.sourceConstraintChanges.size > 0) {\r\n const result = await this.mergeConstraintChanges(relationshipClass.source, changes.sourceConstraintChanges.values());\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n\r\n if (changes.targetConstraintChanges.size > 0) {\r\n const result = await this.mergeConstraintChanges(relationshipClass.target, changes.targetConstraintChanges.values());\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return { itemKey };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;;AAMA,yDAAyG;AACzG,+CAA4C;AAE5C,gEAAiL;AAKjL;;;GAGG;AACU,QAAA,uBAAuB,GAAyD;IAC3F,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC5C,OAAO,EAAE,YAAY,EAAE,wCAAwC,EAAE,CAAC;SACnE;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACrD,OAAO,EAAE,YAAY,EAAE,iDAAiD,EAAE,CAAC;SAC5E;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE;YAC1C,OAAO,EAAE,YAAY,EAAE,mDAAmD,EAAE,CAAC;SAC9E;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE;YAC1C,OAAO,EAAE,YAAY,EAAE,mDAAmD,EAAE,CAAC;SAC9E;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YAC3E,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EA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AC;QAC/B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,QAAQ,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*--------------------------------------------------------------------------------------------*/\nimport { type RelationshipClassDifference, type RelationshipConstraintClassDifference, type RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\nimport { type MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\nimport { locateSchemaItem, type SchemaItemMergerHandler, updateSchemaItemKey } from \"./SchemaItemMerger\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\ntype ConstraintClassTypes = EntityClass | Mixin | RelationshipClass;\n\n/**\n * Defines a merge handler to merge RelationshipClass schema items.\n * @internal\n */\nexport const relationshipClassMerger: SchemaItemMergerHandler<RelationshipClassDifference> = {\n async add(context, change) {\n if (change.difference.strength === undefined) {\n return { errorMessage: \"RelationshipClass must define strength\" };\n }\n if (change.difference.strengthDirection === undefined) {\n return { errorMessage: \"RelationshipClass must define strengthDirection\" };\n }\n if (change.difference.source === undefined) {\n return { errorMessage: \"RelationshipClass must define a source constraint\" };\n }\n if (change.difference.target === undefined) {\n return { errorMessage: \"RelationshipClass must define a target constraint\" };\n }\n\n return context.editor.relationships.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n strength: change.difference.strength,\n strengthDirection: change.difference.strengthDirection,\n source: change.difference.source,\n target: change.difference.target,\n });\n },\n async modify(context, change, itemKey, item: MutableRelationshipClass) {\n return modifyRelationshipClass(context, change, itemKey, item);\n },\n};\n\nasync function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey, item: MutableRelationshipClass) {\n // The following modifications will only be applied if the items gets modified\n // and not the 2nd pass when adding a RelationshipClass.\n if(change.changeType === \"modify\") {\n if(change.difference.strength !== undefined) {\n if (item.strength === undefined) {\n const strength = parseStrength(change.difference.strength);\n if (strength === undefined) {\n return { itemKey, errorMessage: `An invalid relationship class strength value '${change.difference.strength}' has been provided.` };\n }\n item.setStrength(strength);\n return { itemKey };\n }\n return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strength is not supported.` };\n }\n if(change.difference.strengthDirection !== undefined) {\n if (item.strengthDirection === undefined) {\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\n if (strengthDirection === undefined) {\n return { itemKey, errorMessage: `An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.` };\n }\n item.setStrengthDirection(strengthDirection);\n return { itemKey };\n }\n return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strengthDirection is not supported.` };\n }\n }\n return modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges differences of a Relationship constraint.\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\n * @internal\n */\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\n if(change.changeType !== \"modify\") {\n return { errorMessage: \"RelationshipConstraints can only be modified.\" };\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n if(change.difference.roleLabel !== undefined) {\n constraint.roleLabel = change.difference.roleLabel;\n }\n if(change.difference.polymorphic !== undefined) {\n const result = await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\n if(result.errorMessage) {\n return result;\n }\n }\n if(change.difference.multiplicity !== undefined) {\n if (constraint.multiplicity === undefined) {\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\n if (multiplicity === undefined) {\n return { errorMessage: `An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.` };\n }\n const result = await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\n if(result.errorMessage) {\n return result;\n }\n }\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };\n }\n if(change.difference.abstractConstraint !== undefined) {\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem<ConstraintClassTypes>(itemKey);\n if (abstractConstraint === undefined) {\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`};\n }\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\n }\n return { itemKey: constraint.relationshipClass.key };\n}\n\n/**\n * Merges differences of a Relationship constraint classes.\n * @internal\n */\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<SchemaItemEditResults> {\n if(change.changeType !== \"add\") {\n return { errorMessage: `Change type ${change.changeType} is not supported for Relationship constraint classes.` };\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n for(const constraintName of change.difference) {\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\n const constraintClass = await context.editor.schemaContext.getSchemaItem<ConstraintClassTypes>(constraintClassKey);\n if(constraintClass === undefined) {\n return { errorMessage: `Could not locate relationship constraint class ${constraintClassKey.name}` };\n }\n const result = await context.editor.relationships.addConstraintClass(constraint, constraintClass);\n if(result.errorMessage) {\n return result;\n }\n }\n return { itemKey: constraint.relationshipClass.key };\n}\n\nfunction parseConstraint(path: string): \"source\" | \"target\" {\n return path.startsWith(\"$source\")\n ? \"source\"\n : \"target\";\n}\n"]}
|
|
@@ -1,61 +1,36 @@
|
|
|
1
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
2
|
+
import type { SchemaEditResults, SchemaItemEditResults } from "../Editing/Editor";
|
|
3
|
+
import { AnySchemaDifference, AnySchemaItemDifference, AnySchemaItemPathDifference } from "../Differencing/SchemaDifference";
|
|
1
4
|
import { SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
2
|
-
import { SchemaItemChanges } from "../Validation/SchemaChanges";
|
|
3
|
-
import { SchemaMergeContext } from "./SchemaMerger";
|
|
4
5
|
/**
|
|
5
|
-
* Defines a type-safe interface of Property Value resolver.
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export interface SchemaItemMergerHandler<T extends AnySchemaItemDifference | AnySchemaItemPathDifference> {
|
|
9
|
+
add: (context: SchemaMergeContext, change: T) => Promise<SchemaItemEditResults>;
|
|
10
|
+
modify: (context: SchemaMergeContext, change: T, itemKey: SchemaItemKey, item: any) => Promise<SchemaItemEditResults>;
|
|
11
|
+
}
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* @internal
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
-readonly [key in keyof ReturnType<T["toJSON"]>]: ReturnType<T["toJSON"]>[key];
|
|
16
|
-
};
|
|
15
|
+
export declare function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string): Promise<SchemaItem>;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* Merges the given set of schema items. As schema items may depend or relate with other
|
|
18
|
+
* schema items, the list gets filtered to ensure the items get merged in a certain order.
|
|
19
|
+
* @param context The current merging context.
|
|
20
|
+
* @param itemChanges Set of schema item that differed.
|
|
21
|
+
* @returns An async iterable with the merge result for each schema item.
|
|
22
22
|
* @internal
|
|
23
23
|
*/
|
|
24
|
-
export declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @returns A resolver map with resolvers for the property.
|
|
37
|
-
*/
|
|
38
|
-
protected createPropertyValueResolver(): Promise<PropertyValueResolver<TItem>>;
|
|
39
|
-
/**
|
|
40
|
-
* This overridable method gets called for more complex merging.
|
|
41
|
-
* @param _itemKey The key of the current schema item.
|
|
42
|
-
* @param _source The source item that shall gets merged into.
|
|
43
|
-
* @param _change The schema item change to be applied.
|
|
44
|
-
*/
|
|
45
|
-
protected merge(_itemKey: SchemaItemKey, _source: TItem, _change: SchemaItemChanges): Promise<void>;
|
|
46
|
-
protected lookup<T extends SchemaItem>(schemaItem: T): Promise<T | undefined>;
|
|
47
|
-
/**
|
|
48
|
-
* Merges the given schema item changes in the current context.
|
|
49
|
-
* @param context The merging context
|
|
50
|
-
* @param schemaItemChanges An iterable of item changes.
|
|
51
|
-
*/
|
|
52
|
-
static mergeChanges<TChange extends SchemaItemChanges>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Merges the property values.
|
|
55
|
-
* @param targetItem The current schema item
|
|
56
|
-
* @param changes The property changes.
|
|
57
|
-
*/
|
|
58
|
-
private mergeItemPropertyValues;
|
|
59
|
-
}
|
|
60
|
-
export {};
|
|
24
|
+
export declare function mergeSchemaItems(context: SchemaMergeContext, itemChanges: AnySchemaDifference[]): AsyncGenerator<SchemaEditResults, void, unknown>;
|
|
25
|
+
/**
|
|
26
|
+
* Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateSchemaItemFullName(context: SchemaMergeContext, reference: string): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Updates the given reference if it refers to a SchemaItem in the source Schema and
|
|
32
|
+
* returns a SchemaItemKey. If any other schema is referred the reference is not change.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function updateSchemaItemKey(context: SchemaMergeContext, reference: string): Promise<SchemaItemKey>;
|
|
61
36
|
//# sourceMappingURL=SchemaItemMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,2BAA2B,EAAoB,MAAM,kCAAkC,CAAC;AAC/I,OAAO,EAAkD,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASrH;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,uBAAuB,GAAG,2BAA2B;IACtG,GAAG,EAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACnF,MAAM,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACvH;AAmBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG;AAED;;;;;;;GAOG;AACH,wBAAuB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,oDAwCtG;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAG5F;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,0BAYvF"}
|