@itwin/ecschema-editing 4.5.0-dev.9 → 4.6.0-dev.0
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 +46 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +76 -0
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaConflicts.js +56 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +43 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +501 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -0
- package/lib/cjs/Differencing/SchemaDifference.d.ts +150 -0
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaDifference.js +54 -0
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -0
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +9 -2
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +25 -0
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +8 -2
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +29 -6
- 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.d.ts +7 -1
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +15 -0
- 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.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.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/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/MutableUnit.js.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.d.ts +7 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +20 -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.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +1 -5
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +4 -3
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +57 -49
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +3 -2
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +22 -7
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +1 -5
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +21 -0
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PropertyMerger.js +315 -0
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -0
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +15 -0
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/RelationshipClassMerger.js +132 -0
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -0
- package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +7 -3
- package/lib/cjs/Merging/SchemaMerger.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/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.js.map +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.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.d.ts +4 -0
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +4 -0
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +10 -10
- package/public/locales/en/ECSchemaEditing.json +26 -26
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts +0 -15
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/AnyPropertyMerger.js +0 -71
- package/lib/cjs/Merging/AnyPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +0 -32
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.js +0 -143
- package/lib/cjs/Merging/ArrayPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts +0 -16
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js +0 -90
- package/lib/cjs/Merging/ClassPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +0 -24
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +0 -106
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/StructPropertyMerger.d.ts +0 -11
- package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/StructPropertyMerger.js +0 -47
- package/lib/cjs/Merging/StructPropertyMerger.js.map +0 -1
|
@@ -7,8 +7,8 @@ exports.ClassMerger = void 0;
|
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
9
|
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
10
|
-
const ClassPropertyMerger_1 = require("./ClassPropertyMerger");
|
|
11
10
|
const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
|
|
11
|
+
const PropertyMerger_1 = require("./PropertyMerger");
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
@@ -19,8 +19,8 @@ class ClassMerger {
|
|
|
19
19
|
async create(_schemaKey, ecClass) {
|
|
20
20
|
return { errorMessage: `${(0, ecschema_metadata_1.schemaItemTypeToString)(ecClass.schemaItemType)} class type is not implemented.` };
|
|
21
21
|
}
|
|
22
|
-
async
|
|
23
|
-
return {
|
|
22
|
+
async merge(itemKey, _change) {
|
|
23
|
+
return { itemKey };
|
|
24
24
|
}
|
|
25
25
|
async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
|
|
26
26
|
const mutableClass = ecClass;
|
|
@@ -83,38 +83,59 @@ class ClassMerger {
|
|
|
83
83
|
}
|
|
84
84
|
return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.` };
|
|
85
85
|
}
|
|
86
|
-
async
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
async mergeAttributeValueChanges(itemKey, propertyValueChanges) {
|
|
87
|
+
if (propertyValueChanges.length > 0) {
|
|
88
|
+
const targetItem = await this.context.targetSchema.lookupItem(itemKey);
|
|
89
|
+
if (targetItem === undefined) {
|
|
90
|
+
return { errorMessage: `'${itemKey.name}' class could not be located in the merged schema.` };
|
|
91
|
+
}
|
|
92
|
+
for (const change of propertyValueChanges) {
|
|
93
|
+
const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs;
|
|
94
|
+
const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);
|
|
95
|
+
if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
|
|
96
|
+
return results;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
return {};
|
|
100
99
|
}
|
|
101
|
-
return {
|
|
100
|
+
return { itemKey };
|
|
102
101
|
}
|
|
103
|
-
async
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
async handleError(callback) {
|
|
103
|
+
const result = await callback;
|
|
104
|
+
if (result.errorMessage) {
|
|
105
|
+
throw new Error(result.errorMessage);
|
|
106
106
|
}
|
|
107
|
+
}
|
|
108
|
+
async mergePropertyChanges(itemKey, propertyChanges) {
|
|
107
109
|
const targetItem = await this.context.targetSchema.lookupItem(itemKey);
|
|
108
110
|
if (targetItem === undefined) {
|
|
109
|
-
|
|
111
|
+
return { itemKey, errorMessage: `'${itemKey.name}' class could not be located in the merged schema.` };
|
|
110
112
|
}
|
|
111
|
-
for (const change of
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
for (const change of propertyChanges) {
|
|
114
|
+
if (change.propertyMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
|
|
115
|
+
if (await targetItem.getProperty(change.ecTypeName) !== undefined) {
|
|
116
|
+
return { itemKey, errorMessage: `Merged schema already contains a class '${itemKey.name}' property '${change.ecTypeName}'.` };
|
|
117
|
+
}
|
|
118
|
+
const sourceProperty = change.propertyMissing.diagnostic.ecDefinition;
|
|
119
|
+
const results = await (0, PropertyMerger_1.createPropertyFromProps)(this.context, itemKey, sourceProperty);
|
|
120
|
+
if (results.errorMessage !== undefined) {
|
|
121
|
+
return { itemKey, errorMessage: results.errorMessage };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const targetProperty = (await targetItem.getProperty(change.ecTypeName));
|
|
126
|
+
const results = await (0, PropertyMerger_1.mergePropertyAttributeValueChanges)(this.context, targetProperty, change.propertyValueChanges);
|
|
127
|
+
if (results.errorMessage !== undefined) {
|
|
128
|
+
return { itemKey, errorMessage: results.errorMessage };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const mergeResults = await (0, CustomAttributeMerger_1.mergeCustomAttributes)(this.context, change.customAttributeChanges.values(), async (ca) => {
|
|
132
|
+
return this.context.editor.entities.addCustomAttributeToProperty(itemKey, change.ecTypeName, ca);
|
|
133
|
+
});
|
|
134
|
+
if (mergeResults.errorMessage !== undefined) {
|
|
135
|
+
return { itemKey, errorMessage: mergeResults.errorMessage };
|
|
116
136
|
}
|
|
117
137
|
}
|
|
138
|
+
return { itemKey };
|
|
118
139
|
}
|
|
119
140
|
// First pass to create missing changes
|
|
120
141
|
static async mergeItemStubChanges(context, classChanges) {
|
|
@@ -127,44 +148,31 @@ class ClassMerger {
|
|
|
127
148
|
if (await context.targetSchema.lookupItem(targetItemKey) !== undefined) {
|
|
128
149
|
throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);
|
|
129
150
|
}
|
|
130
|
-
|
|
131
|
-
if (results.errorMessage !== undefined) {
|
|
132
|
-
throw new Error(results.errorMessage);
|
|
133
|
-
}
|
|
151
|
+
await merger.handleError(merger.create(context.targetSchema.schemaKey, sourceItem));
|
|
134
152
|
}
|
|
135
153
|
}
|
|
136
154
|
}
|
|
137
155
|
// 2nd pass to merge baseClass, properties, mixins and CA.
|
|
138
156
|
static async mergeItemContentChanges(context, classChanges) {
|
|
139
157
|
const merger = new this(context);
|
|
140
|
-
let mergeResults;
|
|
141
158
|
for (const change of classChanges) {
|
|
142
159
|
const targetItemKey = new ecschema_metadata_1.SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);
|
|
143
160
|
const changeType = change.schemaItemMissing?.changeType;
|
|
144
161
|
if (change.baseClassDelta !== undefined) {
|
|
145
|
-
|
|
146
|
-
if (results.errorMessage !== undefined) {
|
|
147
|
-
throw new Error(results.errorMessage);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (change.entityMixinChanges.size > 0) {
|
|
151
|
-
const results = await merger.addMixins(targetItemKey, change.entityMixinChanges.values(), changeType);
|
|
152
|
-
if (results.errorMessage !== undefined) {
|
|
153
|
-
throw new Error(results.errorMessage);
|
|
154
|
-
}
|
|
162
|
+
await merger.handleError(merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType));
|
|
155
163
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
// merge class attributes
|
|
165
|
+
await merger.handleError(merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges));
|
|
166
|
+
// merge class mixins/constraints/etc
|
|
167
|
+
await merger.handleError(merger.merge(targetItemKey, change));
|
|
168
|
+
// merge class property attribute values
|
|
169
|
+
if (change.propertyChanges.size > 0) {
|
|
170
|
+
await merger.handleError(merger.mergePropertyChanges(targetItemKey, change.propertyChanges.values()));
|
|
160
171
|
}
|
|
161
172
|
// merge custom attributes
|
|
162
|
-
|
|
173
|
+
await merger.handleError((0, CustomAttributeMerger_1.mergeCustomAttributes)(merger.context, change.customAttributeChanges.values(), async (ca) => {
|
|
163
174
|
return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);
|
|
164
|
-
});
|
|
165
|
-
if (mergeResults.errorMessage !== undefined) {
|
|
166
|
-
throw new Error(mergeResults.errorMessage);
|
|
167
|
-
}
|
|
175
|
+
}));
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAiK;AAIjK,+DAAgI;AAChI,+DAA4D;AAC5D,mEAAgE;AAEhE;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,MAAM,CAAC,UAAqB,EAAE,OAAe;QAC3D,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,0CAAsB,EAAC,OAAO,CAAC,cAAc,CAAC,iCAAiC,EAAC,CAAC;IAC7G,CAAC;IAES,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,KAAK,CAAC,IAAI,SAAS,OAAO,CAAC,IAAI,6BAA6B,EAAE,CAAC;IACzG,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACpH,MAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,QAAO,aAAa,EAAE;YACpB,KAAK,gBAAgB;gBACnB,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,0BAA0B,EAAE,CAAC;iBACxF;gBACD,OAAO,IAAI,CAAC;YAEd,KAAK,OAAO;gBACV,YAAY,CA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AK,EAAE,EAAE,EAAE,EAAE;gBAC9G,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF;AAtLD,kCAsLC","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 { ECClass, ECClassModifier, Mixin, parseClassModifier, SchemaItemKey, SchemaItemType, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { BaseClassDelta, ChangeType, ClassChanges, EntityMixinChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\r\nimport { ClassPropertyMerger } from \"./ClassPropertyMerger\";\r\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class ClassMerger<TClass extends ECClass> {\r\n protected readonly context: SchemaMergeContext;\r\n\r\n constructor(context: SchemaMergeContext) {\r\n this.context = context;\r\n }\r\n\r\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\r\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\r\n }\r\n\r\n protected async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\r\n return { errorMessage: `Adding mixin '${mixin.name}' to '${itemKey.name}' class is not implemented.` };\r\n }\r\n\r\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n const mutableClass = ecClass as unknown as MutableClass;\r\n switch(attributeName) {\r\n case \"schemaItemType\":\r\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\r\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\r\n }\r\n return true;\r\n\r\n case \"label\":\r\n mutableClass.setDisplayLabel(attributeNewValue);\r\n return true;\r\n\r\n case \"description\":\r\n mutableClass.setDescription(attributeNewValue);\r\n return true;\r\n\r\n case \"modifier\":\r\n const modifier = parseClassModifier(attributeNewValue);\r\n if (modifier === undefined) {\r\n return { errorMessage: \"An invalid class modifier has been provided.\" };\r\n }\r\n\r\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\r\n mutableClass.setModifier(modifier);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\r\n }\r\n return false;\r\n }\r\n\r\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\r\n return typeof obj === \"object\" && \"errorMessage\" in obj;\r\n }\r\n\r\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\r\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\r\n if (sourceBaseClass !== undefined) {\r\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : sourceBaseClass.schema.schemaKey);\r\n\r\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\r\n if (sourceBaseClass.schemaItemType === SchemaItemType.EntityClass) {\r\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n } else if (sourceBaseClass.schemaItemType === SchemaItemType.Mixin) {\r\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\r\n }\r\n }\r\n\r\n if (targetBaseClass !== undefined) {\r\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\r\n if (baseClass === undefined) {\r\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\r\n }\r\n if (await baseClass.is(targetBaseClass)) {\r\n if (baseClass.schemaItemType === SchemaItemType.EntityClass) {\r\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n } else if (baseClass.schemaItemType === SchemaItemType.Mixin) {\r\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\r\n }\r\n }\r\n }\r\n }\r\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\r\n }\r\n\r\n private async addMixins(itemKey: SchemaItemKey, entityMixinChanges: Iterable<EntityMixinChanges>, changeType?: ChangeType): Promise<SchemaItemEditResults> {\r\n if (changeType === ChangeType.Missing) {\r\n for (const entityMixinChange of entityMixinChanges) {\r\n for (const change of entityMixinChange.entityMixinChange) {\r\n const mixins = change.diagnostic.messageArgs! as unknown as [Mixin];\r\n for (const mixin of mixins) {\r\n const result = await this.addMixin(itemKey, mixin);\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n }\r\n }\r\n return {};\r\n }\r\n return { errorMessage: `Changing the class '${itemKey.name}' mixins is not supported.`};\r\n }\r\n\r\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]) {\r\n if (propertyValueChanges.length === 0) {\r\n return;\r\n }\r\n\r\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\r\n if (targetItem === undefined) {\r\n throw new Error(`'${itemKey.name}' class could not be located in the merged schema.`);\r\n }\r\n\r\n for (const change of propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\r\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\r\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n }\r\n\r\n // First pass to create missing changes\r\n public static async mergeItemStubChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\r\n const merger = new this(context);\r\n\r\n for (const change of classChanges) {\r\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\r\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\r\n const changeType = change.schemaItemMissing?.changeType;\r\n\r\n if (changeType === ChangeType.Missing) {\r\n\r\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\r\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\r\n }\r\n\r\n const results = await merger.create(context.targetSchema.schemaKey, sourceItem);\r\n if (results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // 2nd pass to merge baseClass, properties, mixins and CA.\r\n public static async mergeItemContentChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>){\r\n const merger = new this(context);\r\n let mergeResults: SchemaItemEditResults;\r\n\r\n for (const change of classChanges) {\r\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\r\n const changeType = change.schemaItemMissing?.changeType;\r\n\r\n if (change.baseClassDelta !== undefined) {\r\n const results = await merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType);\r\n if (results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n\r\n if (change.entityMixinChanges.size > 0) {\r\n const results = await merger.addMixins(targetItemKey, change.entityMixinChanges.values(), changeType);\r\n if (results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n\r\n await merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges);\r\n mergeResults = await ClassPropertyMerger.mergeChanges(context, targetItemKey, change.propertyChanges.values());\r\n if (mergeResults.errorMessage !== undefined) {\r\n throw new Error(mergeResults.errorMessage);\r\n }\r\n\r\n // merge custom attributes\r\n mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\r\n return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);\r\n });\r\n\r\n if (mergeResults.errorMessage !== undefined) {\r\n throw new Error(mergeResults.errorMessage);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAoK;AAIpK,+DAA6H;AAC7H,mEAAgE;AAChE,qDAA+F;AAE/F;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,MAAM,CAAC,UAAqB,EAAE,OAAe;QAC3D,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,0CAAsB,EAAC,OAAO,CAAC,cAAc,CAAC,iCAAiC,EAAC,CAAC;IAC7G,CAAC;IAES,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QACjE,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACpH,MAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,QAAO,aAAa,EAAE;YACpB,KAAK,gBAAgB;gBACnB,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,0BAA0B,EAAE,CAAC;iBACxF;gBACD,OAAO,IAAI,CAAC;YAEd,KAAK,OAAO;gBACV,YAAY,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;YAEd,KAAK,aAAa;gBAChB,YAAY,CAAC,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AU,GAAG,MAAM,CAAC,iBAAiB,EAAE,UAAU,CAAC;YAExD,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE;gBACvC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;aACjG;YAED,yBAAyB;YACzB,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,0BAA0B,CAAC,aAAa,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAExG,qCAAqC;YACrC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;YAE9D,wCAAwC;YACxC,IAAI,MAAM,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,EAAE;gBACnC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;aACvG;YAED,0BAA0B;YAC1B,MAAM,MAAM,CAAC,WAAW,CAAC,IAAA,6CAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBAClH,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC,CAAC;SACL;IACH,CAAC;CACF;AAlMD,kCAkMC","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 { ECClass, ECClassModifier, parseClassModifier, Property, SchemaItemKey, SchemaItemType, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { BaseClassDelta, ChangeType, ClassChanges, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\nimport { createPropertyFromProps, mergePropertyAttributeValueChanges } from \"./PropertyMerger\";\n\n/**\n * @internal\n */\nexport class ClassMerger<TClass extends ECClass> {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\n }\n\n protected async merge(itemKey: SchemaItemKey, _change: ClassChanges): Promise<SchemaItemEditResults> {\n return { itemKey };\n }\n\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const mutableClass = ecClass as unknown as MutableClass;\n switch(attributeName) {\n case \"schemaItemType\":\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\n }\n return true;\n\n case \"label\":\n mutableClass.setDisplayLabel(attributeNewValue);\n return true;\n\n case \"description\":\n mutableClass.setDescription(attributeNewValue);\n return true;\n\n case \"modifier\":\n const modifier = parseClassModifier(attributeNewValue);\n if (modifier === undefined) {\n return { errorMessage: \"An invalid class modifier has been provided.\" };\n }\n\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\n mutableClass.setModifier(modifier);\n return true;\n }\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\n }\n return false;\n }\n\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\n if (sourceBaseClass !== undefined) {\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : sourceBaseClass.schema.schemaKey);\n\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\n if (sourceBaseClass.schemaItemType === SchemaItemType.EntityClass) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n } else if (sourceBaseClass.schemaItemType === SchemaItemType.Mixin) {\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\n }\n }\n\n if (targetBaseClass !== undefined) {\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\n if (baseClass === undefined) {\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\n }\n if (await baseClass.is(targetBaseClass)) {\n if (baseClass.schemaItemType === SchemaItemType.EntityClass) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n } else if (baseClass.schemaItemType === SchemaItemType.Mixin) {\n return this.context.editor.mixins.setMixinBaseClass(itemKey, baseClassKey);\n }\n }\n }\n }\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\n }\n\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]): Promise<SchemaItemEditResults> {\n if (propertyValueChanges.length > 0) {\n\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\n if (targetItem === undefined) {\n return { errorMessage: `'${itemKey.name}' class could not be located in the merged schema.` };\n }\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n }\n }\n\n return { itemKey };\n }\n\n private async handleError(callback: Promise<SchemaItemEditResults>) {\n const result = await callback;\n if (result.errorMessage) {\n throw new Error(result.errorMessage);\n }\n }\n\n private async mergePropertyChanges(itemKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\n if (targetItem === undefined) {\n return { itemKey, errorMessage: `'${itemKey.name}' class could not be located in the merged schema.`};\n }\n\n for (const change of propertyChanges) {\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\n return { itemKey, errorMessage: `Merged schema already contains a class '${itemKey.name}' property '${change.ecTypeName}'.`};\n }\n\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\n const results = await createPropertyFromProps(this.context, itemKey, sourceProperty);\n if (results.errorMessage !== undefined) {\n return { itemKey, errorMessage: results.errorMessage };\n }\n } else {\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\n const results = await mergePropertyAttributeValueChanges(this.context, targetProperty, change.propertyValueChanges);\n if (results.errorMessage !== undefined) {\n return { itemKey, errorMessage: results.errorMessage };\n }\n }\n\n const mergeResults = await mergeCustomAttributes(this.context, change.customAttributeChanges.values(), async (ca) => {\n return this.context.editor.entities.addCustomAttributeToProperty(itemKey, change.ecTypeName, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n return { itemKey, errorMessage: mergeResults.errorMessage};\n }\n }\n return { itemKey };\n }\n\n // First pass to create missing changes\n public static async mergeItemStubChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\n const merger = new this(context);\n\n for (const change of classChanges) {\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n const changeType = change.schemaItemMissing?.changeType;\n\n if (changeType === ChangeType.Missing) {\n\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\n }\n\n await merger.handleError(merger.create(context.targetSchema.schemaKey, sourceItem));\n }\n }\n }\n\n // 2nd pass to merge baseClass, properties, mixins and CA.\n public static async mergeItemContentChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>){\n const merger = new this(context);\n for (const change of classChanges) {\n const targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n const changeType = change.schemaItemMissing?.changeType;\n\n if (change.baseClassDelta !== undefined) {\n await merger.handleError(merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType));\n }\n\n // merge class attributes\n await merger.handleError(merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges));\n\n // merge class mixins/constraints/etc\n await merger.handleError(merger.merge(targetItemKey, change));\n\n // merge class property attribute values\n if (change.propertyChanges.size > 0) {\n await merger.handleError(merger.mergePropertyChanges(targetItemKey, change.propertyChanges.values()));\n }\n\n // merge custom attributes\n await merger.handleError(mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);\n }));\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","sourcesContent":["// /*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,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CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","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 { Constant, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\n\n/**\n * @internal\n */\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\n /**\n * Creates the property value resolver for [[Constant]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\n return {\n phenomenon: (phenomenonFullName, targetItemKey) => {\n // There are two options, either the phenomenon was referenced from another\n // schema or it is defined in the same schema as the constant to be merged.\n // In the latter case, the changes would report a different property value that\n // refers to the source schema. So that needs to be changed here.\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${phenomenonName}`;\n }\n return phenomenonFullName;\n },\n numerator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\n }\n return value;\n },\n denominator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\n }\n return value;\n },\n };\n }\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+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BAA8B,CAAC,UAAU,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuH;AACvH,+DAA0F;AAO1F;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CAAC,YAAgC,EAAE,OAAkD,EAAE,QAAoE;IACpM,KAAK,MAAM,8BAA8B,IAAI,OAAO,EAAE;QACpD,KAAK,MAAM,MAAM,IAAI,8BAA8B,CAAC,sBAAsB,EAAE;YAC1E,IAAI,MAAM,CAAC,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAC5C,MAAM,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,WAAgC,CAAC;gBACnF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAI,8BAAU,CAAC,aAAa,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;gBAC1F,MAAM,aAAa,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC;oBAC7G,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS;oBACrC,CAAC,CAAC,IAAI,6BAAS,CAAC,UAAU,CAAC,CAC5B,CAAC;gBACF,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC;gBAC9G,IAAI,qBAAqB,KAAK,SAAS,EAAE;oBACvC,OAAO,EAAE,YAAY,EAAE,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,EAAC,CAAC;iBACnH;gBAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC;oBAC7B,GAAG,qBAAqB;oBACxB,SAAS,EAAE,qBAAqB,CAAC,QAAQ;iBAC1C,CAAC,CAAC;gBAEH,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,OAAO,EAAG,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;iBAChD;aACF;iBAAM;gBACL,OAAO,EAAE,YAAY,EAAE,+BAA+B,8BAA8B,CAAC,UAAU,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","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 { CustomAttribute, CustomAttributeClass, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ChangeType, CustomAttributeContainerChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\ninterface EditResults {\n errorMessage?: string;\n}\n\n/**\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\n * a scope (Class, Property, Schema) specific handler.\n * @param mergeContext The current schema merging context.\n * @param changes An iterable with custom attribute changes.\n * @param callback The callback to add the custom attribute with a scope specific editor.\n * @returns A EditResults object.\n * @internal\n */\nexport async function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults> {\n for (const customAttributeContainerChange of changes) {\n for (const change of customAttributeContainerChange.customAttributeChanges) {\n if (change.changeType === ChangeType.Missing) {\n const [sourceCustomAttribute] = change.diagnostic.messageArgs as [CustomAttribute];\n const [schemaName, itemName] = SchemaItem.parseFullName(sourceCustomAttribute.className);\n const schemaItemKey = new SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)\n ? mergeContext.targetSchema.schemaKey\n : new SchemaKey(schemaName),\n );\n const targetCustomAttribute = await mergeContext.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\n if (targetCustomAttribute === undefined) {\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`};\n }\n\n const results = await callback({\n ...sourceCustomAttribute,\n className: targetCustomAttribute.fullName,\n });\n\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage };\n }\n } else {\n return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.`};\n }\n }\n }\n return {};\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { EntityClass,
|
|
1
|
+
import { EntityClass, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
2
2
|
import { ClassMerger } from "./ClassMerger";
|
|
3
3
|
import { SchemaItemEditResults } from "../Editing/Editor";
|
|
4
|
+
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
4
5
|
/**
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
8
|
export default class EntityClassMerger extends ClassMerger<EntityClass> {
|
|
8
9
|
protected create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults>;
|
|
9
|
-
protected
|
|
10
|
+
protected merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults>;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=EntityClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAS,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAc,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW,CAAC,WAAW,CAAC;cAC5C,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAIlF,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAuB9G"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
*--------------------------------------------------------------------------------------------*/
|
|
7
7
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
8
|
const ClassMerger_1 = require("./ClassMerger");
|
|
9
|
+
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
9
10
|
/**
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
@@ -13,13 +14,27 @@ class EntityClassMerger extends ClassMerger_1.ClassMerger {
|
|
|
13
14
|
async create(schemaKey, ecClass) {
|
|
14
15
|
return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);
|
|
15
16
|
}
|
|
16
|
-
async
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
async merge(itemKey, changes) {
|
|
18
|
+
if (changes.entityMixinChanges.size > 0) {
|
|
19
|
+
if (changes.schemaItemMissing?.changeType !== SchemaChanges_1.ChangeType.Missing) {
|
|
20
|
+
return { errorMessage: `Changing the entity class '${itemKey.name}' mixins is not supported.` };
|
|
21
|
+
}
|
|
22
|
+
for (const change of changes.entityMixinChanges.values()) {
|
|
23
|
+
for (const entityMixinChange of change.entityMixinChange) {
|
|
24
|
+
const mixins = entityMixinChange.diagnostic.messageArgs;
|
|
25
|
+
for (const mixin of mixins) {
|
|
26
|
+
const mixinKey = new ecschema_metadata_1.SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)
|
|
27
|
+
? this.context.targetSchema.schemaKey
|
|
28
|
+
: mixin.schema.schemaKey);
|
|
29
|
+
const result = await this.context.editor.entities.addMixin(itemKey, mixinKey);
|
|
30
|
+
if (result.errorMessage !== undefined) {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { itemKey };
|
|
23
38
|
}
|
|
24
39
|
}
|
|
25
40
|
exports.default = EntityClassMerger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAE5C,+DAAuE;AAEvE;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QAC1E,IAAI,OAAO,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,EAAE;YACvC,IAAI,OAAO,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAChE,OAAO,EAAE,YAAY,EAAE,8BAA8B,OAAO,CAAC,IAAI,4BAA4B,EAAC,CAAC;aAChG;YAED,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE;gBACxD,KAAK,MAAM,iBAAiB,IAAI,MAAM,CAAC,iBAAiB,EAAE;oBACxD,MAAM,MAAM,GAAG,iBAAiB,CAAC,UAAU,CAAC,WAAkC,CAAC;oBAC/E,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;wBAC1B,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;4BAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;4BACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;wBAC5B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;wBAC9E,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;4BACrC,OAAO,MAAM,CAAC;yBACf;qBACF;iBACF;aACF;SACF;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AA5BD,oCA4BC","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 { EntityClass, Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ChangeType, ClassChanges } from \"../Validation/SchemaChanges\";\n\n/**\n * @internal\n */\nexport default class EntityClassMerger extends ClassMerger<EntityClass> {\n protected override async create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults> {\n return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);\n }\n\n protected override async merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults> {\n if (changes.entityMixinChanges.size > 0) {\n if (changes.schemaItemMissing?.changeType !== ChangeType.Missing) {\n return { errorMessage: `Changing the entity class '${itemKey.name}' mixins is not supported.`};\n }\n\n for (const change of changes.entityMixinChanges.values()) {\n for (const entityMixinChange of change.entityMixinChange) {\n const mixins = entityMixinChange.diagnostic.messageArgs! as unknown as [Mixin];\n for (const mixin of mixins) {\n const mixinKey = new SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : mixin.schema.schemaKey);\n const result = await this.context.editor.entities.addMixin(itemKey, mixinKey);\n if (result.errorMessage !== undefined) {\n return result;\n }\n }\n }\n }\n }\n return { itemKey };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4E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CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4EAA4E;YAC5E,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAEzE,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC5B,MAAM,KAAK,CAAC,eAAe,gBAAgB,CAAC,UAAU,wBAAwB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAClG;gBAED,4EAA4E;gBAC5E,+DAA+D;gBAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAEtD,8EAA8E;gBAC9E,gFAAgF;gBAChF,SAAS;aACV;YAED,6EAA6E;YAC7E,4EAA4E;YAC5E,8EAA8E;YAC9E,KAAI,MAAM,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;gBAC9D,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,WAAmC,CAAC,CAAC;aAC5G;SACF;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,OAAsB,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAsB;QACjH,8EAA8E;QAC9E,oEAAoE;QACpE,IAAG,YAAY,KAAK,OAAO,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","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 { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\n\n/**\n * @internal\n */\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\n\n /** Shorthand property to the enumerations editor. */\n private get _editor() {\n return this.context.editor.enumerations;\n }\n\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\n // In case the enumerator entry does not exist in the target enumeration the\n // enumeratorMissing property is set and\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\n\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\n if (enumerator === undefined) {\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\n }\n\n // Enumerators are plain javascript objects with out any references to other\n // instances or a schema. That allows to simply copy them over.\n await this._editor.addEnumerator(itemKey, enumerator);\n\n // Since every missing enumerator has delta changes for ech property, the loop\n // must call continue here to avoid having all properties checked and set again.\n continue;\n }\n\n // For changes where the enumerators differ, the enumeratorDeltas property is\n // filled. This allows to change individual enumerator entries. This is only\n // allowed for labels and descriptions, all other deltas would throw an error.\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\n }\n }\n }\n\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\n // In case an enumerator has the same name but different value, the enumerator\n // cannot be merged to keep integrity for the existing schema users.\n if(propertyName === \"value\") {\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\n }\n\n // For the other two properties they shall only be merged if the source value is\n // set. In case they'd be undefined, the current enumerators value shall be kept.\n if(propertyName === \"label\" && value !== undefined) {\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\n }\n if(propertyName === \"description\" && value !== undefined) {\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB,SAAQ,mCAAgC;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AAE,aAAa,CAAC,CAAC;oBACnJ,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;iBAC9G;qBAAM;oBACL,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,CAAC;oBACvD,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAC3F;oBACD,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQ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F;AAvDD,uCAuDC","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 { Format, InvertedUnit, KindOfQuantity, OverrideFormat, SchemaItem, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\nimport { KindOfQuantityChanges } from \"../Validation/SchemaChanges\";\n\n/**\n * @internal\n */\nexport default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {\n\n protected override async merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges) {\n for (const presentationUnitChange of changes.presentationUnitChanges.values()) {\n for (const change of presentationUnitChange.presentationUnitChange) {\n const format = change.diagnostic.messageArgs![0];\n const isDefault = source.defaultPresentationFormat === format;\n\n if (OverrideFormat.isOverrideFormat(format)) {\n const parentFormat = await this.lookup<Format>(format.parent);\n if (parentFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);\n }\n\n const unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined = [];\n if (format.units !== undefined) {\n for (const [unit, label] of format.units) {\n const targetUnit = await this.lookup<Unit | InvertedUnit>(unit);\n if (targetUnit === undefined) {\n throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);\n }\n unitAndLabels.push([targetUnit, label]);\n }\n }\n const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);\n await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);\n } else {\n const targetFormat = await this.lookup<Format>(format);\n if (targetFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);\n }\n await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);\n }\n }\n }\n }\n\n /**\n *\n * Creates the property value resolver for [[KindOfQuantity]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>> {\n return {\n persistenceUnit: (newValue, targetItemKey, oldValue) => {\n if (oldValue !== undefined && oldValue !== newValue) {\n throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);\n }\n const [schemaName, itemName] = SchemaItem.parseFullName(newValue);\n if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${itemName}`;\n }\n return newValue;\n },\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,KAAK,CAAC;cAEhC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAW5E,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,KAAK,CAAC;cAEhC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAW5E,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;CAU1K"}
|
|
@@ -20,10 +20,6 @@ class MixinMerger extends ClassMerger_1.ClassMerger {
|
|
|
20
20
|
return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);
|
|
21
21
|
}
|
|
22
22
|
async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
|
|
23
|
-
const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
|
|
24
|
-
if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
|
|
25
|
-
return results;
|
|
26
|
-
}
|
|
27
23
|
switch (attributeName) {
|
|
28
24
|
case "appliesTo":
|
|
29
25
|
if (attributeOldValue !== undefined) {
|
|
@@ -31,7 +27,7 @@ class MixinMerger extends ClassMerger_1.ClassMerger {
|
|
|
31
27
|
}
|
|
32
28
|
return true;
|
|
33
29
|
}
|
|
34
|
-
return
|
|
30
|
+
return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
exports.default = MixinMerger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OA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CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAAc,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC5H,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,EAAE;oBACnC,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;iBAC7F;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AAvBD,8BAuBC","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 { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ClassMerger } from \"./ClassMerger\";\n\n/**\n * @internal\n */\nexport default class MixinMerger extends ClassMerger<Mixin> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\n if (ecClass.appliesTo === undefined) {\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\n }\n\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\n ? this.context.targetSchema.schemaKey\n : ecClass.appliesTo.schemaKey);\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\n }\n\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\n }\n return true;\n }\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Property, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import { PropertyEditResults } from "../Editing/Editor";
|
|
4
|
+
import { PropertyValueChange } from "../Validation/SchemaChanges";
|
|
5
|
+
/**
|
|
6
|
+
* Updates property with attribute value changes.
|
|
7
|
+
* @param context The current merging context.
|
|
8
|
+
* @param property The Property object to be changed.
|
|
9
|
+
* @param propertyValueChanges The changes to be applied to the property.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergePropertyAttributeValueChanges(context: SchemaMergeContext, property: Property, propertyValueChanges: PropertyValueChange[]): Promise<PropertyEditResults>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Property through a PropertyProps.
|
|
15
|
+
* @param context The current merging context.
|
|
16
|
+
* @param classKey The SchemaItemKey of the class.
|
|
17
|
+
* @param property The Property object to be cloned.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function createPropertyFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: Property): Promise<PropertyEditResults>;
|
|
21
|
+
//# sourceMappingURL=PropertyMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuI,QAAQ,EAAwF,aAAa,EAAkE,MAAM,0BAA0B,CAAC;AAC9V,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAkBlE;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAYnL;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsCpJ"}
|