@itwin/ecschema-editing 4.4.0-dev.9 → 4.5.0-dev.2
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.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +5 -0
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +1 -1
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +8 -6
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +2 -0
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +1 -0
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +20 -0
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.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.d.ts +2 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.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.d.ts +9 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.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 +33 -2
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +148 -22
- 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/AnyPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +9 -1
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js +8 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +21 -0
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/CustomAttributeMerger.js +51 -0
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -0
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +15 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.js +66 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -0
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemFactory.js +10 -0
- package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +2 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +11 -4
- 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 -0
- 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/Merging/StructPropertyMerger.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.d.ts +13 -3
- package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
- package/lib/cjs/Validation/ECRules.js +30 -11
- 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.d.ts +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +2 -4
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAiJ;AAIjJ,+DAAgI;AAChI,+DAA4D;AAE5D;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,MAAM,CAAC,UAAqB,EAAE,OA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AAc,KAAK,SAAS,EAAE;gBACvC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;gBAC5F,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;iBACvC;aACF;YAED,IAAI,MAAM,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,EAAE;gBACtC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;gBACtG,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;iBACvC;aACF;YAED,MAAM,MAAM,CAAC,0BAA0B,CAAC,aAAa,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC;YACpF,MAAM,YAAY,GAAI,MAAM,yCAAmB,CAAC,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;YACtH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF;AA1JD,kCA0JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { ECClass, ECClassModifier, Mixin, parseClassModifier, SchemaItemKey, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { BaseClassDelta, ChangeType, ClassChanges, EntityMixinChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\r\nimport { ClassPropertyMerger } from \"./ClassPropertyMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class ClassMerger<TClass extends ECClass> {\r\n protected readonly context: SchemaMergeContext;\r\n\r\n constructor(context: SchemaMergeContext) {\r\n this.context = context;\r\n }\r\n\r\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\r\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\r\n }\r\n\r\n protected async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\r\n return { errorMessage: `Adding mixin '${mixin.name}' to '${itemKey.name}' class is not implemented.` };\r\n }\r\n\r\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n const mutableClass = ecClass as unknown as MutableClass;\r\n switch(attributeName) {\r\n case \"schemaItemType\":\r\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\r\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\r\n }\r\n return true;\r\n\r\n case \"label\":\r\n mutableClass.setDisplayLabel(attributeNewValue);\r\n return true;\r\n\r\n case \"description\":\r\n mutableClass.setDescription(attributeNewValue);\r\n return true;\r\n\r\n case \"modifier\":\r\n const modifier = parseClassModifier(attributeNewValue);\r\n if (modifier === undefined) {\r\n return { errorMessage: \"An invalid class modifier has been provided.\" };\r\n }\r\n\r\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\r\n mutableClass.setModifier(modifier);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\r\n }\r\n return false;\r\n }\r\n\r\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\r\n return typeof obj === \"object\" && \"errorMessage\" in obj;\r\n }\r\n\r\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\r\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\r\n if (sourceBaseClass !== undefined) {\r\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : sourceBaseClass.schema.schemaKey);\r\n\r\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\r\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n }\r\n\r\n if (targetBaseClass !== undefined) {\r\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\r\n if (baseClass === undefined) {\r\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\r\n }\r\n if (await baseClass.is(targetBaseClass)) {\r\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\r\n }\r\n }\r\n }\r\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\r\n }\r\n\r\n private async addMixins(itemKey: SchemaItemKey, entityMixinChanges: Iterable<EntityMixinChanges>, changeType?: ChangeType): Promise<SchemaItemEditResults> {\r\n if (changeType === ChangeType.Missing) {\r\n for (const entityMixinChange of entityMixinChanges) {\r\n for (const change of entityMixinChange.entityMixinChange) {\r\n const mixins = change.diagnostic.messageArgs! as unknown as [Mixin];\r\n for (const mixin of mixins) {\r\n const result = await this.addMixin(itemKey, mixin);\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n }\r\n }\r\n return {};\r\n }\r\n return { errorMessage: `Changing the class '${itemKey.name}' mixins is not supported.`};\r\n }\r\n\r\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]) {\r\n if (propertyValueChanges.length === 0) {\r\n return;\r\n }\r\n\r\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\r\n if (targetItem === undefined) {\r\n throw new Error(`'${itemKey.name}' class could not be located in the merged schema.`);\r\n }\r\n\r\n for (const change of propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\r\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\r\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n }\r\n\r\n public static async mergeChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\r\n const merger = new this(context);\r\n\r\n for (const change of classChanges) {\r\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\r\n let targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\r\n const changeType = change.schemaItemMissing?.changeType;\r\n\r\n if (changeType === ChangeType.Missing) {\r\n\r\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\r\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\r\n }\r\n\r\n const results = await merger.create(context.targetSchema.schemaKey, sourceItem);\r\n if (results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n targetItemKey = results.itemKey!;\r\n }\r\n\r\n if (change.baseClassDelta !== undefined) {\r\n const results = await merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType);\r\n if (results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n\r\n if (change.entityMixinChanges.size > 0) {\r\n const results = await merger.addMixins(targetItemKey, change.entityMixinChanges.values(), changeType);\r\n if (results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n\r\n await merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges);\r\n const mergeResults = await ClassPropertyMerger.mergeChanges(context, targetItemKey, change.propertyChanges.values());\r\n if (mergeResults.errorMessage !== undefined) {\r\n throw new Error(mergeResults.errorMessage);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAiJ;AAIjJ,+DAAgI;AAChI,+DAA4D;AAC5D,mEAAgE;AAEhE;;GAEG;AACH,MAAa,WAAW;IAGtB,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,MAAM,CAAC,UAAqB,EAAE,OAAe;QAC3D,OAAO,EAAE,YAAY,EAAE,GAAG,IAAA,0CAAsB,EAAC,OAAO,CAAC,cAAc,CAAC,iCAAiC,EAAC,CAAC;IAC7G,CAAC;IAES,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,KAAK,CAAC,IAAI,SAAS,OAAO,CAAC,IAAI,6BAA6B,EAAE,CAAC;IACzG,CAAC;IAES,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACpH,MAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,QAAO,aAAa,EAAE;YACpB,KAAK,gBAAgB;gBACnB,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,EAAE;oBAC9E,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,0BAA0B,EAAE,CAAC;iBACxF;gBACD,OAAO,IAAI,CAAC;YAEd,KAAK,OAAO;gBACV,YAAY,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;YAEd,KAAK,aAAa;gBAChB,YAAY,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,OAAO,IAAI,CAAC;YAEd,KAAK,UAAU;gBACb,M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,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5C;YAED,0BAA0B;YAC1B,YAAY,GAAG,MAAM,IAAA,6CAAqB,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBAC9G,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF;AAnKD,kCAmKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ECClass, ECClassModifier, Mixin, parseClassModifier, SchemaItemKey, schemaItemTypeToString, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { BaseClassDelta, ChangeType, ClassChanges, EntityMixinChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { ClassPropertyMerger } from \"./ClassPropertyMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * @internal\n */\nexport class ClassMerger<TClass extends ECClass> {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n protected async create(_schemaKey: SchemaKey, ecClass: TClass): Promise<SchemaItemEditResults> {\n return { errorMessage: `${schemaItemTypeToString(ecClass.schemaItemType)} class type is not implemented.`};\n }\n\n protected async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\n return { errorMessage: `Adding mixin '${mixin.name}' to '${itemKey.name}' class is not implemented.` };\n }\n\n protected async mergeAttributes(ecClass: TClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const mutableClass = ecClass as unknown as MutableClass;\n switch(attributeName) {\n case \"schemaItemType\":\n if (attributeOldValue !== undefined && attributeOldValue !== attributeNewValue) {\n return { errorMessage: `Changing the class '${ecClass.name}' type is not supported.` };\n }\n return true;\n\n case \"label\":\n mutableClass.setDisplayLabel(attributeNewValue);\n return true;\n\n case \"description\":\n mutableClass.setDescription(attributeNewValue);\n return true;\n\n case \"modifier\":\n const modifier = parseClassModifier(attributeNewValue);\n if (modifier === undefined) {\n return { errorMessage: \"An invalid class modifier has been provided.\" };\n }\n\n if (attributeOldValue === undefined || modifier === ECClassModifier.None) {\n mutableClass.setModifier(modifier);\n return true;\n }\n return { errorMessage: `Changing the class '${ecClass.name}' modifier is not supported.` };\n }\n return false;\n }\n\n protected isSchemaItemEditResults(obj: any): obj is SchemaItemEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async setBaseClass(itemKey: SchemaItemKey, baseClassDelta: BaseClassDelta, changeType?: ChangeType): Promise<SchemaItemEditResults> {\n const [sourceBaseClass, targetBaseClass] = baseClassDelta.diagnostic.messageArgs! as [ECClass, ECClass];\n if (sourceBaseClass !== undefined) {\n const baseClassKey = new SchemaItemKey(sourceBaseClass.name, sourceBaseClass.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : sourceBaseClass.schema.schemaKey);\n\n if (changeType === ChangeType.Missing && targetBaseClass === undefined) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n }\n\n if (targetBaseClass !== undefined) {\n const baseClass = await this.context.targetSchema.lookupItem<ECClass>(baseClassKey);\n if (baseClass === undefined) {\n return { errorMessage: `'${baseClassKey.name}' class could not be located in the merged schema.`};\n }\n if (await baseClass.is(targetBaseClass)) {\n return this.context.editor.entities.setBaseClass(itemKey, baseClassKey);\n }\n }\n }\n return { errorMessage: `Changing the class '${itemKey.name}' baseClass is not supported.`};\n }\n\n private async addMixins(itemKey: SchemaItemKey, entityMixinChanges: Iterable<EntityMixinChanges>, changeType?: ChangeType): Promise<SchemaItemEditResults> {\n if (changeType === ChangeType.Missing) {\n for (const entityMixinChange of entityMixinChanges) {\n for (const change of entityMixinChange.entityMixinChange) {\n const mixins = change.diagnostic.messageArgs! as unknown as [Mixin];\n for (const mixin of mixins) {\n const result = await this.addMixin(itemKey, mixin);\n if (result.errorMessage !== undefined) {\n return result;\n }\n }\n }\n }\n return {};\n }\n return { errorMessage: `Changing the class '${itemKey.name}' mixins is not supported.`};\n }\n\n private async mergeAttributeValueChanges(itemKey: SchemaItemKey, propertyValueChanges: PropertyValueChange[]) {\n if (propertyValueChanges.length === 0) {\n return;\n }\n\n const targetItem = await this.context.targetSchema.lookupItem<TClass>(itemKey);\n if (targetItem === undefined) {\n throw new Error(`'${itemKey.name}' class could not be located in the merged schema.`);\n }\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await this.mergeAttributes(targetItem, attributeName, attributeNewValue, attributeOldValue);\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n }\n\n public static async mergeChanges(context: SchemaMergeContext, classChanges: Iterable<ClassChanges>) {\n const merger = new this(context);\n\n for (const change of classChanges) {\n const sourceItem = (await change.schema.getItem<ECClass>(change.ecTypeName))!;\n let targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n const changeType = change.schemaItemMissing?.changeType;\n\n if (changeType === ChangeType.Missing) {\n\n if (await context.targetSchema.lookupItem<ECClass>(targetItemKey) !== undefined) {\n throw new Error(`Merged schema already contains a class '${change.ecTypeName}'.`);\n }\n\n const results = await merger.create(context.targetSchema.schemaKey, sourceItem);\n if (results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n targetItemKey = results.itemKey!;\n }\n\n if (change.baseClassDelta !== undefined) {\n const results = await merger.setBaseClass(targetItemKey, change.baseClassDelta, changeType);\n if (results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n\n if (change.entityMixinChanges.size > 0) {\n const results = await merger.addMixins(targetItemKey, change.entityMixinChanges.values(), changeType);\n if (results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n\n await merger.mergeAttributeValueChanges(targetItemKey, change.propertyValueChanges);\n let mergeResults = await ClassPropertyMerger.mergeChanges(context, targetItemKey, change.propertyChanges.values());\n if (mergeResults.errorMessage !== undefined) {\n throw new Error(mergeResults.errorMessage);\n }\n\n // merge custom attributes\n mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttribute(targetItemKey, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n throw new Error(mergeResults.errorMessage);\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2C,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAc,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2C,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAc,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOpD;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEnC,OAAO,EAAE,kBAAkB;IAIvC,OAAO,CAAC,iBAAiB;IAsBzB,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB;YAIvD,0BAA0B;WAepB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAmCnK"}
|
|
@@ -10,6 +10,7 @@ const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
|
10
10
|
const StructPropertyMerger_1 = require("./StructPropertyMerger");
|
|
11
11
|
const ArrayPropertyMerger_1 = require("./ArrayPropertyMerger");
|
|
12
12
|
const PrimitiveOrEnumPropertyMerger_1 = require("./PrimitiveOrEnumPropertyMerger");
|
|
13
|
+
const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
|
|
13
14
|
/**
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
@@ -75,8 +76,14 @@ class ClassPropertyMerger {
|
|
|
75
76
|
const targetProperty = (await targetItem.getProperty(change.ecTypeName));
|
|
76
77
|
await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);
|
|
77
78
|
}
|
|
79
|
+
const mergeResults = await (0, CustomAttributeMerger_1.mergeCustomAttributes)(merger.context, change.customAttributeChanges.values(), async (ca) => {
|
|
80
|
+
return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);
|
|
81
|
+
});
|
|
82
|
+
if (mergeResults.errorMessage !== undefined) {
|
|
83
|
+
return { errorMessage: mergeResults.errorMessage };
|
|
84
|
+
}
|
|
78
85
|
}
|
|
79
|
-
return {};
|
|
86
|
+
return { itemKey: classKey };
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
89
|
exports.ClassPropertyMerger = ClassPropertyMerger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAkG;AAElG,+DAA+F;AAE/F,iEAA8D;AAC9D,+DAA+H;AAE/H,mFAAqG;
|
|
1
|
+
{"version":3,"file":"ClassPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAkG;AAElG,+DAA+F;AAE/F,iEAA8D;AAC9D,+DAA+H;AAE/H,mFAAqG;AACrG,mEAAgE;AAEhE;;GAEG;AACH,MAAa,mBAAmB;IAG9B,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEO,iBAAiB,CAAC,QAAkB;QAC1C,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE;YAC5B,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;gBACtB,OAAO,IAAI,oDAA8B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACzD;YACD,OAAO,IAAI,yDAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACpD;QACD,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;gBACtB,OAAO,IAAI,iDAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACtD;YACD,OAAO,IAAI,uDAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAClD;QACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE;YACvB,IAAI,QAAQ,CAAC,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AAE,CAAC,CAAC;YACtG,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,EAAC,CAAC;aACnD;SACF;QACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF;AAnFD,kDAmFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ECClass, Property, propertyTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { PropertyEditResults, SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ChangeType, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { StructPropertyMerger } from \"./StructPropertyMerger\";\nimport { EnumerationArrayPropertyMerger, PrimitiveArraPropertyMerger, StructArrayPropertyMerger } from \"./ArrayPropertyMerger\";\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\nimport { EnumerationPropertyMerger, PrimitivePropertyMerger } from \"./PrimitiveOrEnumPropertyMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * @internal\n */\nexport class ClassPropertyMerger {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n private getPropertyMerger(property: Property): AnyPropertyMerger<Property> {\n if (property.isEnumeration()) {\n if (property.isArray()) {\n return new EnumerationArrayPropertyMerger(this.context);\n }\n return new EnumerationPropertyMerger(this.context);\n }\n if (property.isPrimitive()) {\n if (property.isArray()) {\n return new PrimitiveArraPropertyMerger(this.context);\n }\n return new PrimitivePropertyMerger(this.context);\n }\n if (property.isStruct()) {\n if (property.isArray()) {\n return new StructArrayPropertyMerger(this.context);\n }\n return new StructPropertyMerger(this.context);\n }\n throw new Error(`Unsupported Property Type: ${propertyTypeToString(property.propertyType)}`);\n }\n\n protected isPropertyEditResults(obj: any): obj is PropertyEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async mergeAttributeValueChanges(targetProperty: Property, propertyValueChanges: PropertyValueChange[]) {\n if (propertyValueChanges.length === 0)\n return;\n\n const merger = this.getPropertyMerger(targetProperty);\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await merger.mergeAttributes(targetProperty, attributeName, attributeNewValue, attributeOldValue);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n }\n\n public static async mergeChanges(context: SchemaMergeContext, classKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\n const merger = new this(context);\n\n for (const change of propertyChanges) {\n const targetItem = await context.targetSchema.lookupItem<ECClass>(classKey);\n if (targetItem === undefined) {\n return { errorMessage: `'${classKey.name}' class could not be located in the merged schema.`};\n }\n\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\n return { errorMessage: `Merged schema already contains a class '${classKey.name}' property '${change.ecTypeName}'.`};\n }\n\n const propertyMerger = merger.getPropertyMerger(sourceProperty);\n const results = await propertyMerger.createFromProps(classKey, sourceProperty);\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage};\n }\n } else {\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\n await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);\n }\n\n const mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n return { errorMessage: mergeResults.errorMessage};\n }\n }\n return { itemKey: classKey };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","sourcesContent":["// /*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","sourcesContent":["// /*---------------------------------------------------------------------------------------------\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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Merging
|
|
3
|
+
*/
|
|
4
|
+
import { CustomAttribute } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { CustomAttributeContainerChanges } from "../Validation/SchemaChanges";
|
|
6
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
7
|
+
interface EditResults {
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
|
|
12
|
+
* a scope (Class, Property, Schema) specific handler.
|
|
13
|
+
* @param mergeContext The current schema merging context.
|
|
14
|
+
* @param changes An iterable with custom attribute changes.
|
|
15
|
+
* @param callback The callback to add the custom attribute with a scope specific editor.
|
|
16
|
+
* @returns A EditResults object.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=CustomAttributeMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAA8D,MAAM,0BAA0B,CAAC;AACvH,OAAO,EAAc,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,CAAC,+BAA+B,CAAC,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA6B5N"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Merging
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.mergeCustomAttributes = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
13
|
+
/**
|
|
14
|
+
* Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
|
|
15
|
+
* a scope (Class, Property, Schema) specific handler.
|
|
16
|
+
* @param mergeContext The current schema merging context.
|
|
17
|
+
* @param changes An iterable with custom attribute changes.
|
|
18
|
+
* @param callback The callback to add the custom attribute with a scope specific editor.
|
|
19
|
+
* @returns A EditResults object.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
async function mergeCustomAttributes(mergeContext, changes, callback) {
|
|
23
|
+
for (const customAttributeContainerChange of changes) {
|
|
24
|
+
for (const change of customAttributeContainerChange.customAttributeChanges) {
|
|
25
|
+
if (change.changeType === SchemaChanges_1.ChangeType.Missing) {
|
|
26
|
+
const [sourceCustomAttribute] = change.diagnostic.messageArgs;
|
|
27
|
+
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(sourceCustomAttribute.className);
|
|
28
|
+
const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)
|
|
29
|
+
? mergeContext.targetSchema.schemaKey
|
|
30
|
+
: new ecschema_metadata_1.SchemaKey(schemaName));
|
|
31
|
+
const targetCustomAttribute = await mergeContext.targetSchema.lookupItem(schemaItemKey);
|
|
32
|
+
if (targetCustomAttribute === undefined) {
|
|
33
|
+
return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.` };
|
|
34
|
+
}
|
|
35
|
+
const results = await callback({
|
|
36
|
+
...sourceCustomAttribute,
|
|
37
|
+
className: targetCustomAttribute.fullName,
|
|
38
|
+
});
|
|
39
|
+
if (results.errorMessage !== undefined) {
|
|
40
|
+
return { errorMessage: results.errorMessage };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.` };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
exports.mergeCustomAttributes = mergeCustomAttributes;
|
|
51
|
+
//# sourceMappingURL=CustomAttributeMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;;;;;GAQ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C,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QACpE,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;YAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE5B,+DAA+D;QAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAdD,oCAcC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QACpE,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;YAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE5B,+DAA+D;QAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAdD,oCAcC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { EntityClass, Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\n/**\n * @internal\n */\nexport default class EntityClassMerger extends ClassMerger<EntityClass> {\n protected override async create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults> {\n return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);\n }\n\n protected override async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\n const mixinKey = new SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : mixin.schema.schemaKey);\n\n // addMixin should return results instead of throwing exception\n await this.context.editor.entities.addMixin(itemKey, mixinKey);\n return {};\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4EAA4E;YAC5E,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAEzE,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC5B,MAAM,KAAK,CAAC,eAAe,gBAAgB,CAAC,UAAU,wBAAwB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAClG;gBAED,4EAA4E;gBAC5E,+DAA+D;gBAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAEtD,8EAA8E;gBAC9E,gFAAgF;gBAChF,SAAS;aACV;YAED,6EAA6E;YAC7E,4EAA4E;YAC5E,8EAA8E;YAC9E,KAAI,MAAM,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;gBAC9D,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,WAAmC,CAAC,CAAC;aAC5G;SACF;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,OAAsB,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAsB;QACjH,8EAA8E;QAC9E,oEAAoE;QACpE,IAAG,YAAY,KAAK,OAAO,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
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":["/*---------------------------------------------------------------------------------------------\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"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { KindOfQuantity, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { PropertyValueResolver, SchemaItemMerger } from "./SchemaItemMerger";
|
|
3
|
+
import { KindOfQuantityChanges } from "../Validation/SchemaChanges";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {
|
|
8
|
+
protected merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Creates the property value resolver for [[KindOfQuantity]] items.
|
|
12
|
+
*/
|
|
13
|
+
protected createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=KindOfQuantityMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,cAAc,EAA8B,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AACjI,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,gBAAgB,CAAC,cAAc,CAAC;cAEvD,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB;IAmC7G;;;OAGG;cACsB,2BAA2B,IAAI,OAAO,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;CAcvG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
class KindOfQuantityMerger extends SchemaItemMerger_1.SchemaItemMerger {
|
|
13
|
+
async merge(itemKey, source, changes) {
|
|
14
|
+
for (const presentationUnitChange of changes.presentationUnitChanges.values()) {
|
|
15
|
+
for (const change of presentationUnitChange.presentationUnitChange) {
|
|
16
|
+
const format = change.diagnostic.messageArgs[0];
|
|
17
|
+
const isDefault = source.defaultPresentationFormat === format;
|
|
18
|
+
if (ecschema_metadata_1.OverrideFormat.isOverrideFormat(format)) {
|
|
19
|
+
const parentFormat = await this.lookup(format.parent);
|
|
20
|
+
if (parentFormat === undefined) {
|
|
21
|
+
throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);
|
|
22
|
+
}
|
|
23
|
+
const unitAndLabels = [];
|
|
24
|
+
if (format.units !== undefined) {
|
|
25
|
+
for (const [unit, label] of format.units) {
|
|
26
|
+
const targetUnit = await this.lookup(unit);
|
|
27
|
+
if (targetUnit === undefined) {
|
|
28
|
+
throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);
|
|
29
|
+
}
|
|
30
|
+
unitAndLabels.push([targetUnit, label]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);
|
|
34
|
+
await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const targetFormat = await this.lookup(format);
|
|
38
|
+
if (targetFormat === undefined) {
|
|
39
|
+
throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);
|
|
40
|
+
}
|
|
41
|
+
await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* Creates the property value resolver for [[KindOfQuantity]] items.
|
|
49
|
+
*/
|
|
50
|
+
async createPropertyValueResolver() {
|
|
51
|
+
return {
|
|
52
|
+
persistenceUnit: (newValue, targetItemKey, oldValue) => {
|
|
53
|
+
if (oldValue !== undefined && oldValue !== newValue) {
|
|
54
|
+
throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);
|
|
55
|
+
}
|
|
56
|
+
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(newValue);
|
|
57
|
+
if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {
|
|
58
|
+
return `${targetItemKey.schemaName}.${itemName}`;
|
|
59
|
+
}
|
|
60
|
+
return newValue;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = KindOfQuantityMerger;
|
|
66
|
+
//# sourceMappingURL=KindOfQuantityMerger.js.map
|
|
@@ -0,0 +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;oBAC3C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC9D,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAClG;oBAED,MAAM,aAAa,GAAiE,EAAE,CAAC;oBACvF,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;wBAC9B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE;4BACxC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAsB,IAAI,CAAC,CAAC;4BAChE,IAAI,UAAU,KAAK,SAAS,EAAE;gCAC5B,MAAM,IAAI,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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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAc;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,YAAY,EAAE,aAAa,OAAO,CAAC,QAAQ,iDAAiD,EAAE,CAAC;SACzG;QAED,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,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,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC1G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACnG,OAAO,OAAO,CAAC;SAChB;QAED,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;IACf,CAAC;CACF;AA5BD,8BA4BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAc;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,YAAY,EAAE,aAAa,OAAO,CAAC,QAAQ,iDAAiD,EAAE,CAAC;SACzG;QAED,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,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,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC1G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACnG,OAAO,OAAO,CAAC;SAChB;QAED,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;IACf,CAAC;CACF;AA5BD,8BA4BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ClassMerger } from \"./ClassMerger\";\n\n/**\n * @internal\n */\nexport default class MixinMerger extends ClassMerger<Mixin> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\n if (ecClass.appliesTo === undefined) {\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\n }\n\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\n ? this.context.targetSchema.schemaKey\n : ecClass.appliesTo.schemaKey);\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\n }\n\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\n }\n return true;\n }\n return false;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimitiveOrEnumPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PrimitiveOrEnumPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA6L;AAC7L,2DAAwD;AAIxD;;GAEG;AACH,MAAe,6BAAgG,SAAQ,qCAA+C;IACpJ,KAAK,CAAC,eAAe,CAAC,QAAsC,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACjJ,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC3G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACjG,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,eAAe,GAAG,QAAyD,CAAC;QACl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I,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAC/B,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAc,OAAO,CAAC,CAAC;QAC9E,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,OAAO,EAAE,YAAY,EAAE,0CAA0C,WAAW,CAAC,IAAI,wBAAwB,EAAE,CAAC;SAC7G;QAED,MAAM,KAAK,GAA6B;YACtC,GAAG,QAAQ,CAAC,MAAM,EAAE;YACpB,GAAG,OAAO;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/G,CAAC;CACF;AA7CD,8DA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"PrimitiveOrEnumPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PrimitiveOrEnumPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA6L;AAC7L,2DAAwD;AAIxD;;GAEG;AACH,MAAe,6BAAgG,SAAQ,qCAA+C;IACpJ,KAAK,CAAC,eAAe,CAAC,QAAsC,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACjJ,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC3G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACjG,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,eAAe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;YAC3H,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAC/B,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAc,OAAO,CAAC,CAAC;QAC9E,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,OAAO,EAAE,YAAY,EAAE,0CAA0C,WAAW,CAAC,IAAI,wBAAwB,EAAE,CAAC;SAC7G;QAED,MAAM,KAAK,GAA6B;YACtC,GAAG,QAAQ,CAAC,MAAM,EAAE;YACpB,GAAG,OAAO;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/G,CAAC;CACF;AA7CD,8DA6CC","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 { Enumeration, EnumerationProperty, EnumerationPropertyProps, PrimitiveOrEnumPropertyBase, PrimitiveProperty, PrimitivePropertyProps, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\nimport { PropertyEditResults } from \"../Editing/Editor\";\nimport { MutablePrimitiveOrEnumPropertyBase } from \"../Editing/Mutable/MutablePrimitiveOrEnumProperty\";\n\n/**\n * @internal\n */\nabstract class PrimitiveOrEnumPropertyMerger<TPrimitiveOrEnumPropertyBase extends PrimitiveOrEnumPropertyBase> extends AnyPropertyMerger<TPrimitiveOrEnumPropertyBase> {\n public override async mergeAttributes(property: TPrimitiveOrEnumPropertyBase, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const mutableProperty = property as unknown as MutablePrimitiveOrEnumPropertyBase;\n switch (attributeName) {\n case \"extendedTypeName\": {\n mutableProperty.setExtendedTypeName(attributeNewValue);\n return true;\n }\n case \"minLength\": {\n mutableProperty.setMinLength(attributeNewValue);\n return true;\n }\n case \"maxLength\": {\n mutableProperty.setMaxLength(attributeNewValue);\n return true;\n }\n case \"minValue\": {\n mutableProperty.setMinValue(attributeNewValue);\n return true;\n }\n case \"maxValue\": {\n mutableProperty.setMaxValue(attributeNewValue);\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * @internal\n */\nexport class PrimitivePropertyMerger extends PrimitiveOrEnumPropertyMerger<PrimitiveProperty> {\n public override async createFromProps(classKey: SchemaItemKey, property: PrimitiveProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const props: PrimitivePropertyProps = {\n ...property.toJSON(),\n ...results,\n };\n return this.context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, props);\n }\n}\n\n/**\n * @internal\n */\nexport class EnumerationPropertyMerger extends PrimitiveOrEnumPropertyMerger<EnumerationProperty> {\n public override async mergeAttributes(property: EnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch (attributeName) {\n case \"enumeration\": {\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };\n }\n return true;\n }\n }\n return false;\n }\n\n public override async createFromProps(classKey: SchemaItemKey, property: EnumerationProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n if (property.enumeration === undefined) {\n return { errorMessage: `Property ${property.fullName} is missing the required 'enumeration' attribute.` };\n }\n\n const enumeration = await property.enumeration;\n const itemKey = new SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : enumeration.schema.schemaKey,\n );\n const type = await this.context.targetSchema.lookupItem<Enumeration>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };\n }\n\n const props: EnumerationPropertyProps = {\n ...property.toJSON(),\n ...results,\n typeName: type.fullName,\n };\n return this.context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, props);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemFactory.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaItemFactory.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyH,UAAU,EAAE,aAAa,EAAsC,MAAM,0BAA0B,CAAC;AAEhO,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;GAEG;AACH,yBAAiB,iBAAiB,CAAC;IAEjC;;;;;OAKG;IACH,SAAsB,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAMtG;CA0DF"}
|
|
@@ -55,6 +55,16 @@ var SchemaItemFactory;
|
|
|
55
55
|
: phenomenon.key;
|
|
56
56
|
return editor.constants.create(targetSchemaKey, template.name, itemKey, template.definition);
|
|
57
57
|
}
|
|
58
|
+
if (is(template, ecschema_metadata_1.KindOfQuantity)) {
|
|
59
|
+
if (template.persistenceUnit === undefined) {
|
|
60
|
+
throw new Error(`Invalid KindOfQuantity ${template.name} has no persistenceUnit defined`);
|
|
61
|
+
}
|
|
62
|
+
const persistenceUnit = await template.persistenceUnit;
|
|
63
|
+
const itemKey = persistenceUnit.key.schemaKey.matches(template.key.schemaKey)
|
|
64
|
+
? new ecschema_metadata_1.SchemaItemKey(persistenceUnit.name, targetSchemaKey)
|
|
65
|
+
: persistenceUnit.key;
|
|
66
|
+
return editor.kindOfQuantities.create(targetSchemaKey, template.name, itemKey);
|
|
67
|
+
}
|
|
58
68
|
if (is(template, ecschema_metadata_1.UnitSystem))
|
|
59
69
|
return editor.unitSystems.create(targetSchemaKey, template.name);
|
|
60
70
|
throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemFactory.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,
|
|
1
|
+
{"version":3,"file":"SchemaItemFactory.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAgO;AAIhO;;GAEG;AACH,IAAiB,iBAAiB,CAwEjC;AAxED,WAAiB,iBAAiB;IAEhC;;;;;OAKG;IACI,KAAK,UAAU,MAAM,CAAC,OAA2B,EAAE,QAAoB;QAC5E,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC1F,IAAG,MAAM,CAAC,YAAY,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SACtC;QACD,OAAO,MAAM,CAAC,OAAQ,CAAC;IACzB,CAAC;IANqB,wBAAM,SAM3B,CAAA;IAED;;;;;;OAMG;IACH,KAAK,UAAU,UAAU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eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEnE,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;OAKG;IACH,SAAS,EAAE,CAAuB,IAAgB,EAAE,IAA6B;QAC/E,OAAO,IAAI,YAAY,IAAI,CAAC;IAC9B,CAAC;AACH,CAAC,EAxEgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAwEjC","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, CustomAttributeClass, EntityClass, Enumeration, KindOfQuantity, Phenomenon, PrimitiveType, PropertyCategory, SchemaItem, SchemaItemKey, SchemaKey, StructClass, UnitSystem } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"../Editing/Editor\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\n/**\n * @internal\n */\nexport namespace SchemaItemFactory {\n\n /**\n * Creates a new Schema Item based on the given template instance.\n * @param context The current merging context.\n * @param template The Schema Items Template\n * @returns The SchemaItemKey of the created item.\n */\n export async function create(context: SchemaMergeContext, template: SchemaItem): Promise<SchemaItemKey> {\n const result = await createItem(context.editor, context.targetSchema.schemaKey, template);\n if(result.errorMessage) {\n throw new Error(result.errorMessage);\n }\n return result.itemKey!;\n }\n\n /**\n * Creates a new Schema Item in the SchemaContextEditor.\n * @param editor The SchemaContextEditor\n * @param targetSchemaKey The key of the target schema the item shall be created in.\n * @param template The Schema Items Template\n * @returns A SchemaItemEditResults with a schema key if the item could be created.\n */\n async function createItem(editor: SchemaContextEditor, targetSchemaKey: SchemaKey, template: SchemaItem): Promise<SchemaItemEditResults> {\n if (is(template, Enumeration))\n return editor.enumerations.create(targetSchemaKey, template.name, template.isInt ? PrimitiveType.Integer : PrimitiveType.String, template.label, template.isStrict);\n if (is(template, EntityClass))\n return editor.entities.create(targetSchemaKey, template.name, template.modifier);\n if (is(template, StructClass))\n return editor.structs.create(targetSchemaKey, template.name);\n if (is(template, CustomAttributeClass))\n return editor.customAttributes.create(targetSchemaKey, template.name, template.containerType);\n if(is(template, PropertyCategory))\n return editor.propertyCategories.create(targetSchemaKey, template.name, template.priority);\n if (is(template, Phenomenon))\n return editor.phenomenons.create(targetSchemaKey, template.name, template.definition);\n if (is(template, Constant)) {\n if(template.phenomenon === undefined) {\n throw new Error(`Invalid Constant ${template.name} has no phenomenon defined`);\n }\n const phenomenon = await template.phenomenon;\n const itemKey = phenomenon.key.schemaKey.matches(template.key.schemaKey)\n ? new SchemaItemKey(phenomenon.name, targetSchemaKey)\n : phenomenon.key;\n\n return editor.constants.create(targetSchemaKey, template.name, itemKey, template.definition);\n }\n if (is(template, KindOfQuantity)) {\n if(template.persistenceUnit === undefined) {\n throw new Error(`Invalid KindOfQuantity ${template.name} has no persistenceUnit defined`);\n }\n const persistenceUnit = await template.persistenceUnit;\n const itemKey = persistenceUnit.key.schemaKey.matches(template.key.schemaKey)\n ? new SchemaItemKey(persistenceUnit.name, targetSchemaKey)\n : persistenceUnit.key;\n return editor.kindOfQuantities.create(targetSchemaKey, template.name, itemKey);\n }\n if (is(template, UnitSystem))\n return editor.unitSystems.create(targetSchemaKey, template.name);\n\n throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);\n }\n\n /**\n * Type Guard to \"cast\" a given schema item into an implementation\n * @param item Item to be checked\n * @param type The desired implementation.\n * @returns true if the item could be casted, otherwise false.\n */\n function is<T extends SchemaItem>(item: SchemaItem, type: new (...args: any) => T ): item is T {\n return item instanceof type;\n }\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { SchemaMergeContext } from "./SchemaMerger";
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
export type PropertyValueResolver<T extends SchemaItem, TProps = MutableSchemaItemProps<T>> = {
|
|
9
|
-
[P in keyof TProps]?: (
|
|
9
|
+
[P in keyof TProps]?: (newValue: any, item: SchemaItemKey, oldValue?: any) => any;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* Defines a Mutable Schema Props interface.
|
|
@@ -43,6 +43,7 @@ export declare class SchemaItemMerger<TItem extends SchemaItem> {
|
|
|
43
43
|
* @param _change The schema item change to be applied.
|
|
44
44
|
*/
|
|
45
45
|
protected merge(_itemKey: SchemaItemKey, _source: TItem, _change: SchemaItemChanges): Promise<void>;
|
|
46
|
+
protected lookup<T extends SchemaItem>(schemaItem: T): Promise<T | undefined>;
|
|
46
47
|
/**
|
|
47
48
|
* Merges the given schema item changes in the current context.
|
|
48
49
|
* @param context The merging context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAmC,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,UAAU,EAAE,MAAM,GAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI;KACzF,CAAC,IAAI,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAmC,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,qB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|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(schemaItem.name, this.context.sourceSchema.schemaKey.matches(schemaItem.schema.schemaKey)
|
|
48
|
+
? this.context.targetSchema.schemaKey
|
|
49
|
+
: schemaItem.schema.schemaKey);
|
|
50
|
+
return this.context.targetSchema.lookupItem(itemKey);
|
|
51
|
+
}
|
|
46
52
|
/**
|
|
47
53
|
* Merges the given schema item changes in the current context.
|
|
48
54
|
* @param context The merging context
|
|
@@ -79,14 +85,15 @@ class SchemaItemMerger {
|
|
|
79
85
|
if (changes.length === 0) {
|
|
80
86
|
return;
|
|
81
87
|
}
|
|
82
|
-
const
|
|
88
|
+
const targetItem = (await this.context.targetSchema.lookupItem(targetItemKey));
|
|
89
|
+
const jsonProps = (targetItem?.toJSON() ?? {});
|
|
83
90
|
const propertyResolver = await this.createPropertyValueResolver();
|
|
84
91
|
for (const change of changes) {
|
|
85
|
-
const [propertyName,
|
|
92
|
+
const [propertyName, propertyNewValue, propertyOldValue] = change.diagnostic.messageArgs;
|
|
86
93
|
const resolver = propertyResolver[propertyName];
|
|
87
94
|
jsonProps[propertyName] = resolver !== undefined
|
|
88
|
-
? resolver(
|
|
89
|
-
:
|
|
95
|
+
? resolver(propertyNewValue, targetItemKey, propertyOldValue)
|
|
96
|
+
: propertyNewValue;
|
|
90
97
|
}
|
|
91
98
|
await this.context.editor.schemaItems.applyProps(targetItemKey, jsonProps);
|
|
92
99
|
}
|