@itwin/ecschema-editing 5.0.0-dev.7 → 5.0.0-dev.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/lib/cjs/Differencing/Errors.js +6 -0
- package/lib/cjs/Differencing/Errors.js.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +3 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +2 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +4 -3
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +57 -11
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +33 -4
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +55 -5
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +78 -19
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +5 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Editing/Constants.d.ts +2 -1
- package/lib/cjs/Editing/Constants.d.ts.map +1 -1
- package/lib/cjs/Editing/Constants.js +4 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +2 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +3 -0
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +6 -0
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +48 -35
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +2 -2
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +32 -21
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +2 -1
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +18 -14
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +2 -1
- package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
- package/lib/cjs/Editing/Enumerations.js +6 -3
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Exception.js +35 -6
- package/lib/cjs/Editing/Exception.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts +2 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +5 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +2 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js +10 -6
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +11 -7
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +2 -1
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +13 -9
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +8 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.d.ts +2 -1
- package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
- package/lib/cjs/Editing/Phenomena.js +3 -0
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts +2 -2
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +6 -4
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +2 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js +5 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +1 -0
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +17 -10
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +2 -2
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +8 -11
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +2 -1
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +3 -0
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +2 -1
- package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js +3 -0
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.d.ts +2 -1
- package/lib/cjs/Editing/Units.d.ts.map +1 -1
- package/lib/cjs/Editing/Units.js +5 -2
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +4 -4
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +7 -6
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/NameMapping.d.ts +22 -0
- package/lib/cjs/Merging/Edits/NameMapping.d.ts.map +1 -0
- package/lib/cjs/Merging/Edits/NameMapping.js +54 -0
- package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -0
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js +1 -260
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +9 -6
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.js +19 -14
- package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +1 -2
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.js +2 -2
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/cjs/Merging/FormatMerger.d.ts +24 -0
- package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/FormatMerger.js +143 -0
- package/lib/cjs/Merging/FormatMerger.js.map +1 -0
- package/lib/cjs/Merging/InvertedUnitMerger.d.ts +14 -0
- package/lib/cjs/Merging/InvertedUnitMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/InvertedUnitMerger.js +45 -0
- package/lib/cjs/Merging/InvertedUnitMerger.js.map +1 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -5
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +1 -1
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +28 -26
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +4 -4
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +5 -3
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +40 -5
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +14 -8
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js +42 -17
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js +2 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/cjs/Merging/UnitMerger.d.ts +14 -0
- package/lib/cjs/Merging/UnitMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/UnitMerger.js +62 -0
- package/lib/cjs/Merging/UnitMerger.js.map +1 -0
- package/lib/cjs/Merging/Utils.d.ts +11 -0
- package/lib/cjs/Merging/Utils.d.ts.map +1 -1
- package/lib/cjs/Merging/Utils.js +23 -3
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +18 -16
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js +3 -0
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js +39 -69
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +2 -2
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +4 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +23 -23
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +22 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +30 -5
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.js +1 -4
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js +3 -4
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js +4 -0
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/package.json +10 -10
|
@@ -18,7 +18,7 @@ async function addCustomAttribute(context, change) {
|
|
|
18
18
|
throw new Error("CustomAttribute instance must specify className");
|
|
19
19
|
}
|
|
20
20
|
const schemaItemKey = await (0, Utils_1.updateSchemaItemKey)(context, change.difference.className);
|
|
21
|
-
const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey);
|
|
21
|
+
const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey, ecschema_metadata_1.CustomAttributeClass);
|
|
22
22
|
if (targetCustomAttributeClass === undefined) {
|
|
23
23
|
throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);
|
|
24
24
|
}
|
|
@@ -30,19 +30,20 @@ async function addCustomAttribute(context, change) {
|
|
|
30
30
|
await context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);
|
|
31
31
|
}
|
|
32
32
|
if (change.appliedTo === "SchemaItem") {
|
|
33
|
-
const itemKey =
|
|
33
|
+
const itemKey = (0, Utils_1.toItemKey)(context, change.itemName);
|
|
34
34
|
const editor = await (0, Utils_1.getClassEditor)(context, itemKey);
|
|
35
35
|
await editor.addCustomAttribute(itemKey, caInstance);
|
|
36
36
|
}
|
|
37
37
|
if (change.appliedTo === "Property") {
|
|
38
|
-
const itemKey =
|
|
38
|
+
const itemKey = (0, Utils_1.toItemKey)(context, change.itemName);
|
|
39
39
|
const [propertyName] = change.path.split(".");
|
|
40
|
+
const propertyKey = (0, Utils_1.toPropertyKey)(context, change.itemName, propertyName);
|
|
40
41
|
const editor = await (0, Utils_1.getClassEditor)(context, itemKey);
|
|
41
|
-
await editor.properties.addCustomAttribute(itemKey, propertyName, caInstance);
|
|
42
|
+
await editor.properties.addCustomAttribute(itemKey, propertyKey.propertyName, caInstance);
|
|
42
43
|
}
|
|
43
44
|
if (change.appliedTo === "RelationshipConstraint") {
|
|
44
|
-
const itemKey =
|
|
45
|
-
const relationshipClass = await context.targetSchema.lookupItem(itemKey);
|
|
45
|
+
const itemKey = (0, Utils_1.toItemKey)(context, change.itemName);
|
|
46
|
+
const relationshipClass = await context.targetSchema.lookupItem(itemKey, ecschema_metadata_1.RelationshipClass);
|
|
46
47
|
if (relationshipClass === undefined) {
|
|
47
48
|
throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);
|
|
48
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";;AAeA,
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";;AAeA,gDA2CC;AAKD,sDAIC;AAKD,oDAGC;AA3ED;;;+FAG+F;AAC/F,gEAAoG;AAGpG,mCAAkH;AAIlH;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAA2B,EAAE,MAAiC;IACrG,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAEtF,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,EAAE,wCAAoB,CAAC,CAAC;IAC9G,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAC7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AAC,CAAC;QACpD,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,qCAAiB,CAAC,CAAC;QAC5F,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,2CAA2C,OAAO,CAAC,IAAI,wBAAwB,CAAC,CAAC;QACnG,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS;YAC1C,CAAC,CAAC,iBAAiB,CAAC,MAAM;YAC1B,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAE7B,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,8BAA8B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,qBAAqB,CAAC,OAA2B,EAAE,gBAAmC,EAAE,OAA8B;IAC1I,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE,CAAC;QAC/C,MAAM,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,eAAgC,EAAE,OAA8B;IACtI,eAAe,CAAC,SAAS,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { CustomAttribute, CustomAttributeClass, RelationshipClass } from \"@itwin/ecschema-metadata\";\r\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\r\nimport { getClassEditor, toItemKey, toPropertyKey, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\ntype CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<void>;\r\n\r\n/**\r\n * Merges a new CustomAttributes from Schema, items or properties into the target schema.\r\n * @internal\r\n */\r\nexport async function addCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<void> {\r\n if (change.difference.className === undefined) {\r\n throw new Error(\"CustomAttribute instance must specify className\");\r\n }\r\n const schemaItemKey = await updateSchemaItemKey(context, change.difference.className);\r\n\r\n const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey, CustomAttributeClass);\r\n if (targetCustomAttributeClass === undefined) {\r\n throw new Error(`Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`);\r\n }\r\n\r\n const caInstance: CustomAttribute = {\r\n ...change.difference,\r\n className: schemaItemKey.fullName,\r\n };\r\n\r\n if (change.appliedTo === \"Schema\") {\r\n await context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);\r\n }\r\n if (change.appliedTo === \"SchemaItem\") {\r\n const itemKey = toItemKey(context, change.itemName);\r\n const editor = await getClassEditor(context, itemKey);\r\n await editor.addCustomAttribute(itemKey, caInstance);\r\n }\r\n if (change.appliedTo === \"Property\") {\r\n const itemKey = toItemKey(context, change.itemName);\r\n const [propertyName] = change.path.split(\".\");\r\n const propertyKey = toPropertyKey(context, change.itemName, propertyName);\r\n const editor = await getClassEditor(context, itemKey);\r\n await editor.properties.addCustomAttribute(itemKey, propertyKey.propertyName, caInstance);\r\n }\r\n if (change.appliedTo === \"RelationshipConstraint\") {\r\n const itemKey = toItemKey(context, change.itemName);\r\n const relationshipClass = await context.targetSchema.lookupItem(itemKey, RelationshipClass);\r\n if (relationshipClass === undefined) {\r\n throw new Error(`Unable to locate the relationship class ${itemKey.name} in the merged schema.`);\r\n }\r\n const constraint = change.path === \"$source\"\r\n ? relationshipClass.source\r\n : relationshipClass.target;\r\n\r\n return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<void> {\r\n for (const customAttribute of customAttributes) {\r\n await applyCustomAttribute(context, customAttribute, handler);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<void> {\r\n customAttribute.className = await updateSchemaItemFullName(context, customAttribute.className);\r\n return handler(customAttribute);\r\n}\r\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Merging
|
|
3
|
+
*/
|
|
4
|
+
import { SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
5
|
+
export declare class PropertyKey {
|
|
6
|
+
readonly propertyName: string;
|
|
7
|
+
readonly classKey: SchemaItemKey;
|
|
8
|
+
get fullName(): string;
|
|
9
|
+
constructor(propertyName: string, classKey: SchemaItemKey);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare class NameMapping {
|
|
15
|
+
private readonly _map;
|
|
16
|
+
constructor();
|
|
17
|
+
addItemMapping(itemKey: string, newName: string): void;
|
|
18
|
+
addPropertyMapping(propertyKey: string, newName: string): void;
|
|
19
|
+
resolveItemKey(itemKey: Readonly<SchemaItemKey>): Readonly<SchemaItemKey>;
|
|
20
|
+
resolvePropertyKey(propertyKey: Readonly<PropertyKey>): Readonly<PropertyKey>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=NameMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NameMapping.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/NameMapping.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,qBAAa,WAAW;IACtB,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,QAAQ,EAAE,aAAa,CAAC;IAExC,IAAW,QAAQ,IAAI,MAAM,CAE5B;gBAEW,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa;CAI1D;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;;IAM1C,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAI/C,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAIvD,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC;IASzE,kBAAkB,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC;CAQrF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NameMapping = exports.PropertyKey = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module Merging
|
|
10
|
+
*/
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
class PropertyKey {
|
|
13
|
+
propertyName;
|
|
14
|
+
classKey;
|
|
15
|
+
get fullName() {
|
|
16
|
+
return `${this.classKey.fullName}.${this.propertyName}`;
|
|
17
|
+
}
|
|
18
|
+
constructor(propertyName, classKey) {
|
|
19
|
+
this.propertyName = propertyName;
|
|
20
|
+
this.classKey = classKey;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.PropertyKey = PropertyKey;
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
class NameMapping {
|
|
28
|
+
_map;
|
|
29
|
+
constructor() {
|
|
30
|
+
this._map = new Map();
|
|
31
|
+
}
|
|
32
|
+
addItemMapping(itemKey, newName) {
|
|
33
|
+
this._map.set(itemKey, { newName });
|
|
34
|
+
}
|
|
35
|
+
addPropertyMapping(propertyKey, newName) {
|
|
36
|
+
this._map.set(propertyKey, { newName });
|
|
37
|
+
}
|
|
38
|
+
resolveItemKey(itemKey) {
|
|
39
|
+
const entry = this._map.get(itemKey.fullName);
|
|
40
|
+
if (entry === undefined) {
|
|
41
|
+
return itemKey;
|
|
42
|
+
}
|
|
43
|
+
return new ecschema_metadata_1.SchemaItemKey(entry.newName, itemKey.schemaKey);
|
|
44
|
+
}
|
|
45
|
+
resolvePropertyKey(propertyKey) {
|
|
46
|
+
const entry = this._map.get(propertyKey.fullName);
|
|
47
|
+
if (entry === undefined) {
|
|
48
|
+
return propertyKey;
|
|
49
|
+
}
|
|
50
|
+
return new PropertyKey(entry.newName, propertyKey.classKey);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.NameMapping = NameMapping;
|
|
54
|
+
//# sourceMappingURL=NameMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NameMapping.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/NameMapping.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,gEAAyD;AAMzD,MAAa,WAAW;IACN,YAAY,CAAS;IACrB,QAAQ,CAAgB;IAExC,IAAW,QAAQ;QACjB,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;IAC1D,CAAC;IAED,YAAY,YAAoB,EAAE,QAAuB;QACvD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAZD,kCAYC;AAED;;GAEG;AACH,MAAa,WAAW;IACL,IAAI,CAA4B;IAEjD;QACE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC9C,CAAC;IAEM,cAAc,CAAC,OAAe,EAAE,OAAe;QACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAEM,kBAAkB,CAAC,WAAmB,EAAE,OAAe;QAC5D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEM,cAAc,CAAC,OAAgC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAG,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,iCAAa,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAEM,kBAAkB,CAAC,WAAkC;QAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAG,KAAK,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF;AAhCD,kCAgCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\ninterface MappingEntry {\r\n readonly newName: string;\r\n}\r\n\r\nexport class PropertyKey {\r\n public readonly propertyName: string;\r\n public readonly classKey: SchemaItemKey;\r\n\r\n public get fullName(): string {\r\n return `${this.classKey.fullName}.${this.propertyName}`;\r\n }\r\n\r\n constructor(propertyName: string, classKey: SchemaItemKey) {\r\n this.propertyName = propertyName;\r\n this.classKey = classKey;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class NameMapping {\r\n private readonly _map: Map<string, MappingEntry>;\r\n\r\n constructor() {\r\n this._map = new Map<string, MappingEntry>();\r\n }\r\n\r\n public addItemMapping(itemKey: string, newName: string) {\r\n this._map.set(itemKey, { newName });\r\n }\r\n\r\n public addPropertyMapping(propertyKey: string, newName: string) {\r\n this._map.set(propertyKey, { newName });\r\n }\r\n\r\n public resolveItemKey(itemKey: Readonly<SchemaItemKey>): Readonly<SchemaItemKey> {\r\n const entry = this._map.get(itemKey.fullName);\r\n if(entry === undefined) {\r\n return itemKey;\r\n }\r\n\r\n return new SchemaItemKey(entry.newName, itemKey.schemaKey);\r\n }\r\n\r\n public resolvePropertyKey(propertyKey: Readonly<PropertyKey>): Readonly<PropertyKey> {\r\n const entry = this._map.get(propertyKey.fullName);\r\n if(entry === undefined) {\r\n return propertyKey;\r\n }\r\n\r\n return new PropertyKey(entry.newName, propertyKey.classKey);\r\n }\r\n}\r\n"]}
|
|
@@ -10,5 +10,5 @@ export declare function applyRenamePropertyEdit(result: SchemaDifferenceResult,
|
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit
|
|
13
|
+
export declare function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit): void;
|
|
14
14
|
//# sourceMappingURL=RenameEditHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenameEditHandler.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"RenameEditHandler.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAmD,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAQ9H;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,kBAAkB,QAuB/F;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,oBAAoB,QAuBnG"}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.applyRenamePropertyEdit = applyRenamePropertyEdit;
|
|
11
11
|
exports.applyRenameSchemaItemEdit = applyRenameSchemaItemEdit;
|
|
12
|
-
const SchemaDifference_1 = require("../../Differencing/SchemaDifference");
|
|
13
12
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
14
13
|
const Utils = require("../../Differencing/Utils");
|
|
15
14
|
/**
|
|
@@ -38,7 +37,7 @@ function applyRenamePropertyEdit(result, edit) {
|
|
|
38
37
|
/**
|
|
39
38
|
* @internal
|
|
40
39
|
*/
|
|
41
|
-
function applyRenameSchemaItemEdit(result, edit
|
|
40
|
+
function applyRenameSchemaItemEdit(result, edit) {
|
|
42
41
|
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(edit.key);
|
|
43
42
|
if (!result.sourceSchemaName.startsWith(schemaName)) {
|
|
44
43
|
return;
|
|
@@ -57,57 +56,6 @@ function applyRenameSchemaItemEdit(result, edit, postProcessing) {
|
|
|
57
56
|
result.conflicts.splice(conflictIndex, 1);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
postProcessing(() => {
|
|
61
|
-
renameSchemaItem(result, edit, itemDifference.schemaType);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function renameSchemaItem(result, edit, schemaType) {
|
|
65
|
-
const schemaKey = ecschema_metadata_1.SchemaKey.parseString(result.sourceSchemaName);
|
|
66
|
-
const [_schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(edit.key);
|
|
67
|
-
const oldKey = new ecschema_metadata_1.SchemaItemKey(itemName, schemaKey);
|
|
68
|
-
const newKey = new ecschema_metadata_1.SchemaItemKey(edit.value, schemaKey);
|
|
69
|
-
switch (schemaType) {
|
|
70
|
-
case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
|
|
71
|
-
renameCustomAttributeClassName(result, oldKey, newKey);
|
|
72
|
-
break;
|
|
73
|
-
case ecschema_metadata_1.SchemaItemType.EntityClass:
|
|
74
|
-
renameEntityClassName(result, oldKey, newKey);
|
|
75
|
-
break;
|
|
76
|
-
case ecschema_metadata_1.SchemaItemType.Enumeration:
|
|
77
|
-
renameEnumerationName(result, oldKey, newKey);
|
|
78
|
-
break;
|
|
79
|
-
case ecschema_metadata_1.SchemaItemType.Format:
|
|
80
|
-
break;
|
|
81
|
-
case ecschema_metadata_1.SchemaItemType.InvertedUnit:
|
|
82
|
-
break;
|
|
83
|
-
case ecschema_metadata_1.SchemaItemType.KindOfQuantity:
|
|
84
|
-
renameKindOfQuantityName(result, oldKey, newKey);
|
|
85
|
-
break;
|
|
86
|
-
case ecschema_metadata_1.SchemaItemType.Mixin:
|
|
87
|
-
renameMixinName(result, oldKey, newKey);
|
|
88
|
-
break;
|
|
89
|
-
case ecschema_metadata_1.SchemaItemType.Phenomenon:
|
|
90
|
-
renamePhenomenonName(result, oldKey, newKey);
|
|
91
|
-
break;
|
|
92
|
-
case ecschema_metadata_1.SchemaItemType.PropertyCategory:
|
|
93
|
-
renamePropertyCategoryName(result, oldKey, newKey);
|
|
94
|
-
break;
|
|
95
|
-
case ecschema_metadata_1.SchemaItemType.RelationshipClass:
|
|
96
|
-
renameRelationshipClassName(result, oldKey, newKey);
|
|
97
|
-
break;
|
|
98
|
-
case ecschema_metadata_1.SchemaItemType.StructClass:
|
|
99
|
-
renameStructClassName(result, oldKey, newKey);
|
|
100
|
-
break;
|
|
101
|
-
case ecschema_metadata_1.SchemaItemType.Unit:
|
|
102
|
-
break;
|
|
103
|
-
case ecschema_metadata_1.SchemaItemType.UnitSystem:
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function renameBaseClass(difference, oldKey, newKey) {
|
|
108
|
-
if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {
|
|
109
|
-
difference.baseClass = newKey.fullName;
|
|
110
|
-
}
|
|
111
59
|
}
|
|
112
60
|
function renameName(change, oldName, newName) {
|
|
113
61
|
if (change.itemName === oldName) {
|
|
@@ -115,211 +63,4 @@ function renameName(change, oldName, newName) {
|
|
|
115
63
|
schemaItemDifference.itemName = newName;
|
|
116
64
|
}
|
|
117
65
|
}
|
|
118
|
-
function renameRelationshipConstraint(change, oldKey, newKey) {
|
|
119
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
|
|
120
|
-
const constraintProps = [change.difference.source, change.difference.target];
|
|
121
|
-
for (const props of constraintProps) {
|
|
122
|
-
if (props) {
|
|
123
|
-
if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {
|
|
124
|
-
props.abstractConstraint = newKey.fullName;
|
|
125
|
-
}
|
|
126
|
-
if (props.constraintClasses !== undefined) {
|
|
127
|
-
for (let i = 0; i < props.constraintClasses.length; i++) {
|
|
128
|
-
if (oldKey.matchesFullName(props.constraintClasses[i]))
|
|
129
|
-
props.constraintClasses[i] = newKey.fullName;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
for (let i = 0; i < change.difference.length; i++) {
|
|
137
|
-
if (oldKey.matchesFullName(change.difference[i]))
|
|
138
|
-
change.difference[i] = newKey.fullName;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function renamePropertyCategoryName({ differences }, oldKey, newKey) {
|
|
143
|
-
for (const entry of differences) {
|
|
144
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.PropertyCategory) {
|
|
145
|
-
renameName(entry, oldKey.name, newKey.name);
|
|
146
|
-
}
|
|
147
|
-
if (Utils.isClassDifference(entry) && entry.difference.properties) {
|
|
148
|
-
for (const property of entry.difference.properties) {
|
|
149
|
-
if (property.category && oldKey.matchesFullName(property.category)) {
|
|
150
|
-
const props = property;
|
|
151
|
-
props.category = newKey.fullName;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.Property) {
|
|
156
|
-
if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {
|
|
157
|
-
entry.difference.category = newKey.fullName;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function renameKindOfQuantityName({ differences }, oldKey, newKey) {
|
|
163
|
-
for (const entry of differences) {
|
|
164
|
-
if (Utils.isClassDifference(entry) && entry.difference.properties) {
|
|
165
|
-
for (const property of entry.difference.properties) {
|
|
166
|
-
if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {
|
|
167
|
-
const props = property;
|
|
168
|
-
props.kindOfQuantity = newKey.fullName;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.Property) {
|
|
173
|
-
if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {
|
|
174
|
-
entry.difference.kindOfQuantity = newKey.fullName;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function renameEnumerationName({ differences }, oldKey, newKey) {
|
|
180
|
-
for (const change of differences) {
|
|
181
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
182
|
-
for (const property of change.difference.properties) {
|
|
183
|
-
if (property.type === "PrimitiveProperty" || property.type === "PrimitiveArrayProperty") {
|
|
184
|
-
const props = property;
|
|
185
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
186
|
-
props.typeName = newKey.fullName;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && (change.difference.type === "PrimitiveProperty" || change.difference.type === "PrimitiveArrayProperty")) {
|
|
191
|
-
const props = change.difference;
|
|
192
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
193
|
-
props.typeName = newKey.fullName;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function renamePhenomenonName({ differences }, oldKey, newKey) {
|
|
198
|
-
for (const entry of differences) {
|
|
199
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Constant || entry.schemaType === ecschema_metadata_1.SchemaItemType.Unit) {
|
|
200
|
-
if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))
|
|
201
|
-
entry.difference.phenomenon = newKey.fullName;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function renameStructClassName({ differences }, oldKey, newKey) {
|
|
206
|
-
for (const change of differences) {
|
|
207
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.StructClass) {
|
|
208
|
-
renameBaseClass(change.difference, oldKey, newKey);
|
|
209
|
-
}
|
|
210
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
211
|
-
for (const property of change.difference.properties) {
|
|
212
|
-
if (property.type === "StructProperty" || property.type === "StructArrayProperty") {
|
|
213
|
-
const props = property;
|
|
214
|
-
;
|
|
215
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
216
|
-
props.typeName = newKey.fullName;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && (change.difference.type === "StructProperty" || change.difference.type === "StructArrayProperty")) {
|
|
221
|
-
const props = change.difference;
|
|
222
|
-
if (props.typeName && oldKey.matchesFullName(props.typeName))
|
|
223
|
-
props.typeName = newKey.fullName;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function renameCustomAttributeClassName({ differences }, oldKey, newKey) {
|
|
228
|
-
for (const change of differences) {
|
|
229
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.CustomAttributeClass) {
|
|
230
|
-
renameBaseClass(change.difference, oldKey, newKey);
|
|
231
|
-
}
|
|
232
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.CustomAttributeInstance) {
|
|
233
|
-
if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {
|
|
234
|
-
change.difference.className = newKey.fullName;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property || Utils.isClassDifference(change)) {
|
|
238
|
-
if (change.difference.customAttributes) {
|
|
239
|
-
for (const customAttribute of change.difference.customAttributes) {
|
|
240
|
-
if (oldKey.matchesFullName(customAttribute.className))
|
|
241
|
-
customAttribute.className = newKey.fullName;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
246
|
-
for (const property of change.difference.properties) {
|
|
247
|
-
if (property.customAttributes) {
|
|
248
|
-
for (const customAttribute of property.customAttributes) {
|
|
249
|
-
if (oldKey.matchesFullName(customAttribute.className))
|
|
250
|
-
customAttribute.className = newKey.fullName;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// https://github.com/iTwin/itwinjs-core/issues/7020
|
|
256
|
-
/* if (change.schemaType === SchemaItemType.RelationshipClass) {
|
|
257
|
-
const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];
|
|
258
|
-
for (const props of constraintProps) {
|
|
259
|
-
if (props.customAttributes !== undefined) {
|
|
260
|
-
for (const customAttribute of props.customAttributes) {
|
|
261
|
-
if (oldKey.matchesFullName(customAttribute.className))
|
|
262
|
-
customAttribute.className = newKey.fullName;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
} */
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
function renameRelationshipClassName({ differences }, oldKey, newKey) {
|
|
270
|
-
for (const change of differences) {
|
|
271
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
|
|
272
|
-
renameBaseClass(change.difference, oldKey, newKey);
|
|
273
|
-
}
|
|
274
|
-
if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && change.difference.type === "NavigationProperty") {
|
|
275
|
-
const props = change.difference;
|
|
276
|
-
if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))
|
|
277
|
-
props.relationshipName = newKey.fullName;
|
|
278
|
-
}
|
|
279
|
-
if (Utils.isClassDifference(change) && change.difference.properties) {
|
|
280
|
-
for (const property of change.difference.properties) {
|
|
281
|
-
if (property.type === "NavigationProperty") {
|
|
282
|
-
const props = property;
|
|
283
|
-
if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))
|
|
284
|
-
props.relationshipName = newKey.fullName;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass || change.schemaType === SchemaDifference_1.SchemaOtherTypes.RelationshipConstraintClass) {
|
|
289
|
-
renameRelationshipConstraint(change, oldKey, newKey);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function renameEntityClassName({ differences }, oldKey, newKey) {
|
|
294
|
-
for (const entry of differences) {
|
|
295
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.EntityClass) {
|
|
296
|
-
renameName(entry, oldKey.name, newKey.name);
|
|
297
|
-
renameBaseClass(entry.difference, oldKey, newKey);
|
|
298
|
-
}
|
|
299
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Mixin) {
|
|
300
|
-
if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))
|
|
301
|
-
entry.difference.appliesTo = newKey.fullName;
|
|
302
|
-
}
|
|
303
|
-
if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {
|
|
304
|
-
renameRelationshipConstraint(entry, oldKey, newKey);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function renameMixinName({ differences }, oldKey, newKey) {
|
|
309
|
-
for (const entry of differences) {
|
|
310
|
-
if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Mixin) {
|
|
311
|
-
renameBaseClass(entry.difference, oldKey, newKey);
|
|
312
|
-
}
|
|
313
|
-
if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.EntityClassMixin) {
|
|
314
|
-
for (let i = 0; i < entry.difference.length; i++) {
|
|
315
|
-
if (oldKey.matchesFullName(entry.difference[i])) {
|
|
316
|
-
entry.difference[i] = newKey.fullName;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {
|
|
321
|
-
renameRelationshipConstraint(entry, oldKey, newKey);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
66
|
//# sourceMappingURL=RenameEditHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAcH,0DAuBC;AAKD,8DA2BC;AAlED,0EAAyP;AACzP,gEAA0P;AAC1P,kDAAkD;AAMlD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,MAA8B,EAAE,IAAwB;IAC9F,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAA6B,CAAC;IACrF,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACnD,OAAO,KAAK,CAAC,yBAAyB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IACpI,CAAC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,UAA+C,CAAC;IAC3E,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO;IACT,CAAC;IAED,kBAAkB,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IAErC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,kBAAkB,CAAC,CAAC;QACrG,IAAI,aAAa,GAAG,CAAC,CAAC,EA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,CAAC;QACjD,CAAC;QAED,IAAI,KAAK,CAAC,6BAA6B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,KAAK,CAAC,EAAE,CAAC;YACvG,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,WAAW,EAA0B,EAAE,MAAqB,EAAE,MAAqB;IAC5G,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,UAAU,KAAK,kCAAc,CAAC,KAAK,EAAE,CAAC;YAC9C,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,KAAK,CAAC,UAAU,KAAK,mCAAgB,CAAC,gBAAgB,EAAE,CAAC;YAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,IAAI,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,6BAA6B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,KAAK,CAAC,EAAE,CAAC;YACvG,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\r\nimport { AnyClassItemDifference, AnySchemaItemDifference, ClassPropertyDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, SchemaDifferenceResult, SchemaOtherTypes, SchemaType } from \"../../Differencing/SchemaDifference\";\r\nimport { NavigationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, RelationshipConstraintProps, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps, StructPropertyProps } from \"@itwin/ecschema-metadata\";\r\nimport * as Utils from \"../../Differencing/Utils\";\r\n\r\ntype Editable<T extends object> = {\r\n -readonly [P in keyof T]: T[P];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\r\n const [schemaName, itemName, path] = edit.key.split(\".\") as [string, string, string];\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\r\n });\r\n\r\n const propertyDifference = difference as Editable<ClassPropertyDifference>;\r\n if (propertyDifference === undefined) {\r\n return;\r\n }\r\n\r\n propertyDifference.path = edit.value;\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, postProcessing: (cb: () => void) => void) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName;\r\n });\r\n\r\n const itemDifference = difference as AnySchemaItemDifference;\r\n if (itemDifference === undefined) {\r\n return;\r\n }\r\n\r\n renameName(itemDifference, itemName, edit.value);\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n\r\n postProcessing(() => {\r\n renameSchemaItem(result, edit, itemDifference.schemaType);\r\n });\r\n}\r\n\r\nfunction renameSchemaItem(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, schemaType: SchemaType) {\r\n const schemaKey = SchemaKey.parseString(result.sourceSchemaName);\r\n const [_schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n const oldKey = new SchemaItemKey(itemName, schemaKey);\r\n const newKey = new SchemaItemKey(edit.value, schemaKey);\r\n\r\n switch (schemaType) {\r\n case SchemaItemType.CustomAttributeClass:\r\n renameCustomAttributeClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.EntityClass:\r\n renameEntityClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Enumeration:\r\n renameEnumerationName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Format:\r\n break;\r\n case SchemaItemType.InvertedUnit:\r\n break;\r\n case SchemaItemType.KindOfQuantity:\r\n renameKindOfQuantityName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Mixin:\r\n renameMixinName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Phenomenon:\r\n renamePhenomenonName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.PropertyCategory:\r\n renamePropertyCategoryName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.RelationshipClass:\r\n renameRelationshipClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.StructClass:\r\n renameStructClassName(result, oldKey, newKey);\r\n break;\r\n case SchemaItemType.Unit:\r\n break;\r\n case SchemaItemType.UnitSystem:\r\n break;\r\n }\r\n}\r\n\r\nfunction renameBaseClass(difference: AnyClassItemDifference[\"difference\"], oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {\r\n difference.baseClass = newKey.fullName;\r\n }\r\n}\r\n\r\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\r\n if (change.itemName === oldName) {\r\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\r\n schemaItemDifference.itemName = newName;\r\n }\r\n}\r\n\r\nfunction renameRelationshipConstraint(change: RelationshipClassDifference | RelationshipConstraintClassDifference, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\r\n for (const props of constraintProps) {\r\n if (props) {\r\n if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {\r\n props.abstractConstraint = newKey.fullName;\r\n }\r\n if (props.constraintClasses !== undefined) {\r\n for (let i = 0; i < props.constraintClasses.length; i++) {\r\n if (oldKey.matchesFullName(props.constraintClasses[i]))\r\n props.constraintClasses[i] = newKey.fullName;\r\n }\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < change.difference.length; i++) {\r\n if (oldKey.matchesFullName(change.difference[i]))\r\n change.difference[i] = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renamePropertyCategoryName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.PropertyCategory) {\r\n renameName(entry, oldKey.name, newKey.name);\r\n }\r\n\r\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\r\n for (const property of entry.difference.properties) {\r\n if (property.category && oldKey.matchesFullName(property.category)) {\r\n const props = property as Editable<typeof property>;\r\n props.category = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.Property) {\r\n if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {\r\n entry.difference.category = newKey.fullName;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction renameKindOfQuantityName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\r\n for (const property of entry.difference.properties) {\r\n if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {\r\n const props = property as Editable<typeof property>;\r\n props.kindOfQuantity = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.Property) {\r\n if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {\r\n entry.difference.kindOfQuantity = newKey.fullName;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction renameEnumerationName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"PrimitiveProperty\" || property.type === \"PrimitiveArrayProperty\") {\r\n const props = property as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && (\r\n change.difference.type === \"PrimitiveProperty\" || change.difference.type === \"PrimitiveArrayProperty\"\r\n )) {\r\n const props = change.difference as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renamePhenomenonName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.Constant || entry.schemaType === SchemaItemType.Unit) {\r\n if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))\r\n entry.difference.phenomenon = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renameStructClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.StructClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"StructProperty\" || property.type === \"StructArrayProperty\") {\r\n const props = property as Editable<StructPropertyProps | StructArrayPropertyProps>;;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && (\r\n change.difference.type === \"StructProperty\" || change.difference.type === \"StructArrayProperty\"\r\n )) {\r\n const props = change.difference as Editable<StructPropertyProps | StructArrayPropertyProps>;\r\n if (props.typeName && oldKey.matchesFullName(props.typeName))\r\n props.typeName = newKey.fullName;\r\n }\r\n }\r\n}\r\n\r\nfunction renameCustomAttributeClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.CustomAttributeClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.CustomAttributeInstance) {\r\n if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {\r\n change.difference.className = newKey.fullName;\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property || Utils.isClassDifference(change)) {\r\n if (change.difference.customAttributes) {\r\n for (const customAttribute of change.difference.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.customAttributes) {\r\n for (const customAttribute of property.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n }\r\n // https://github.com/iTwin/itwinjs-core/issues/7020\r\n /* if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\r\n for (const props of constraintProps) {\r\n if (props.customAttributes !== undefined) {\r\n for (const customAttribute of props.customAttributes) {\r\n if (oldKey.matchesFullName(customAttribute.className))\r\n customAttribute.className = newKey.fullName;\r\n }\r\n }\r\n }\r\n } */\r\n }\r\n}\r\n\r\nfunction renameRelationshipClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const change of differences) {\r\n if (change.schemaType === SchemaItemType.RelationshipClass) {\r\n renameBaseClass(change.difference, oldKey, newKey);\r\n }\r\n\r\n if (change.schemaType === SchemaOtherTypes.Property && change.difference.type === \"NavigationProperty\") {\r\n const props = change.difference as Editable<NavigationPropertyProps>;\r\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\r\n props.relationshipName = newKey.fullName;\r\n }\r\n\r\n if (Utils.isClassDifference(change) && change.difference.properties) {\r\n for (const property of change.difference.properties) {\r\n if (property.type === \"NavigationProperty\") {\r\n const props = property as Editable<NavigationPropertyProps>;\r\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\r\n props.relationshipName = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (change.schemaType === SchemaItemType.RelationshipClass || change.schemaType === SchemaOtherTypes.RelationshipConstraintClass) {\r\n renameRelationshipConstraint(change, oldKey, newKey);\r\n }\r\n }\r\n}\r\n\r\nfunction renameEntityClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.EntityClass) {\r\n renameName(entry, oldKey.name, newKey.name);\r\n renameBaseClass(entry.difference, oldKey, newKey);\r\n }\r\n\r\n if (entry.schemaType === SchemaItemType.Mixin) {\r\n if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))\r\n entry.difference.appliesTo = newKey.fullName;\r\n }\r\n\r\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\r\n renameRelationshipConstraint(entry, oldKey, newKey);\r\n }\r\n }\r\n}\r\n\r\nfunction renameMixinName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\r\n for (const entry of differences) {\r\n if (entry.schemaType === SchemaItemType.Mixin) {\r\n renameBaseClass(entry.difference, oldKey, newKey);\r\n }\r\n\r\n if (entry.schemaType === SchemaOtherTypes.EntityClassMixin) {\r\n for (let i = 0; i < entry.difference.length; i++) {\r\n if (oldKey.matchesFullName(entry.difference[i])) {\r\n entry.difference[i] = newKey.fullName;\r\n }\r\n }\r\n }\r\n\r\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\r\n renameRelationshipConstraint(entry, oldKey, newKey);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAcH,0DAuBC;AAKD,8DAuBC;AA7DD,gEAAsD;AACtD,kDAAkD;AAMlD;;GAEG;AACH,SAAgB,uBAAuB,CAAC,MAA8B,EAAE,IAAwB;IAC9F,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAA6B,CAAC;IACrF,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,C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U,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC1G,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,UAAqC,CAAC;IAC7D,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO;IACT,CAAC;IAED,UAAU,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAEjD,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,cAAc,CAAC,CAAC;QACjG,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,OAAe,EAAE,OAAe;IACnF,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,oBAAoB,GAAG,MAA2C,CAAC;QACzE,oBAAoB,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1C,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\r\nimport { AnySchemaItemDifference, ClassPropertyDifference,SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\r\nimport { SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport * as Utils from \"../../Differencing/Utils\";\r\n\r\ntype Editable<T extends object> = {\r\n -readonly [P in keyof T]: T[P];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\r\n const [schemaName, itemName, path] = edit.key.split(\".\") as [string, string, string];\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\r\n });\r\n\r\n const propertyDifference = difference as Editable<ClassPropertyDifference>;\r\n if (propertyDifference === undefined) {\r\n return;\r\n }\r\n\r\n propertyDifference.path = edit.value;\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(edit.key);\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const difference = result.differences.find((entry) => {\r\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName;\r\n });\r\n\r\n const itemDifference = difference as AnySchemaItemDifference;\r\n if (itemDifference === undefined) {\r\n return;\r\n }\r\n\r\n renameName(itemDifference, itemName, edit.value);\r\n\r\n if (result.conflicts) {\r\n const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);\r\n if (conflictIndex > -1) {\r\n result.conflicts.splice(conflictIndex, 1);\r\n }\r\n }\r\n}\r\n\r\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\r\n if (change.itemName === oldName) {\r\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\r\n schemaItemDifference.itemName = newName;\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Merging
|
|
3
3
|
*/
|
|
4
|
+
import type { ECClass, SchemaItem } from "@itwin/ecschema-metadata";
|
|
4
5
|
import type { SchemaDifferenceResult } from "../../Differencing/SchemaDifference";
|
|
6
|
+
import { NameMapping } from "./NameMapping";
|
|
5
7
|
/**
|
|
6
8
|
* An enumeration that has all the schema edit names.
|
|
7
9
|
* @alpha
|
|
@@ -48,19 +50,19 @@ declare abstract class Editor {
|
|
|
48
50
|
protected add(edit: AnySchemaEdits): void;
|
|
49
51
|
}
|
|
50
52
|
declare class PropertyEditor extends Editor {
|
|
51
|
-
rename(
|
|
52
|
-
skip(
|
|
53
|
+
rename(ecClass: ECClass, propertyName: string, newName: string): void;
|
|
54
|
+
skip(ecClass: ECClass, propertyName: string): void;
|
|
53
55
|
}
|
|
54
56
|
declare class ItemEditor extends Editor {
|
|
55
|
-
rename(
|
|
56
|
-
skip(
|
|
57
|
+
rename(schemaItem: SchemaItem, newName: string): void;
|
|
58
|
+
skip(schemaItem: SchemaItem): void;
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class
|
|
60
62
|
* is to support saving of edits and load them again if needed.
|
|
61
63
|
* @alpha
|
|
62
64
|
*/
|
|
63
|
-
export declare class SchemaEdits {
|
|
65
|
+
export declare class SchemaEdits implements Iterable<AnySchemaEdits> {
|
|
64
66
|
private readonly _edits;
|
|
65
67
|
readonly properties: PropertyEditor;
|
|
66
68
|
readonly items: ItemEditor;
|
|
@@ -71,8 +73,9 @@ export declare class SchemaEdits {
|
|
|
71
73
|
/**
|
|
72
74
|
* @internal
|
|
73
75
|
*/
|
|
74
|
-
applyTo(differenceResult: SchemaDifferenceResult): Promise<void>;
|
|
76
|
+
applyTo(differenceResult: SchemaDifferenceResult, nameMapping: NameMapping): Promise<void>;
|
|
75
77
|
toJSON(): ReadonlyArray<AnySchemaEdits>;
|
|
78
|
+
[Symbol.iterator](): Iterator<AnySchemaEdits>;
|
|
76
79
|
}
|
|
77
80
|
export {};
|
|
78
81
|
//# sourceMappingURL=SchemaEdits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEdits.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaEdits.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;;GAGG;AACH,oBAAY,cAAc;IACxB,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,IAAI,SAAS;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC,gBAAgB,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACxB,QAAQ,GACR,oBAAoB,GACpB,kBAAkB,CAAC;AAErB,uBAAe,MAAM;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CA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