@itwin/ecschema-editing 4.10.0-dev.9 → 5.0.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 +21 -1
- package/lib/cjs/Differencing/Errors.d.ts +3 -3
- package/lib/cjs/Differencing/Errors.d.ts.map +1 -1
- package/lib/cjs/Differencing/Errors.js.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +17 -15
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +1 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +3 -2
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +30 -11
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +16 -5
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +3 -2
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -2
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +37 -44
- 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 +2 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Differencing/Utils.js +21 -22
- package/lib/cjs/Differencing/Utils.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +1 -2
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +2 -4
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +2 -2
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +1 -2
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +2 -3
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.js +2 -3
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +7 -6
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js +4 -5
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.js +6 -6
- package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +3 -4
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +2 -3
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.js +2 -3
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +7 -2
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +38 -17
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +2 -3
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +2 -3
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js +2 -3
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +9 -29
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +4 -5
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +6 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js +9 -0
- 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 +1 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js +2 -3
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js +2 -3
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js +2 -3
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.d.ts +6 -1
- package/lib/cjs/Merging/Utils.d.ts.map +1 -1
- package/lib/cjs/Merging/Utils.js +26 -4
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.d.ts +2 -2
- package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +9 -9
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js +19 -19
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts +2 -2
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.d.ts +1 -1
- package/lib/cjs/Validation/Rules.d.ts.map +1 -1
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +6 -6
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +0 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;AAgBA,kCA+BC;AAzCD,mCAA8C;AAE9C,gEAAwI;AACxI,qDAAwD;AACxD,mEAAgE;AAEhE;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA8B,EAAE,OAAsB,EAAE,IAAa;IAClI,MAAM,YAAY,GAAG,IAAoB,CAAC;IAC1C,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAA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CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC5F,KAAK,kCAAc,CAAC,iBAAiB,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC/G,KAAK,kCAAc,CAAC,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,IAAI,qBAAqB,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,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 { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { AnyClassItemDifference } from \"../Differencing/SchemaDifference\";\r\nimport { updateSchemaItemKey } from \"./Utils\";\r\nimport { type MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { CustomAttribute, ECClass, ECClassModifier, parseClassModifier, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { mergeClassProperties } from \"./PropertyMerger\";\r\nimport { applyCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * Shared modify merger of all ECClass based items.\r\n * @internal\r\n */\r\nexport async function modifyClass(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<void> {\r\n const mutableClass = item as MutableClass;\r\n if (change.difference.label !== undefined) {\r\n mutableClass.setDisplayLabel(change.difference.label);\r\n }\r\n\r\n if (change.difference.description !== undefined) {\r\n mutableClass.setDescription(change.difference.description);\r\n }\r\n\r\n if (change.difference.hasOwnProperty(\"baseClass\")) {\r\n // If the entry difference have a property baseClass and it is explicitly set to undefined,\r\n // it is expected to remove the base class, which is not allowed in this case.\r\n // TODO: We should consider using null for this case.\r\n if(change.difference.baseClass === undefined) {\r\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\r\n }\r\n await setBaseClass(context, item, change.difference.baseClass, change.changeType === \"add\");\r\n }\r\n\r\n if (change.difference.modifier !== undefined) {\r\n await setClassModifier(mutableClass, change.difference.modifier);\r\n }\r\n\r\n if (change.difference.customAttributes !== undefined) {\r\n await applyCustomAttributes(context, change.difference.customAttributes as CustomAttribute[], async (ca) => {\r\n await context.editor.entities.addCustomAttribute(itemKey, ca);\r\n });\r\n }\r\n\r\n return mergeClassProperties(context, change, itemKey);\r\n}\r\n\r\nasync function setBaseClass(context: SchemaMergeContext, item: ECClass, baseClass: string, isInitial: boolean): Promise<void> {\r\n if (!isInitial && (item.baseClass === undefined))\r\n throw new Error(`Changing the class '${item.key.name}' baseClass is not supported.`);\r\n\r\n const baseClassKey = await updateSchemaItemKey(context, baseClass);\r\n const baseClassSetter = getBaseClassSetter(context, item);\r\n\r\n await baseClassSetter(item.key, baseClassKey);\r\n}\r\n\r\nasync function setClassModifier(item: MutableClass, modifierValue: string): Promise<void> {\r\n const modifier = parseClassModifier(modifierValue);\r\n if (modifier === undefined) {\r\n throw new Error(\"An invalid class modifier has been provided.\");\r\n }\r\n if (item.modifier === undefined || item.modifier === modifier || modifier === ECClassModifier.None) {\r\n item.setModifier(modifier);\r\n return;\r\n }\r\n throw new Error(`Changing the class '${item.name}' modifier is not supported.`);\r\n}\r\n\r\nfunction getBaseClassSetter(context: SchemaMergeContext, item: ECClass) {\r\n return async (itemKey: SchemaItemKey, baseClassKey: SchemaItemKey) => {\r\n switch (item.schemaItemType) {\r\n case SchemaItemType.CustomAttributeClass: return context.editor.customAttributes.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.EntityClass: return context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.Mixin: return context.editor.mixins.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.RelationshipClass: return context.editor.relationships.setBaseClass(itemKey, baseClassKey);\r\n case SchemaItemType.StructClass: return context.editor.structs.setBaseClass(itemKey, baseClassKey);\r\n }\r\n throw new Error(`Changing the base class '${item.name}' is not supported.`);\r\n };\r\n}\r\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addConstant = addConstant;
|
|
4
|
+
exports.modifyConstant = modifyConstant;
|
|
4
5
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
6
|
const Utils_1 = require("./Utils");
|
|
6
7
|
/**
|
|
@@ -24,7 +25,6 @@ async function addConstant(context, change) {
|
|
|
24
25
|
definition: change.difference.definition,
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
exports.addConstant = addConstant;
|
|
28
28
|
/**
|
|
29
29
|
* Merges differences to an existing Constant in the target schema.
|
|
30
30
|
* @internal
|
|
@@ -65,5 +65,4 @@ async function modifyConstant(context, change, itemKey) {
|
|
|
65
65
|
constant.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
exports.modifyConstant = modifyConstant;
|
|
69
68
|
//# sourceMappingURL=ConstantMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAcA,kCAkBC;AAMD,wCAqCC;AApED,gEAA+H;AAC/H,mCAAwE;AAExE;;;GAGG;AACI,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,MAA0B;IACvF,IAAI,MAAM,CAAC,UAAU,CAAC,UAA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AK,SAAS,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAa,SAAS,CAAC,CAAC;QAC3F,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QAC5F,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,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\nimport type { ConstantDifference } from \"../Differencing/SchemaDifference\";\r\nimport type{ MutableConstant } from \"../Editing/Mutable/MutableConstant\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new Constant into the target schema.\r\n * @internal\r\n */\r\nexport async function addConstant(context: SchemaMergeContext, change: ConstantDifference) {\r\n if (change.difference.phenomenon === undefined) {\r\n throw new Error(\"Constant must define phenomenon\");\r\n }\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Constant must define definition\");\r\n }\r\n\r\n // Needs to update the reference from source to target schema.\r\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\r\n\r\n await context.editor.constants.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n phenomenon: change.difference.phenomenon,\r\n definition: change.difference.definition,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Constant in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyConstant(context: SchemaMergeContext, change: ConstantDifference, itemKey: SchemaItemKey) {\r\n const constant = await context.targetSchema.lookupItem(itemKey) as MutableConstant;\r\n if (change.difference.label !== undefined) {\r\n await context.editor.constants.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n await context.editor.constants.setDescription(itemKey, change.difference.description);\r\n }\r\n\r\n // Note: There are no editor methods to modify a constant.\r\n if (change.difference.definition !== undefined) {\r\n if (change.difference.definition !== \"\" && constant.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${itemKey.name} has an invalid 'definition' attribute.`);\r\n }\r\n constant.setDefinition(change.difference.definition);\r\n }\r\n if (change.difference.denominator !== undefined) {\r\n if (constant.hasDenominator && constant.denominator !== change.difference.denominator) {\r\n throw new Error(`Failed to merged, constant denominator conflict: ${change.difference.denominator} -> ${constant.denominator}`);\r\n }\r\n constant.setDenominator(change.difference.denominator);\r\n }\r\n if (change.difference.numerator !== undefined) {\r\n if (constant.hasNumerator && constant.numerator !== change.difference.numerator) {\r\n throw new Error(`Failed to merged, constant numerator conflict: ${change.difference.numerator} -> ${constant.numerator}`);\r\n }\r\n constant.setNumerator(change.difference.numerator);\r\n }\r\n if (change.difference.phenomenon !== undefined) {\r\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\r\n const phenomenon = await context.editor.schemaContext.getSchemaItem<Phenomenon>(lookupKey);\r\n if (phenomenon === undefined) {\r\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\r\n }\r\n\r\n constant.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addCustomAttributeClass = addCustomAttributeClass;
|
|
4
|
+
exports.modifyCustomAttributeClass = modifyCustomAttributeClass;
|
|
4
5
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
6
|
const ClassMerger_1 = require("./ClassMerger");
|
|
6
7
|
/**
|
|
@@ -18,7 +19,6 @@ async function addCustomAttributeClass(context, change) {
|
|
|
18
19
|
appliesTo: change.difference.appliesTo,
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
exports.addCustomAttributeClass = addCustomAttributeClass;
|
|
22
22
|
/**
|
|
23
23
|
* Merges differences to an existing CustomAttribute in the target schema.
|
|
24
24
|
* @internal
|
|
@@ -37,5 +37,4 @@ async function modifyCustomAttributeClass(context, change, itemKey) {
|
|
|
37
37
|
}
|
|
38
38
|
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
|
|
39
39
|
}
|
|
40
|
-
exports.modifyCustomAttributeClass = modifyCustomAttributeClass;
|
|
41
40
|
//# sourceMappingURL=CustomAttributeClassMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeClassMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomAttributeClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeClassMerger.ts"],"names":[],"mappings":";;AAcA,0DAWC;AAMD,gEAaC;AArCD,gEAAmH;AACnH,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,MAAsC;IAC/G,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC7E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;KACvC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAAC,OAA2B,EAAE,MAAsC,EAAE,OAAsB;IAC1I,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAmB,CAAC;IAC9E,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,IAAA,yCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,YAAY,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;YACxE,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,YAAY,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3G,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACxF,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,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 type { CustomAttributeClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { containerTypeToString, parseCustomAttributeContainerType, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new CustomAttribute into the target schema.\r\n * @internal\r\n */\r\nexport async function addCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"appliesTo is a required property of a CustomAttributeClass but it is not set\");\r\n }\r\n\r\n await context.editor.customAttributes.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: change.difference.appliesTo,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing CustomAttribute in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyCustomAttributeClass(context: SchemaMergeContext, change: CustomAttributeClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableCAClass;\r\n if (change.difference.appliesTo !== undefined) {\r\n const currentValue = containerTypeToString(item.appliesTo);\r\n if (currentValue !== \"\" && change.difference.appliesTo !== currentValue) {\r\n const containerType = parseCustomAttributeContainerType(`${currentValue}, ${change.difference.appliesTo}`);\r\n if (containerType === undefined) {\r\n throw new Error(\"An invalid custom attribute class containerType has been provided.\");\r\n }\r\n item.setAppliesTo(containerType);\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAA0D,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAGlF,KAAK,qBAAqB,GAAG,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjF;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAA0D,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAGlF,KAAK,qBAAqB,GAAG,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjF;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CtH;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAI3J;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvJ"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addCustomAttribute = addCustomAttribute;
|
|
4
|
+
exports.applyCustomAttributes = applyCustomAttributes;
|
|
5
|
+
exports.applyCustomAttribute = applyCustomAttribute;
|
|
4
6
|
/*---------------------------------------------------------------------------------------------
|
|
5
7
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
8
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -29,12 +31,14 @@ async function addCustomAttribute(context, change) {
|
|
|
29
31
|
}
|
|
30
32
|
if (change.appliedTo === "SchemaItem") {
|
|
31
33
|
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
32
|
-
await
|
|
34
|
+
const editor = await (0, Utils_1.getClassEditor)(context, itemKey);
|
|
35
|
+
await editor.addCustomAttribute(itemKey, caInstance);
|
|
33
36
|
}
|
|
34
37
|
if (change.appliedTo === "Property") {
|
|
35
38
|
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
36
39
|
const [propertyName] = change.path.split(".");
|
|
37
|
-
await
|
|
40
|
+
const editor = await (0, Utils_1.getClassEditor)(context, itemKey);
|
|
41
|
+
await editor.properties.addCustomAttribute(itemKey, propertyName, caInstance);
|
|
38
42
|
}
|
|
39
43
|
if (change.appliedTo === "RelationshipConstraint") {
|
|
40
44
|
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
@@ -48,7 +52,6 @@ async function addCustomAttribute(context, change) {
|
|
|
48
52
|
return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
exports.addCustomAttribute = addCustomAttribute;
|
|
52
55
|
/**
|
|
53
56
|
* @internal
|
|
54
57
|
*/
|
|
@@ -57,7 +60,6 @@ async function applyCustomAttributes(context, customAttributes, handler) {
|
|
|
57
60
|
await applyCustomAttribute(context, customAttribute, handler);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
|
-
exports.applyCustomAttributes = applyCustomAttributes;
|
|
61
63
|
/**
|
|
62
64
|
* @internal
|
|
63
65
|
*/
|
|
@@ -65,5 +67,4 @@ async function applyCustomAttribute(context, customAttribute, handler) {
|
|
|
65
67
|
customAttribute.className = await (0, Utils_1.updateSchemaItemFullName)(context, customAttribute.className);
|
|
66
68
|
return handler(customAttribute);
|
|
67
69
|
}
|
|
68
|
-
exports.applyCustomAttribute = applyCustomAttribute;
|
|
69
70
|
//# sourceMappingURL=CustomAttributeMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";;AAeA,gDA0CC;AAKD,sDAIC;AAKD,oDAGC;AA1ED;;;+FAG+F;AAC/F,gEAAmH;AAGnH,mCAAwF;AAIxF;;;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,CAAuB,aAAa,CAAC,CAAC;IAC9G,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAC7G,CAAC;IAED,MAAM,UAAU,GAAoB;QAClC,GAAG,MAAM,CAAC,UAAU;QACpB,SAAS,EAAE,aAAa,CAAC,QAAQ;KAClC,CAAC;IAEF,IAAI,MAAM,CAAC,SAAS,K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AAC;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, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\r\nimport { getClassEditor, 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<CustomAttributeClass>(schemaItemKey);\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 = new SchemaItemKey(change.itemName, context.targetSchemaKey);\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 = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n const [propertyName] = change.path.split(\".\");\r\n const editor = await getClassEditor(context, itemKey);\r\n await editor.properties.addCustomAttribute(itemKey, propertyName, caInstance);\r\n }\r\n if (change.appliedTo === \"RelationshipConstraint\") {\r\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n const relationshipClass = await context.targetSchema.lookupItem<RelationshipClass>(itemKey);\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"]}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* @module Merging
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.applyRenamePropertyEdit = applyRenamePropertyEdit;
|
|
11
|
+
exports.applyRenameSchemaItemEdit = applyRenameSchemaItemEdit;
|
|
11
12
|
const SchemaDifference_1 = require("../../Differencing/SchemaDifference");
|
|
12
13
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
13
14
|
const Utils = require("../../Differencing/Utils");
|
|
@@ -28,13 +29,12 @@ function applyRenamePropertyEdit(result, edit) {
|
|
|
28
29
|
}
|
|
29
30
|
propertyDifference.path = edit.value;
|
|
30
31
|
if (result.conflicts) {
|
|
31
|
-
const conflictIndex = result.conflicts.findIndex((entry) => entry.
|
|
32
|
+
const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === propertyDifference);
|
|
32
33
|
if (conflictIndex > -1) {
|
|
33
34
|
result.conflicts.splice(conflictIndex, 1);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
exports.applyRenamePropertyEdit = applyRenamePropertyEdit;
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
@@ -52,7 +52,7 @@ function applyRenameSchemaItemEdit(result, edit, postProcessing) {
|
|
|
52
52
|
}
|
|
53
53
|
renameName(itemDifference, itemName, edit.value);
|
|
54
54
|
if (result.conflicts) {
|
|
55
|
-
const conflictIndex = result.conflicts.findIndex((entry) => entry.
|
|
55
|
+
const conflictIndex = result.conflicts.findIndex((entry) => entry.difference === itemDifference);
|
|
56
56
|
if (conflictIndex > -1) {
|
|
57
57
|
result.conflicts.splice(conflictIndex, 1);
|
|
58
58
|
}
|
|
@@ -61,7 +61,6 @@ function applyRenameSchemaItemEdit(result, edit, postProcessing) {
|
|
|
61
61
|
renameSchemaItem(result, edit, itemDifference.schemaType);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
exports.applyRenameSchemaItemEdit = applyRenameSchemaItemEdit;
|
|
65
64
|
function renameSchemaItem(result, edit, schemaType) {
|
|
66
65
|
const schemaKey = ecschema_metadata_1.SchemaKey.parseString(result.sourceSchemaName);
|
|
67
66
|
const [_schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(edit.key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenameEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/RenameEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,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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AAC,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.itemName === itemName && entry.path === path);\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.itemName === itemName && entry.path === undefined);\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
|
+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AAK,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkipEditHandler.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SkipEditHandler.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAuB,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAEvG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,QAAQ,QAkB3E"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Merging
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.applySkipEdit =
|
|
10
|
+
exports.applySkipEdit = applySkipEdit;
|
|
11
11
|
/**
|
|
12
12
|
* Applies a skip edit to the schema differences. It basically removes all entries that
|
|
13
13
|
* that are associated with the item to skip.
|
|
@@ -23,18 +23,18 @@ function applySkipEdit(result, edit) {
|
|
|
23
23
|
const foundIndices = pathName !== undefined
|
|
24
24
|
? findRelatedItemEntries(result, itemName, pathName)
|
|
25
25
|
: findItemEntries(result, itemName);
|
|
26
|
+
const skippedDifferences = [];
|
|
26
27
|
for (const index of foundIndices.reverse()) {
|
|
27
|
-
result.differences.splice(index, 1);
|
|
28
|
+
skippedDifferences.push(...result.differences.splice(index, 1));
|
|
28
29
|
}
|
|
29
30
|
if (result.conflicts) {
|
|
30
|
-
removeRelatedConflicts(result.conflicts,
|
|
31
|
+
removeRelatedConflicts(result.conflicts, skippedDifferences);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
function removeRelatedConflicts(conflicts, itemName, path) {
|
|
34
|
+
function removeRelatedConflicts(conflicts, skippedDifferences) {
|
|
35
35
|
const indices = [];
|
|
36
36
|
conflicts.forEach((conflict, index) => {
|
|
37
|
-
if (
|
|
37
|
+
if (skippedDifferences.includes(conflict.difference)) {
|
|
38
38
|
indices.push(index);
|
|
39
39
|
}
|
|
40
40
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG
|
|
1
|
+
{"version":3,"file":"SkipEditHandler.js","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAaH,sCAkBC;AAzBD;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,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,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB;IAChF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,sBAAsB,CAAC,EAAE,WAAW,EAA0B,EAAE,QAAgB,EAAE,QAAgB;IACzG,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QACxC,IAAI,UAAU,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { AnySchemaDifference, SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\r\nimport type { AnySchemaDifferenceConflict } from \"../../Differencing/SchemaConflicts\";\r\nimport type { SkipEdit } from \"./SchemaEdits\";\r\n\r\n/**\r\n * Applies a skip edit to the schema differences. It basically removes all entries that\r\n * that are associated with the item to skip.\r\n * @param result The result of a schema differencing run\r\n * @param edit The skip edit to be applied.\r\n * @internal\r\n */\r\nexport function applySkipEdit(result: SchemaDifferenceResult, edit: SkipEdit) {\r\n const [schemaName, itemName, pathName] = edit.key.split(\".\") as [string, string, string | undefined];\r\n if (!result.sourceSchemaName.startsWith(schemaName)) {\r\n return;\r\n }\r\n\r\n const foundIndices = pathName !== undefined\r\n ? findRelatedItemEntries(result, itemName, pathName)\r\n : findItemEntries(result, itemName);\r\n\r\n const skippedDifferences: AnySchemaDifference[] = [];\r\n for (const index of foundIndices.reverse()) {\r\n skippedDifferences.push(...result.differences.splice(index, 1));\r\n }\r\n\r\n if (result.conflicts) {\r\n removeRelatedConflicts(result.conflicts, skippedDifferences);\r\n }\r\n}\r\n\r\nfunction removeRelatedConflicts(conflicts: AnySchemaDifferenceConflict[], skippedDifferences: AnySchemaDifference[]) {\r\n const indices: number[] = [];\r\n conflicts.forEach((conflict, index) => {\r\n if (skippedDifferences.includes(conflict.difference)) {\r\n indices.push(index);\r\n }\r\n });\r\n\r\n for (const index of indices.reverse()) {\r\n conflicts.splice(index, 1);\r\n }\r\n}\r\n\r\nfunction findItemEntries({ differences }: SchemaDifferenceResult, itemName: string): number[] {\r\n const found: number[] = [];\r\n differences.forEach((difference, index) => {\r\n if (\"itemName\" in difference && difference.itemName === itemName) {\r\n found.push(index);\r\n }\r\n });\r\n return found;\r\n}\r\n\r\nfunction findRelatedItemEntries({ differences }: SchemaDifferenceResult, itemName: string, pathName: string): number[] {\r\n const found: number[] = [];\r\n differences.forEach((difference, index) => {\r\n if (\"itemName\" in difference && difference.itemName === itemName && \"path\" in difference && difference.path === pathName) {\r\n found.push(index);\r\n }\r\n });\r\n return found;\r\n}\r\n\r\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addEntityClass = addEntityClass;
|
|
4
|
+
exports.modifyEntityClass = modifyEntityClass;
|
|
5
|
+
exports.addClassMixins = addClassMixins;
|
|
4
6
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
7
|
const ClassMerger_1 = require("./ClassMerger");
|
|
6
8
|
const Utils_1 = require("./Utils");
|
|
@@ -15,7 +17,6 @@ async function addEntityClass(context, change) {
|
|
|
15
17
|
...change.difference,
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
|
-
exports.addEntityClass = addEntityClass;
|
|
19
20
|
/**
|
|
20
21
|
* Merges differences to an existing EntityClass in the target schema.
|
|
21
22
|
* @internal
|
|
@@ -30,7 +31,6 @@ async function modifyEntityClass(context, change, itemKey) {
|
|
|
30
31
|
}
|
|
31
32
|
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
|
|
32
33
|
}
|
|
33
|
-
exports.modifyEntityClass = modifyEntityClass;
|
|
34
34
|
/**
|
|
35
35
|
* Merges Mixins to Entity Class schema items.
|
|
36
36
|
* @internal
|
|
@@ -42,5 +42,4 @@ async function addClassMixins(context, change) {
|
|
|
42
42
|
await context.editor.entities.addMixin(entityKey, mixinKey);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
exports.addClassMixins = addClassMixins;
|
|
46
45
|
//# sourceMappingURL=EntityClassMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAeA,wCAOC;AAMD,8CAUC;AAMD,wCAMC;AA3CD,gEAAyD;AACzD,+CAA4C;AAC5C,mCAA8C;AAE9C;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACrE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QAEjC,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAuB,CAAC;IAClF,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1C,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAAkC;IAClG,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAC9E,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9D,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\nimport type { EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { updateSchemaItemKey } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new EntityClass into the target schema.\r\n * @internal\r\n */\r\nexport async function addEntityClass(context: SchemaMergeContext, change: EntityClassDifference) {\r\n await context.editor.entities.createFromProps(context.targetSchemaKey, {\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n\r\n ...change.difference,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing EntityClass in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyEntityClass(context: SchemaMergeContext, change: EntityClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableEntityClass;\r\n if(change.difference.mixins !== undefined) {\r\n for(const mixin of change.difference.mixins) {\r\n const mixinKey = await updateSchemaItemKey(context, mixin);\r\n await context.editor.entities.addMixin(itemKey, mixinKey);\r\n }\r\n }\r\n\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n\r\n/**\r\n * Merges Mixins to Entity Class schema items.\r\n * @internal\r\n */\r\nexport async function addClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<void> {\r\n for(const mixinFullName of change.difference) {\r\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\r\n const entityKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n await context.editor.entities.addMixin(entityKey, mixinKey);\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addEnumeration = addEnumeration;
|
|
4
|
+
exports.modifyEnumeration = modifyEnumeration;
|
|
4
5
|
/*---------------------------------------------------------------------------------------------
|
|
5
6
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
7
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -29,7 +30,6 @@ async function addEnumeration(context, change) {
|
|
|
29
30
|
enumerators: change.difference.enumerators,
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
exports.addEnumeration = addEnumeration;
|
|
33
33
|
/**
|
|
34
34
|
* Merges differences to an existing Enumeration in the target schema.
|
|
35
35
|
* @internal
|
|
@@ -49,5 +49,4 @@ async function modifyEnumeration(context, change, itemKey) {
|
|
|
49
49
|
enumeration.setIsStrict(change.difference.isStrict);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
exports.modifyEnumeration = modifyEnumeration;
|
|
53
52
|
//# sourceMappingURL=EnumerationMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAaA,wCAmBC;AAMD,8CAcC;AApDD;;;+FAG+F;AAC/F,gEAAqF;AAKrF;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QA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,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtD,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\nimport { primitiveTypeToString, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport type { EnumerationDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\r\n\r\n/**\r\n * Merges a new Enumeration into the target schema.\r\n * @internal\r\n */\r\nexport async function addEnumeration(context: SchemaMergeContext, change: EnumerationDifference) {\r\n if (change.difference.type === undefined) {\r\n throw new Error(\"Enumerations must define a type property\");\r\n }\r\n if (change.difference.isStrict === undefined) {\r\n throw new Error(\"Enumerations must define whether enumeration is strict.\");\r\n }\r\n if (change.difference.enumerators === undefined) {\r\n throw new Error(\"Enumerations must define at least ine enumerator.\");\r\n }\r\n\r\n await context.editor.enumerations.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n type: change.difference.type,\r\n isStrict: change.difference.isStrict,\r\n enumerators: change.difference.enumerators,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Enumeration in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyEnumeration(context: SchemaMergeContext, change: EnumerationDifference, itemKey: SchemaItemKey) {\r\n const enumeration = await context.targetSchema.lookupItem(itemKey) as MutableEnumeration;\r\n if(change.difference.type !== undefined) {\r\n throw new Error(`The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(enumeration.type!)}\", not \"${change.difference.type}\".`);\r\n }\r\n if(change.difference.label !== undefined) {\r\n await context.editor.enumerations.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.enumerations.setDescription(itemKey, change.difference.description);\r\n }\r\n if(change.difference.isStrict !== undefined) {\r\n enumeration.setIsStrict(change.difference.isStrict);\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addEnumerator = addEnumerator;
|
|
4
|
+
exports.modifyEnumerator = modifyEnumerator;
|
|
4
5
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
6
|
/**
|
|
6
7
|
* Merges a new Enumerator into the target schema.
|
|
@@ -21,7 +22,6 @@ async function addEnumerator(context, change) {
|
|
|
21
22
|
description: change.difference.description,
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
exports.addEnumerator = addEnumerator;
|
|
25
25
|
/**
|
|
26
26
|
* Merges differences to an existing Enumerator in the target schema.
|
|
27
27
|
* @internal
|
|
@@ -37,5 +37,4 @@ async function modifyEnumerator(context, change, itemKey) {
|
|
|
37
37
|
await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.modifyEnumerator = modifyEnumerator;
|
|
41
40
|
//# sourceMappingURL=EnumeratorMerger.js.map
|