@itwin/ecschema-editing 4.5.0-dev.17 → 4.5.0-dev.20
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 +6 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +9 -2
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +25 -0
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +8 -2
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +29 -6
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +7 -1
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +15 -0
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +7 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +20 -1
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +1 -5
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +4 -3
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +57 -49
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +3 -2
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +22 -7
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +1 -5
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +21 -0
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PropertyMerger.js +315 -0
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -0
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +15 -0
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/RelationshipClassMerger.js +132 -0
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -0
- package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +7 -3
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
- package/public/locales/en/ECSchemaEditing.json +26 -26
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts +0 -15
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/AnyPropertyMerger.js +0 -71
- package/lib/cjs/Merging/AnyPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +0 -32
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.js +0 -143
- package/lib/cjs/Merging/ArrayPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts +0 -16
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js +0 -90
- package/lib/cjs/Merging/ClassPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +0 -24
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +0 -106
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/StructPropertyMerger.d.ts +0 -11
- package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/StructPropertyMerger.js +0 -47
- package/lib/cjs/Merging/StructPropertyMerger.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAs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AoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","sourcesContent":["// /*---------------------------------------------------------------------------------------------\n// * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n// * See LICENSE.md in the project root for license terms and full copyright notice.\n// *--------------------------------------------------------------------------------------------*/\nimport { Constant, SchemaItem } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\n\n/**\n * @internal\n */\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\n /**\n * Creates the property value resolver for [[Constant]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\n return {\n phenomenon: (phenomenonFullName, targetItemKey) => {\n // There are two options, either the phenomenon was referenced from another\n // schema or it is defined in the same schema as the constant to be merged.\n // In the latter case, the changes would report a different property value that\n // refers to the source schema. So that needs to be changed here.\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${phenomenonName}`;\n }\n return phenomenonFullName;\n },\n numerator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\n }\n return value;\n },\n denominator: (value, targetItemKey) => {\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\n }\n return value;\n },\n };\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG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AC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","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 { Constant, SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\r\n /**\r\n * Creates the property value resolver for [[Constant]] items.\r\n */\r\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\r\n return {\r\n phenomenon: (phenomenonFullName, targetItemKey) => {\r\n // There are two options, either the phenomenon was referenced from another\r\n // schema or it is defined in the same schema as the constant to be merged.\r\n // In the latter case, the changes would report a different property value that\r\n // refers to the source schema. So that needs to be changed here.\r\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\r\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\r\n return `${targetItemKey.schemaName}.${phenomenonName}`;\r\n }\r\n return phenomenonFullName;\r\n },\r\n numerator: (value, targetItemKey) => {\r\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\r\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\r\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\r\n }\r\n return value;\r\n },\r\n denominator: (value, targetItemKey) => {\r\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\r\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\r\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\r\n }\r\n return value;\r\n },\r\n };\r\n }\r\n}\r\n\r\n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KAAK,SAAS,EAAE;oBACtC,OAAO,EAAG,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;iBAChD;aACF;iBAAM;gBACL,OAAO,EAAE,YAAY,EAAE,+BAA+B,8BAA8B,CAAC,UAAU,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { CustomAttribute, CustomAttributeClass, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ChangeType, CustomAttributeContainerChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\ninterface EditResults {\n errorMessage?: string;\n}\n\n/**\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\n * a scope (Class, Property, Schema) specific handler.\n * @param mergeContext The current schema merging context.\n * @param changes An iterable with custom attribute changes.\n * @param callback The callback to add the custom attribute with a scope specific editor.\n * @returns A EditResults object.\n * @internal\n */\nexport async function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults> {\n for (const customAttributeContainerChange of changes) {\n for (const change of customAttributeContainerChange.customAttributeChanges) {\n if (change.changeType === ChangeType.Missing) {\n const [sourceCustomAttribute] = change.diagnostic.messageArgs as [CustomAttribute];\n const [schemaName, itemName] = SchemaItem.parseFullName(sourceCustomAttribute.className);\n const schemaItemKey = new SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)\n ? mergeContext.targetSchema.schemaKey\n : new SchemaKey(schemaName),\n );\n const targetCustomAttribute = await mergeContext.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\n if (targetCustomAttribute === undefined) {\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`};\n }\n\n const results = await callback({\n ...sourceCustomAttribute,\n className: targetCustomAttribute.fullName,\n });\n\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage };\n }\n } else {\n return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.`};\n }\n }\n }\n return {};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuH;AACvH,+DAA0F;AAO1F;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CAAC,YAAgC,EAAE,OAAkD,EAAE,QAAoE;IACpM,KAAK,MAAM,8BAA8B,IAAI,OAAO,EAAE;QACpD,KAAK,MAAM,MAAM,IAAI,8BAA8B,CAAC,sBAAsB,EAAE;YAC1E,IAAI,MAAM,CAAC,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAC5C,MAAM,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,WAAgC,CAAC;gBACnF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAI,8BAAU,CAAC,aAAa,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;gBAC1F,MAAM,aAAa,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC;oBAC7G,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS;oBACrC,CAAC,CAAC,IAAI,6BAAS,CAAC,UAAU,CAAC,CAC5B,CAAC;gBACF,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC;gBAC9G,IAAI,qBAAqB,KAAK,SAAS,EAAE;oBACvC,OAAO,EAAE,YAAY,EAAE,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,EAAC,CAAC;iBACnH;gBAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC;oBAC7B,GAAG,qBAAqB;oBACxB,SAAS,EAAE,qBAAqB,CAAC,QAAQ;iBAC1C,CAAC,CAAC;gBAEH,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,OAAO,EAAG,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;iBAChD;aACF;iBAAM;gBACL,OAAO,EAAE,YAAY,EAAE,+BAA+B,8BAA8B,CAAC,UAAU,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { CustomAttribute, CustomAttributeClass, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, CustomAttributeContainerChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\ninterface EditResults {\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\r\n * a scope (Class, Property, Schema) specific handler.\r\n * @param mergeContext The current schema merging context.\r\n * @param changes An iterable with custom attribute changes.\r\n * @param callback The callback to add the custom attribute with a scope specific editor.\r\n * @returns A EditResults object.\r\n * @internal\r\n */\r\nexport async function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults> {\r\n for (const customAttributeContainerChange of changes) {\r\n for (const change of customAttributeContainerChange.customAttributeChanges) {\r\n if (change.changeType === ChangeType.Missing) {\r\n const [sourceCustomAttribute] = change.diagnostic.messageArgs as [CustomAttribute];\r\n const [schemaName, itemName] = SchemaItem.parseFullName(sourceCustomAttribute.className);\r\n const schemaItemKey = new SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)\r\n ? mergeContext.targetSchema.schemaKey\r\n : new SchemaKey(schemaName),\r\n );\r\n const targetCustomAttribute = await mergeContext.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\r\n if (targetCustomAttribute === undefined) {\r\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`};\r\n }\r\n\r\n const results = await callback({\r\n ...sourceCustomAttribute,\r\n className: targetCustomAttribute.fullName,\r\n });\r\n\r\n if (results.errorMessage !== undefined) {\r\n return { errorMessage: results.errorMessage };\r\n }\r\n } else {\r\n return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.`};\r\n }\r\n }\r\n }\r\n return {};\r\n}\r\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { EntityClass,
|
|
1
|
+
import { EntityClass, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
2
2
|
import { ClassMerger } from "./ClassMerger";
|
|
3
3
|
import { SchemaItemEditResults } from "../Editing/Editor";
|
|
4
|
+
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
4
5
|
/**
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
8
|
export default class EntityClassMerger extends ClassMerger<EntityClass> {
|
|
8
9
|
protected create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults>;
|
|
9
|
-
protected
|
|
10
|
+
protected merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults>;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=EntityClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAS,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAc,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW,CAAC,WAAW,CAAC;cAC5C,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAIlF,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAuB9G"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
*--------------------------------------------------------------------------------------------*/
|
|
7
7
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
8
|
const ClassMerger_1 = require("./ClassMerger");
|
|
9
|
+
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
9
10
|
/**
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
@@ -13,13 +14,27 @@ class EntityClassMerger extends ClassMerger_1.ClassMerger {
|
|
|
13
14
|
async create(schemaKey, ecClass) {
|
|
14
15
|
return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);
|
|
15
16
|
}
|
|
16
|
-
async
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
async merge(itemKey, changes) {
|
|
18
|
+
if (changes.entityMixinChanges.size > 0) {
|
|
19
|
+
if (changes.schemaItemMissing?.changeType !== SchemaChanges_1.ChangeType.Missing) {
|
|
20
|
+
return { errorMessage: `Changing the entity class '${itemKey.name}' mixins is not supported.` };
|
|
21
|
+
}
|
|
22
|
+
for (const change of changes.entityMixinChanges.values()) {
|
|
23
|
+
for (const entityMixinChange of change.entityMixinChange) {
|
|
24
|
+
const mixins = entityMixinChange.diagnostic.messageArgs;
|
|
25
|
+
for (const mixin of mixins) {
|
|
26
|
+
const mixinKey = new ecschema_metadata_1.SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)
|
|
27
|
+
? this.context.targetSchema.schemaKey
|
|
28
|
+
: mixin.schema.schemaKey);
|
|
29
|
+
const result = await this.context.editor.entities.addMixin(itemKey, mixinKey);
|
|
30
|
+
if (result.errorMessage !== undefined) {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { itemKey };
|
|
23
38
|
}
|
|
24
39
|
}
|
|
25
40
|
exports.default = EntityClassMerger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAE5C,+DAAuE;AAEvE;;GAEG;AACH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O,MAAM,CAAC;yBACf;qBACF;iBACF;aACF;SACF;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AA5BD,oCA4BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { EntityClass, Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { ClassMerger } from \"./ClassMerger\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { ChangeType, ClassChanges } from \"../Validation/SchemaChanges\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class EntityClassMerger extends ClassMerger<EntityClass> {\r\n protected override async create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults> {\r\n return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults> {\r\n if (changes.entityMixinChanges.size > 0) {\r\n if (changes.schemaItemMissing?.changeType !== ChangeType.Missing) {\r\n return { errorMessage: `Changing the entity class '${itemKey.name}' mixins is not supported.`};\r\n }\r\n\r\n for (const change of changes.entityMixinChanges.values()) {\r\n for (const entityMixinChange of change.entityMixinChange) {\r\n const mixins = entityMixinChange.diagnostic.messageArgs! as unknown as [Mixin];\r\n for (const mixin of mixins) {\r\n const mixinKey = new SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : mixin.schema.schemaKey);\r\n const result = await this.context.editor.entities.addMixin(itemKey, mixinKey);\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return { itemKey };\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumeration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AoE;QACpE,IAAG,YAAY,KAAK,OAAO,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\n\n/**\n * @internal\n */\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\n\n /** Shorthand property to the enumerations editor. */\n private get _editor() {\n return this.context.editor.enumerations;\n }\n\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\n // In case the enumerator entry does not exist in the target enumeration the\n // enumeratorMissing property is set and\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\n\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\n if (enumerator === undefined) {\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\n }\n\n // Enumerators are plain javascript objects with out any references to other\n // instances or a schema. That allows to simply copy them over.\n await this._editor.addEnumerator(itemKey, enumerator);\n\n // Since every missing enumerator has delta changes for ech property, the loop\n // must call continue here to avoid having all properties checked and set again.\n continue;\n }\n\n // For changes where the enumerators differ, the enumeratorDeltas property is\n // filled. This allows to change individual enumerator entries. This is only\n // allowed for labels and descriptions, all other deltas would throw an error.\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\n }\n }\n }\n\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\n // In case an enumerator has the same name but different value, the enumerator\n // cannot be merged to keep integrity for the existing schema users.\n if(propertyName === \"value\") {\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\n }\n\n // For the other two properties they shall only be merged if the source value is\n // set. In case they'd be undefined, the current enumerators value shall be kept.\n if(propertyName === \"label\" && value !== undefined) {\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\n }\n if(propertyName === \"description\" && value !== undefined) {\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAA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AAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","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 { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\r\n\r\n /** Shorthand property to the enumerations editor. */\r\n private get _editor() {\r\n return this.context.editor.enumerations;\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\r\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\r\n // In case the enumerator entry does not exist in the target enumeration the\r\n // enumeratorMissing property is set and\r\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\r\n\r\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\r\n if (enumerator === undefined) {\r\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\r\n }\r\n\r\n // Enumerators are plain javascript objects with out any references to other\r\n // instances or a schema. That allows to simply copy them over.\r\n await this._editor.addEnumerator(itemKey, enumerator);\r\n\r\n // Since every missing enumerator has delta changes for ech property, the loop\r\n // must call continue here to avoid having all properties checked and set again.\r\n continue;\r\n }\r\n\r\n // For changes where the enumerators differ, the enumeratorDeltas property is\r\n // filled. This allows to change individual enumerator entries. This is only\r\n // allowed for labels and descriptions, all other deltas would throw an error.\r\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\r\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\r\n }\r\n }\r\n }\r\n\r\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\r\n // In case an enumerator has the same name but different value, the enumerator\r\n // cannot be merged to keep integrity for the existing schema users.\r\n if(propertyName === \"value\") {\r\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\r\n }\r\n\r\n // For the other two properties they shall only be merged if the source value is\r\n // set. In case they'd be undefined, the current enumerators value shall be kept.\r\n if(propertyName === \"label\" && value !== undefined) {\r\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\r\n }\r\n if(propertyName === \"description\" && value !== undefined) {\r\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB,SAAQ,mCAAgC;IAE7D,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAsB,EAAE,OAA8B;QAC3G,KAAK,MAAM,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,EAAE;YAC7E,KAAK,MAAM,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,EAAE;gBAClE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,WAAY,CAAC,CAAC,CAAC,CAAC;gBACjD,MAAM,SAAS,GAAG,MAAM,CAAC,yBAAyB,KAAK,MAAM,CAAC;gBAE9D,IAAI,kCAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;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BAAgB,CAAC,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Format, InvertedUnit, KindOfQuantity, OverrideFormat, SchemaItem, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\nimport { KindOfQuantityChanges } from \"../Validation/SchemaChanges\";\n\n/**\n * @internal\n */\nexport default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {\n\n protected override async merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges) {\n for (const presentationUnitChange of changes.presentationUnitChanges.values()) {\n for (const change of presentationUnitChange.presentationUnitChange) {\n const format = change.diagnostic.messageArgs![0];\n const isDefault = source.defaultPresentationFormat === format;\n\n if (OverrideFormat.isOverrideFormat(format)) {\n const parentFormat = await this.lookup<Format>(format.parent);\n if (parentFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);\n }\n\n const unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined = [];\n if (format.units !== undefined) {\n for (const [unit, label] of format.units) {\n const targetUnit = await this.lookup<Unit | InvertedUnit>(unit);\n if (targetUnit === undefined) {\n throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);\n }\n unitAndLabels.push([targetUnit, label]);\n }\n }\n const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);\n await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);\n } else {\n const targetFormat = await this.lookup<Format>(format);\n if (targetFormat === undefined) {\n throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);\n }\n await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);\n }\n }\n }\n }\n\n /**\n *\n * Creates the property value resolver for [[KindOfQuantity]] items.\n */\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>> {\n return {\n persistenceUnit: (newValue, targetItemKey, oldValue) => {\n if (oldValue !== undefined && oldValue !== newValue) {\n throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);\n }\n const [schemaName, itemName] = SchemaItem.parseFullName(newValue);\n if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\n return `${targetItemKey.schemaName}.${itemName}`;\n }\n return newValue;\n },\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB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AM,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;oBACnJ,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;iBAC9G;qBAAM;oBACL,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,CAAC;oBACvD,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAC3F;oBACD,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { Format, InvertedUnit, KindOfQuantity, OverrideFormat, SchemaItem, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\r\nimport { KindOfQuantityChanges } from \"../Validation/SchemaChanges\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges) {\r\n for (const presentationUnitChange of changes.presentationUnitChanges.values()) {\r\n for (const change of presentationUnitChange.presentationUnitChange) {\r\n const format = change.diagnostic.messageArgs![0];\r\n const isDefault = source.defaultPresentationFormat === format;\r\n\r\n if (OverrideFormat.isOverrideFormat(format)) {\r\n const parentFormat = await this.lookup<Format>(format.parent);\r\n if (parentFormat === undefined) {\r\n throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);\r\n }\r\n\r\n const unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined = [];\r\n if (format.units !== undefined) {\r\n for (const [unit, label] of format.units) {\r\n const targetUnit = await this.lookup<Unit | InvertedUnit>(unit);\r\n if (targetUnit === undefined) {\r\n throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);\r\n }\r\n unitAndLabels.push([targetUnit, label]);\r\n }\r\n }\r\n const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);\r\n await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);\r\n } else {\r\n const targetFormat = await this.lookup<Format>(format);\r\n if (targetFormat === undefined) {\r\n throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);\r\n }\r\n await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * Creates the property value resolver for [[KindOfQuantity]] items.\r\n */\r\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>> {\r\n return {\r\n persistenceUnit: (newValue, targetItemKey, oldValue) => {\r\n if (oldValue !== undefined && oldValue !== newValue) {\r\n throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);\r\n }\r\n const [schemaName, itemName] = SchemaItem.parseFullName(newValue);\r\n if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\r\n return `${targetItemKey.schemaName}.${itemName}`;\r\n }\r\n return newValue;\r\n },\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,KAAK,CAAC;cAEhC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAW5E,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,KAAK,CAAC;cAEhC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAW5E,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;CAU1K"}
|
|
@@ -20,10 +20,6 @@ class MixinMerger extends ClassMerger_1.ClassMerger {
|
|
|
20
20
|
return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);
|
|
21
21
|
}
|
|
22
22
|
async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
|
|
23
|
-
const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
|
|
24
|
-
if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
|
|
25
|
-
return results;
|
|
26
|
-
}
|
|
27
23
|
switch (attributeName) {
|
|
28
24
|
case "appliesTo":
|
|
29
25
|
if (attributeOldValue !== undefined) {
|
|
@@ -31,7 +27,7 @@ class MixinMerger extends ClassMerger_1.ClassMerger {
|
|
|
31
27
|
}
|
|
32
28
|
return true;
|
|
33
29
|
}
|
|
34
|
-
return
|
|
30
|
+
return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
exports.default = MixinMerger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yB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AAC,SAAS,CAAC;YAClI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAAc,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC5H,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,EAAE;oBACnC,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;iBAC7F;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AAvBD,8BAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { ClassMerger } from \"./ClassMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class MixinMerger extends ClassMerger<Mixin> {\r\n\r\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\r\n if (ecClass.appliesTo === undefined) {\r\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\r\n }\r\n\r\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : ecClass.appliesTo.schemaKey);\r\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\r\n }\r\n\r\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n switch(attributeName) {\r\n case \"appliesTo\":\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\r\n }\r\n return true;\r\n }\r\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Property, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import { PropertyEditResults } from "../Editing/Editor";
|
|
4
|
+
import { PropertyValueChange } from "../Validation/SchemaChanges";
|
|
5
|
+
/**
|
|
6
|
+
* Updates property with attribute value changes.
|
|
7
|
+
* @param context The current merging context.
|
|
8
|
+
* @param property The Property object to be changed.
|
|
9
|
+
* @param propertyValueChanges The changes to be applied to the property.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergePropertyAttributeValueChanges(context: SchemaMergeContext, property: Property, propertyValueChanges: PropertyValueChange[]): Promise<PropertyEditResults>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Property through a PropertyProps.
|
|
15
|
+
* @param context The current merging context.
|
|
16
|
+
* @param classKey The SchemaItemKey of the class.
|
|
17
|
+
* @param property The Property object to be cloned.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function createPropertyFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: Property): Promise<PropertyEditResults>;
|
|
21
|
+
//# sourceMappingURL=PropertyMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuI,QAAQ,EAAwF,aAAa,EAAkE,MAAM,0BAA0B,CAAC;AAC9V,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAkBlE;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAYnL;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsCpJ"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPropertyFromProps = exports.mergePropertyAttributeValueChanges = 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
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
|
+
async function mergePropertyAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
10
|
+
if (property.isEnumeration()) {
|
|
11
|
+
return EnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
12
|
+
}
|
|
13
|
+
if (property.isPrimitive()) {
|
|
14
|
+
return PrimitivePropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
15
|
+
}
|
|
16
|
+
if (property.isStruct()) {
|
|
17
|
+
return StructPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
18
|
+
}
|
|
19
|
+
if (property.isNavigation()) {
|
|
20
|
+
return NavigationPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Updates property with attribute value changes.
|
|
26
|
+
* @param context The current merging context.
|
|
27
|
+
* @param property The Property object to be changed.
|
|
28
|
+
* @param propertyValueChanges The changes to be applied to the property.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
async function mergePropertyAttributeValueChanges(context, property, propertyValueChanges) {
|
|
32
|
+
for (const change of propertyValueChanges) {
|
|
33
|
+
const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs;
|
|
34
|
+
const results = await mergePropertyAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
35
|
+
if (!results) {
|
|
36
|
+
return { errorMessage: `Property ${property.fullName} attribute ${attributeName} change is not implemented.` };
|
|
37
|
+
}
|
|
38
|
+
if (typeof results === "object" && "errorMessage" in results && results.errorMessage !== undefined) {
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { itemKey: property.class.key, propertyName: property.name };
|
|
43
|
+
}
|
|
44
|
+
exports.mergePropertyAttributeValueChanges = mergePropertyAttributeValueChanges;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a Property through a PropertyProps.
|
|
47
|
+
* @param context The current merging context.
|
|
48
|
+
* @param classKey The SchemaItemKey of the class.
|
|
49
|
+
* @param property The Property object to be cloned.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
async function createPropertyFromProps(context, classKey, property) {
|
|
53
|
+
let props = {};
|
|
54
|
+
if (property.category !== undefined) {
|
|
55
|
+
const sourceCategory = await property.category;
|
|
56
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(sourceCategory.name, context.sourceSchema.schemaKey.matches(sourceCategory.schema.schemaKey)
|
|
57
|
+
? context.targetSchema.schemaKey
|
|
58
|
+
: sourceCategory.schema.schemaKey);
|
|
59
|
+
const targetCategory = await context.targetSchema.lookupItem(itemKey);
|
|
60
|
+
if (targetCategory === undefined) {
|
|
61
|
+
return { errorMessage: `Unable to locate the property category class ${sourceCategory.name} in the context schema.` };
|
|
62
|
+
}
|
|
63
|
+
props = { ...props, category: targetCategory.fullName };
|
|
64
|
+
}
|
|
65
|
+
if (property.kindOfQuantity !== undefined) {
|
|
66
|
+
const sourceKoq = await property.kindOfQuantity;
|
|
67
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(sourceKoq.name, context.sourceSchema.schemaKey.matches(sourceKoq.schema.schemaKey)
|
|
68
|
+
? context.targetSchema.schemaKey
|
|
69
|
+
: sourceKoq.schema.schemaKey);
|
|
70
|
+
const targetKoq = await context.targetSchema.lookupItem(itemKey);
|
|
71
|
+
if (targetKoq === undefined) {
|
|
72
|
+
return { errorMessage: `Unable to locate the property kind of quantity class ${sourceKoq.name} in the context schema.` };
|
|
73
|
+
}
|
|
74
|
+
props = { ...props, kindOfQuantity: targetKoq.fullName };
|
|
75
|
+
}
|
|
76
|
+
if (property.isEnumeration())
|
|
77
|
+
return EnumPropertyMerger.createFromProps(context, classKey, property, props);
|
|
78
|
+
if (property.isPrimitive())
|
|
79
|
+
return PrimitivePropertyMerger.createFromProps(context, classKey, property, props);
|
|
80
|
+
if (property.isStruct())
|
|
81
|
+
return StructPropertyMerger.createFromProps(context, classKey, property, props);
|
|
82
|
+
if (property.isNavigation())
|
|
83
|
+
return NavigationPropertyMerger.createFromProps(context, classKey, property, props);
|
|
84
|
+
return { errorMessage: `Unsupported Property Type: ${(0, ecschema_metadata_1.propertyTypeToString)(property.propertyType)}` };
|
|
85
|
+
}
|
|
86
|
+
exports.createPropertyFromProps = createPropertyFromProps;
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
var PropertyMerger;
|
|
91
|
+
(function (PropertyMerger) {
|
|
92
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, _attributeOldValue) {
|
|
93
|
+
const mutableProperty = property;
|
|
94
|
+
switch (attributeName) {
|
|
95
|
+
case "type":
|
|
96
|
+
return { errorMessage: `Changing the property '${property.fullName}' type is not supported.` };
|
|
97
|
+
case "description":
|
|
98
|
+
mutableProperty.setDescription(attributeNewValue);
|
|
99
|
+
return true;
|
|
100
|
+
case "label":
|
|
101
|
+
mutableProperty.setLabel(attributeNewValue);
|
|
102
|
+
return true;
|
|
103
|
+
case "isReadOnly":
|
|
104
|
+
mutableProperty.setIsReadOnly(attributeNewValue);
|
|
105
|
+
return true;
|
|
106
|
+
case "priority":
|
|
107
|
+
mutableProperty.setPriority(attributeNewValue);
|
|
108
|
+
return true;
|
|
109
|
+
case "category":
|
|
110
|
+
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(attributeNewValue);
|
|
111
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(itemName, context.sourceSchema.schemaKey.compareByName(schemaName)
|
|
112
|
+
? context.targetSchema.schemaKey
|
|
113
|
+
: new ecschema_metadata_1.SchemaKey(schemaName));
|
|
114
|
+
return context.editor.entities.setPropertyCategory(property.class.key, property.name, itemKey);
|
|
115
|
+
case "kindOfQuantity":
|
|
116
|
+
return { errorMessage: `Changing the property '${property.fullName}' kind of quantity is not supported.` };
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
PropertyMerger.mergeAttributes = mergeAttributes;
|
|
121
|
+
})(PropertyMerger || (PropertyMerger = {}));
|
|
122
|
+
/**
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
125
|
+
var ArrayPropertyMerger;
|
|
126
|
+
(function (ArrayPropertyMerger) {
|
|
127
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
128
|
+
const mutableProperty = property;
|
|
129
|
+
switch (attributeName) {
|
|
130
|
+
case "minOccurs":
|
|
131
|
+
mutableProperty.setMinOccurs(attributeNewValue);
|
|
132
|
+
return true;
|
|
133
|
+
case "maxOccurs":
|
|
134
|
+
mutableProperty.setMaxOccurs(attributeNewValue);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
138
|
+
}
|
|
139
|
+
ArrayPropertyMerger.mergeAttributes = mergeAttributes;
|
|
140
|
+
})(ArrayPropertyMerger || (ArrayPropertyMerger = {}));
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
var PrimitiveOrEnumPropertyMerger;
|
|
145
|
+
(function (PrimitiveOrEnumPropertyMerger) {
|
|
146
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
147
|
+
const mutableProperty = property;
|
|
148
|
+
switch (attributeName) {
|
|
149
|
+
case "extendedTypeName": {
|
|
150
|
+
mutableProperty.setExtendedTypeName(attributeNewValue);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
case "minLength": {
|
|
154
|
+
mutableProperty.setMinLength(attributeNewValue);
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
case "maxLength": {
|
|
158
|
+
mutableProperty.setMaxLength(attributeNewValue);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
case "minValue": {
|
|
162
|
+
mutableProperty.setMinValue(attributeNewValue);
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
case "maxValue": {
|
|
166
|
+
mutableProperty.setMaxValue(attributeNewValue);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (property.isArray()) {
|
|
171
|
+
return ArrayPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
172
|
+
}
|
|
173
|
+
return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
174
|
+
}
|
|
175
|
+
PrimitiveOrEnumPropertyMerger.mergeAttributes = mergeAttributes;
|
|
176
|
+
})(PrimitiveOrEnumPropertyMerger || (PrimitiveOrEnumPropertyMerger = {}));
|
|
177
|
+
/**
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
var EnumPropertyMerger;
|
|
181
|
+
(function (EnumPropertyMerger) {
|
|
182
|
+
async function createFromProps(context, classKey, property, props) {
|
|
183
|
+
if (property.enumeration === undefined) {
|
|
184
|
+
return { errorMessage: `Property ${property.fullName} is missing the required 'enumeration' attribute.` };
|
|
185
|
+
}
|
|
186
|
+
const enumeration = await property.enumeration;
|
|
187
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(enumeration.name, context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)
|
|
188
|
+
? context.targetSchema.schemaKey
|
|
189
|
+
: enumeration.schema.schemaKey);
|
|
190
|
+
const type = await context.targetSchema.lookupItem(itemKey);
|
|
191
|
+
if (type === undefined) {
|
|
192
|
+
return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the context schema.` };
|
|
193
|
+
}
|
|
194
|
+
const enumProps = {
|
|
195
|
+
...property.toJSON(),
|
|
196
|
+
...props,
|
|
197
|
+
typeName: type.fullName,
|
|
198
|
+
};
|
|
199
|
+
if (property.isArray()) {
|
|
200
|
+
return context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, enumProps);
|
|
201
|
+
}
|
|
202
|
+
return context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, enumProps);
|
|
203
|
+
}
|
|
204
|
+
EnumPropertyMerger.createFromProps = createFromProps;
|
|
205
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
206
|
+
switch (attributeName) {
|
|
207
|
+
case "enumeration":
|
|
208
|
+
return { errorMessage: `Changing the property '${property.fullName}' enumeration is not supported.` };
|
|
209
|
+
}
|
|
210
|
+
return PrimitiveOrEnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
211
|
+
}
|
|
212
|
+
EnumPropertyMerger.mergeAttributes = mergeAttributes;
|
|
213
|
+
})(EnumPropertyMerger || (EnumPropertyMerger = {}));
|
|
214
|
+
/**
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
var PrimitivePropertyMerger;
|
|
218
|
+
(function (PrimitivePropertyMerger) {
|
|
219
|
+
async function createFromProps(context, classKey, property, props) {
|
|
220
|
+
const primitiveProps = {
|
|
221
|
+
...property.toJSON(),
|
|
222
|
+
...props,
|
|
223
|
+
};
|
|
224
|
+
if (property.isArray()) {
|
|
225
|
+
return context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, primitiveProps);
|
|
226
|
+
}
|
|
227
|
+
return context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, primitiveProps);
|
|
228
|
+
}
|
|
229
|
+
PrimitivePropertyMerger.createFromProps = createFromProps;
|
|
230
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
231
|
+
switch (attributeName) {
|
|
232
|
+
case "primitiveType":
|
|
233
|
+
return { errorMessage: `Changing the property '${property.fullName}' primitiveType is not supported.` };
|
|
234
|
+
}
|
|
235
|
+
return PrimitiveOrEnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
236
|
+
}
|
|
237
|
+
PrimitivePropertyMerger.mergeAttributes = mergeAttributes;
|
|
238
|
+
})(PrimitivePropertyMerger || (PrimitivePropertyMerger = {}));
|
|
239
|
+
/**
|
|
240
|
+
* @internal
|
|
241
|
+
*/
|
|
242
|
+
var StructPropertyMerger;
|
|
243
|
+
(function (StructPropertyMerger) {
|
|
244
|
+
async function createFromProps(context, classKey, property, props) {
|
|
245
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(property.structClass.name, context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)
|
|
246
|
+
? context.targetSchema.schemaKey
|
|
247
|
+
: property.structClass.schema.schemaKey);
|
|
248
|
+
const type = await context.targetSchema.lookupItem(itemKey);
|
|
249
|
+
if (type === undefined) {
|
|
250
|
+
return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the context schema.` };
|
|
251
|
+
}
|
|
252
|
+
const structProps = {
|
|
253
|
+
...property.toJSON(),
|
|
254
|
+
...props,
|
|
255
|
+
typeName: type.fullName,
|
|
256
|
+
};
|
|
257
|
+
if (property.isArray()) {
|
|
258
|
+
return context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, structProps);
|
|
259
|
+
}
|
|
260
|
+
return context.editor.entities.createStructPropertyFromProps(classKey, property.name, type, structProps);
|
|
261
|
+
}
|
|
262
|
+
StructPropertyMerger.createFromProps = createFromProps;
|
|
263
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
264
|
+
switch (attributeName) {
|
|
265
|
+
case "structClass":
|
|
266
|
+
return { errorMessage: `Changing the property '${property.fullName}' structClass is not supported.` };
|
|
267
|
+
}
|
|
268
|
+
if (property.isArray()) {
|
|
269
|
+
return ArrayPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
270
|
+
}
|
|
271
|
+
return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
272
|
+
}
|
|
273
|
+
StructPropertyMerger.mergeAttributes = mergeAttributes;
|
|
274
|
+
})(StructPropertyMerger || (StructPropertyMerger = {}));
|
|
275
|
+
/**
|
|
276
|
+
* @internal
|
|
277
|
+
*/
|
|
278
|
+
var NavigationPropertyMerger;
|
|
279
|
+
(function (NavigationPropertyMerger) {
|
|
280
|
+
async function createFromProps(context, classKey, property, props) {
|
|
281
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(property.relationshipClass.name, context.sourceSchema.schemaKey.matches(property.relationshipClass.schemaKey)
|
|
282
|
+
? context.targetSchema.schemaKey
|
|
283
|
+
: property.relationshipClass.schemaKey);
|
|
284
|
+
const type = await context.targetSchema.lookupItem(itemKey);
|
|
285
|
+
if (type === undefined) {
|
|
286
|
+
return { errorMessage: `Unable to locate the relationship class ${property.relationshipClass.name} in the context schema.` };
|
|
287
|
+
}
|
|
288
|
+
const navigationProps = {
|
|
289
|
+
...property.toJSON(),
|
|
290
|
+
...props,
|
|
291
|
+
relationshipName: type.fullName,
|
|
292
|
+
};
|
|
293
|
+
if (property.class.schemaItemType === ecschema_metadata_1.SchemaItemType.EntityClass)
|
|
294
|
+
return context.editor.entities.createNavigationPropertyFromProps(classKey, navigationProps);
|
|
295
|
+
if (property.class.schemaItemType === ecschema_metadata_1.SchemaItemType.Mixin)
|
|
296
|
+
return context.editor.mixins.createNavigationPropertyFromProps(classKey, navigationProps);
|
|
297
|
+
if (property.class.schemaItemType === ecschema_metadata_1.SchemaItemType.RelationshipClass)
|
|
298
|
+
return context.editor.relationships.createNavigationPropertyFromProps(classKey, navigationProps);
|
|
299
|
+
return { errorMessage: `Navigation property can't be added to ${(0, ecschema_metadata_1.schemaItemTypeToString)(property.class.schemaItemType)}.` };
|
|
300
|
+
}
|
|
301
|
+
NavigationPropertyMerger.createFromProps = createFromProps;
|
|
302
|
+
async function mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue) {
|
|
303
|
+
switch (attributeName) {
|
|
304
|
+
case "direction": {
|
|
305
|
+
return { errorMessage: `Changing the property '${property.fullName}' direction is not supported.` };
|
|
306
|
+
}
|
|
307
|
+
case "relationshipClass": {
|
|
308
|
+
return { errorMessage: `Changing the property '${property.fullName}' relationship class is not supported.` };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);
|
|
312
|
+
}
|
|
313
|
+
NavigationPropertyMerger.mergeAttributes = mergeAttributes;
|
|
314
|
+
})(NavigationPropertyMerger || (NavigationPropertyMerger = {}));
|
|
315
|
+
//# sourceMappingURL=PropertyMerger.js.map
|