@itwin/ecschema-editing 4.6.0-dev.5 → 4.6.0-dev.6
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 +18 -1
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- 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.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.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.js.map +1 -1
- 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.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.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA8V;AAQ9V,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,QAAkB,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;IAC3J,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE;QAC5B,OAAO,kBAAkB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACnH;IACD,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE;QAC1B,OAAO,uBAAuB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACxH;IACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE;QACvB,OAAO,oBAAoB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACrH;IACD,IAAI,QAAQ,CAAC,YAAY,EAAE,EAAE;QAC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AQ,CAAC,QAAQ,wCAAwC,EAAE,CAAC;aAC9G;SACF;QACD,OAAO,cAAc,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAChH,CAAC;IAVqB,wCAAe,kBAUpC,CAAA;AACH,CAAC,EArCS,wBAAwB,KAAxB,wBAAwB,QAqCjC","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 { AnyArrayProperty, AnyEnumerationProperty, AnyPrimitiveProperty, AnyStructProperty, Enumeration, KindOfQuantity, NavigationProperty, Property, PropertyCategory, PropertyProps, propertyTypeToString, RelationshipClass, SchemaItem, SchemaItemKey, SchemaItemType, schemaItemTypeToString, SchemaKey, StructClass } from \"@itwin/ecschema-metadata\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { PropertyEditResults } from \"../Editing/Editor\";\nimport { MutableProperty } from \"../Editing/Mutable/MutableProperty\";\nimport { MutableArrayProperty } from \"../Editing/Mutable/MutableArrayProperty\";\nimport { MutablePrimitiveOrEnumPropertyBase } from \"../Editing/Mutable/MutablePrimitiveOrEnumProperty\";\nimport { PropertyValueChange } from \"../Validation/SchemaChanges\";\n\nasync function mergePropertyAttributes(context: SchemaMergeContext, property: Property, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n if (property.isEnumeration()) {\n return EnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n if (property.isPrimitive()) {\n return PrimitivePropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n if (property.isStruct()) {\n return StructPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n if (property.isNavigation()) {\n return NavigationPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n return false;\n}\n\n/**\n * Updates property with attribute value changes.\n * @param context The current merging context.\n * @param property The Property object to be changed.\n * @param propertyValueChanges The changes to be applied to the property.\n * @internal\n */\nexport async function mergePropertyAttributeValueChanges(context: SchemaMergeContext, property: Property, propertyValueChanges: PropertyValueChange[]): Promise<PropertyEditResults> {\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await mergePropertyAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n if (!results) {\n return { errorMessage: `Property ${property.fullName} attribute ${attributeName} change is not implemented.` };\n }\n if (typeof results === \"object\" && \"errorMessage\" in results && results.errorMessage !== undefined) {\n return results;\n }\n }\n return { itemKey: property.class.key, propertyName: property.name };\n}\n\n/**\n * Creates a Property through a PropertyProps.\n * @param context The current merging context.\n * @param classKey The SchemaItemKey of the class.\n * @param property The Property object to be cloned.\n * @internal\n */\nexport async function createPropertyFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: Property): Promise<PropertyEditResults> {\n let props = {} as PropertyProps;\n\n if (property.category !== undefined) {\n const sourceCategory = await property.category;\n const itemKey = new SchemaItemKey(sourceCategory.name, context.sourceSchema.schemaKey.matches(sourceCategory.schema.schemaKey)\n ? context.targetSchema.schemaKey\n : sourceCategory.schema.schemaKey,\n );\n const targetCategory = await context.targetSchema.lookupItem<PropertyCategory>(itemKey);\n if (targetCategory === undefined) {\n return { errorMessage: `Unable to locate the property category class ${sourceCategory.name} in the context schema.` };\n }\n props = {...props, category: targetCategory.fullName};\n }\n\n if (property.kindOfQuantity !== undefined) {\n const sourceKoq = await property.kindOfQuantity;\n const itemKey = new SchemaItemKey(sourceKoq.name, context.sourceSchema.schemaKey.matches(sourceKoq.schema.schemaKey)\n ? context.targetSchema.schemaKey\n : sourceKoq.schema.schemaKey,\n );\n const targetKoq = await context.targetSchema.lookupItem<KindOfQuantity>(itemKey);\n if (targetKoq === undefined) {\n return { errorMessage: `Unable to locate the property kind of quantity class ${sourceKoq.name} in the context schema.` };\n }\n props = {...props, kindOfQuantity: targetKoq.fullName};\n }\n if (property.isEnumeration())\n return EnumPropertyMerger.createFromProps(context, classKey, property, props);\n if (property.isPrimitive())\n return PrimitivePropertyMerger.createFromProps(context, classKey, property, props);\n if (property.isStruct())\n return StructPropertyMerger.createFromProps(context, classKey, property, props);\n if (property.isNavigation())\n return NavigationPropertyMerger.createFromProps(context, classKey, property, props);\n\n return { errorMessage: `Unsupported Property Type: ${propertyTypeToString(property.propertyType)}` };\n}\n\n/**\n * @internal\n */\nnamespace PropertyMerger {\n export async function mergeAttributes(context: SchemaMergeContext, property: Property, attributeName: string, attributeNewValue: any, _attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const mutableProperty = property as unknown as MutableProperty;\n switch(attributeName) {\n case \"type\":\n return { errorMessage: `Changing the property '${property.fullName}' type is not supported.` };\n case \"description\":\n mutableProperty.setDescription(attributeNewValue);\n return true;\n case \"label\":\n mutableProperty.setLabel(attributeNewValue);\n return true;\n case \"isReadOnly\":\n mutableProperty.setIsReadOnly(attributeNewValue);\n return true;\n case \"priority\":\n mutableProperty.setPriority(attributeNewValue);\n return true;\n case \"category\":\n const [schemaName, itemName] = SchemaItem.parseFullName(attributeNewValue);\n const itemKey = new SchemaItemKey(itemName, context.sourceSchema.schemaKey.compareByName(schemaName)\n ? context.targetSchema.schemaKey\n : new SchemaKey(schemaName),\n );\n return context.editor.entities.setPropertyCategory(property.class.key, property.name, itemKey);\n case \"kindOfQuantity\":\n return { errorMessage: `Changing the property '${property.fullName}' kind of quantity is not supported.` };\n }\n return false;\n }\n}\n\n/**\n * @internal\n */\nnamespace ArrayPropertyMerger {\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const mutableProperty = property as unknown as MutableArrayProperty;\n switch (attributeName) {\n case \"minOccurs\":\n mutableProperty.setMinOccurs(attributeNewValue);\n return true;\n\n case \"maxOccurs\":\n mutableProperty.setMaxOccurs(attributeNewValue);\n return true;\n }\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n\n/**\n * @internal\n */\nnamespace PrimitiveOrEnumPropertyMerger {\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyPrimitiveProperty | AnyEnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\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 if (property.isArray()) {\n return ArrayPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n\n/**\n * @internal\n */\nnamespace EnumPropertyMerger {\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: AnyEnumerationProperty, props: PropertyProps): Promise<PropertyEditResults> {\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, context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\n ? context.targetSchema.schemaKey\n : enumeration.schema.schemaKey,\n );\n const type = await context.targetSchema.lookupItem<Enumeration>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the context schema.` };\n }\n\n const enumProps = {\n ...property.toJSON(),\n ...props,\n typeName: type.fullName,\n };\n\n if (property.isArray()) {\n return context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, enumProps);\n }\n return context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, enumProps);\n }\n\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyEnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n switch (attributeName) {\n case \"enumeration\":\n return { errorMessage: `Changing the property '${property.fullName}' enumeration is not supported.` };\n }\n return PrimitiveOrEnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n\n/**\n * @internal\n */\nnamespace PrimitivePropertyMerger {\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: AnyPrimitiveProperty, props: PropertyProps): Promise<PropertyEditResults> {\n const primitiveProps = {\n ...property.toJSON(),\n ...props,\n };\n\n if (property.isArray()) {\n return context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, primitiveProps);\n }\n return context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, primitiveProps);\n }\n\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyPrimitiveProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n switch (attributeName) {\n case \"primitiveType\":\n return { errorMessage: `Changing the property '${property.fullName}' primitiveType is not supported.` };\n }\n return PrimitiveOrEnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n\n/**\n * @internal\n */\nnamespace StructPropertyMerger {\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: AnyStructProperty, props: PropertyProps): Promise<PropertyEditResults> {\n const itemKey = new SchemaItemKey(property.structClass.name, context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)\n ? context.targetSchema.schemaKey\n : property.structClass.schema.schemaKey,\n );\n const type = await context.targetSchema.lookupItem<StructClass>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the context schema.` };\n }\n\n const structProps = {\n ...property.toJSON(),\n ...props,\n typeName: type.fullName,\n };\n\n if (property.isArray()) {\n return context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, structProps);\n }\n return context.editor.entities.createStructPropertyFromProps(classKey, property.name, type, structProps);\n }\n\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyStructProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n switch (attributeName) {\n case \"structClass\":\n return { errorMessage: `Changing the property '${property.fullName}' structClass is not supported.` };\n }\n if (property.isArray()) {\n return ArrayPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n\n/**\n * @internal\n */\nnamespace NavigationPropertyMerger {\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: NavigationProperty, props: PropertyProps): Promise<PropertyEditResults> {\n const itemKey = new SchemaItemKey(property.relationshipClass.name, context.sourceSchema.schemaKey.matches(property.relationshipClass.schemaKey)\n ? context.targetSchema.schemaKey\n : property.relationshipClass.schemaKey,\n );\n const type = await context.targetSchema.lookupItem<RelationshipClass>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the relationship class ${property.relationshipClass.name} in the context schema.` };\n }\n\n const navigationProps = {\n ...property.toJSON(),\n ...props,\n relationshipName: type.fullName,\n };\n\n if (property.class.schemaItemType === SchemaItemType.EntityClass)\n return context.editor.entities.createNavigationPropertyFromProps(classKey, navigationProps);\n if (property.class.schemaItemType === SchemaItemType.Mixin)\n return context.editor.mixins.createNavigationPropertyFromProps(classKey, navigationProps);\n if (property.class.schemaItemType === SchemaItemType.RelationshipClass)\n return context.editor.relationships.createNavigationPropertyFromProps(classKey, navigationProps);\n return { errorMessage: `Navigation property can't be added to ${schemaItemTypeToString(property.class.schemaItemType)}.` };\n }\n\n export async function mergeAttributes(context: SchemaMergeContext, property: NavigationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n switch (attributeName) {\n case \"direction\": {\n return { errorMessage: `Changing the property '${property.fullName}' direction is not supported.` };\n }\n case \"relationshipClass\": {\n return { errorMessage: `Changing the property '${property.fullName}' relationship class is not supported.` };\n }\n }\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA8V;AAQ9V,KAAK,UAAU,uBAAuB,CAAC,OAA2B,EAAE,QAAkB,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;IAC3J,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE;QAC5B,OAAO,kBAAkB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACnH;IACD,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE;QAC1B,OAAO,uBAAuB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACxH;IACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE;QACvB,OAAO,oBAAoB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACrH;IACD,IAAI,QAAQ,CAAC,YAAY,EAAE,EAAE;QAC3B,OAAO,wBAAwB,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KACzH;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;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C;IAChH,CAAC;IAVqB,wCAAe,kBAUpC,CAAA;AACH,CAAC,EArCS,wBAAwB,KAAxB,wBAAwB,QAqCjC","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 { AnyArrayProperty, AnyEnumerationProperty, AnyPrimitiveProperty, AnyStructProperty, Enumeration, KindOfQuantity, NavigationProperty, Property, PropertyCategory, PropertyProps, propertyTypeToString, RelationshipClass, SchemaItem, SchemaItemKey, SchemaItemType, schemaItemTypeToString, SchemaKey, StructClass } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { PropertyEditResults } from \"../Editing/Editor\";\r\nimport { MutableProperty } from \"../Editing/Mutable/MutableProperty\";\r\nimport { MutableArrayProperty } from \"../Editing/Mutable/MutableArrayProperty\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"../Editing/Mutable/MutablePrimitiveOrEnumProperty\";\r\nimport { PropertyValueChange } from \"../Validation/SchemaChanges\";\r\n\r\nasync function mergePropertyAttributes(context: SchemaMergeContext, property: Property, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n if (property.isEnumeration()) {\r\n return EnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n if (property.isPrimitive()) {\r\n return PrimitivePropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n if (property.isStruct()) {\r\n return StructPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n if (property.isNavigation()) {\r\n return NavigationPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n return false;\r\n}\r\n\r\n/**\r\n * Updates property with attribute value changes.\r\n * @param context The current merging context.\r\n * @param property The Property object to be changed.\r\n * @param propertyValueChanges The changes to be applied to the property.\r\n * @internal\r\n */\r\nexport async function mergePropertyAttributeValueChanges(context: SchemaMergeContext, property: Property, propertyValueChanges: PropertyValueChange[]): Promise<PropertyEditResults> {\r\n for (const change of propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\r\n const results = await mergePropertyAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n if (!results) {\r\n return { errorMessage: `Property ${property.fullName} attribute ${attributeName} change is not implemented.` };\r\n }\r\n if (typeof results === \"object\" && \"errorMessage\" in results && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n return { itemKey: property.class.key, propertyName: property.name };\r\n}\r\n\r\n/**\r\n * Creates a Property through a PropertyProps.\r\n * @param context The current merging context.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param property The Property object to be cloned.\r\n * @internal\r\n */\r\nexport async function createPropertyFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: Property): Promise<PropertyEditResults> {\r\n let props = {} as PropertyProps;\r\n\r\n if (property.category !== undefined) {\r\n const sourceCategory = await property.category;\r\n const itemKey = new SchemaItemKey(sourceCategory.name, context.sourceSchema.schemaKey.matches(sourceCategory.schema.schemaKey)\r\n ? context.targetSchema.schemaKey\r\n : sourceCategory.schema.schemaKey,\r\n );\r\n const targetCategory = await context.targetSchema.lookupItem<PropertyCategory>(itemKey);\r\n if (targetCategory === undefined) {\r\n return { errorMessage: `Unable to locate the property category class ${sourceCategory.name} in the context schema.` };\r\n }\r\n props = {...props, category: targetCategory.fullName};\r\n }\r\n\r\n if (property.kindOfQuantity !== undefined) {\r\n const sourceKoq = await property.kindOfQuantity;\r\n const itemKey = new SchemaItemKey(sourceKoq.name, context.sourceSchema.schemaKey.matches(sourceKoq.schema.schemaKey)\r\n ? context.targetSchema.schemaKey\r\n : sourceKoq.schema.schemaKey,\r\n );\r\n const targetKoq = await context.targetSchema.lookupItem<KindOfQuantity>(itemKey);\r\n if (targetKoq === undefined) {\r\n return { errorMessage: `Unable to locate the property kind of quantity class ${sourceKoq.name} in the context schema.` };\r\n }\r\n props = {...props, kindOfQuantity: targetKoq.fullName};\r\n }\r\n if (property.isEnumeration())\r\n return EnumPropertyMerger.createFromProps(context, classKey, property, props);\r\n if (property.isPrimitive())\r\n return PrimitivePropertyMerger.createFromProps(context, classKey, property, props);\r\n if (property.isStruct())\r\n return StructPropertyMerger.createFromProps(context, classKey, property, props);\r\n if (property.isNavigation())\r\n return NavigationPropertyMerger.createFromProps(context, classKey, property, props);\r\n\r\n return { errorMessage: `Unsupported Property Type: ${propertyTypeToString(property.propertyType)}` };\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace PropertyMerger {\r\n export async function mergeAttributes(context: SchemaMergeContext, property: Property, attributeName: string, attributeNewValue: any, _attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const mutableProperty = property as unknown as MutableProperty;\r\n switch(attributeName) {\r\n case \"type\":\r\n return { errorMessage: `Changing the property '${property.fullName}' type is not supported.` };\r\n case \"description\":\r\n mutableProperty.setDescription(attributeNewValue);\r\n return true;\r\n case \"label\":\r\n mutableProperty.setLabel(attributeNewValue);\r\n return true;\r\n case \"isReadOnly\":\r\n mutableProperty.setIsReadOnly(attributeNewValue);\r\n return true;\r\n case \"priority\":\r\n mutableProperty.setPriority(attributeNewValue);\r\n return true;\r\n case \"category\":\r\n const [schemaName, itemName] = SchemaItem.parseFullName(attributeNewValue);\r\n const itemKey = new SchemaItemKey(itemName, context.sourceSchema.schemaKey.compareByName(schemaName)\r\n ? context.targetSchema.schemaKey\r\n : new SchemaKey(schemaName),\r\n );\r\n return context.editor.entities.setPropertyCategory(property.class.key, property.name, itemKey);\r\n case \"kindOfQuantity\":\r\n return { errorMessage: `Changing the property '${property.fullName}' kind of quantity is not supported.` };\r\n }\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace ArrayPropertyMerger {\r\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const mutableProperty = property as unknown as MutableArrayProperty;\r\n switch (attributeName) {\r\n case \"minOccurs\":\r\n mutableProperty.setMinOccurs(attributeNewValue);\r\n return true;\r\n\r\n case \"maxOccurs\":\r\n mutableProperty.setMaxOccurs(attributeNewValue);\r\n return true;\r\n }\r\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace PrimitiveOrEnumPropertyMerger {\r\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyPrimitiveProperty | AnyEnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const mutableProperty = property as unknown as MutablePrimitiveOrEnumPropertyBase;\r\n switch (attributeName) {\r\n case \"extendedTypeName\": {\r\n mutableProperty.setExtendedTypeName(attributeNewValue);\r\n return true;\r\n }\r\n case \"minLength\": {\r\n mutableProperty.setMinLength(attributeNewValue);\r\n return true;\r\n }\r\n case \"maxLength\": {\r\n mutableProperty.setMaxLength(attributeNewValue);\r\n return true;\r\n }\r\n case \"minValue\": {\r\n mutableProperty.setMinValue(attributeNewValue);\r\n return true;\r\n }\r\n case \"maxValue\": {\r\n mutableProperty.setMaxValue(attributeNewValue);\r\n return true;\r\n }\r\n }\r\n if (property.isArray()) {\r\n return ArrayPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace EnumPropertyMerger {\r\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: AnyEnumerationProperty, props: PropertyProps): Promise<PropertyEditResults> {\r\n if (property.enumeration === undefined) {\r\n return { errorMessage: `Property ${property.fullName} is missing the required 'enumeration' attribute.` };\r\n }\r\n\r\n const enumeration = await property.enumeration;\r\n const itemKey = new SchemaItemKey(enumeration.name, context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\r\n ? context.targetSchema.schemaKey\r\n : enumeration.schema.schemaKey,\r\n );\r\n const type = await context.targetSchema.lookupItem<Enumeration>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the context schema.` };\r\n }\r\n\r\n const enumProps = {\r\n ...property.toJSON(),\r\n ...props,\r\n typeName: type.fullName,\r\n };\r\n\r\n if (property.isArray()) {\r\n return context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, enumProps);\r\n }\r\n return context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, enumProps);\r\n }\r\n\r\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyEnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n switch (attributeName) {\r\n case \"enumeration\":\r\n return { errorMessage: `Changing the property '${property.fullName}' enumeration is not supported.` };\r\n }\r\n return PrimitiveOrEnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace PrimitivePropertyMerger {\r\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: AnyPrimitiveProperty, props: PropertyProps): Promise<PropertyEditResults> {\r\n const primitiveProps = {\r\n ...property.toJSON(),\r\n ...props,\r\n };\r\n\r\n if (property.isArray()) {\r\n return context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, primitiveProps);\r\n }\r\n return context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, primitiveProps);\r\n }\r\n\r\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyPrimitiveProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n switch (attributeName) {\r\n case \"primitiveType\":\r\n return { errorMessage: `Changing the property '${property.fullName}' primitiveType is not supported.` };\r\n }\r\n return PrimitiveOrEnumPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace StructPropertyMerger {\r\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: AnyStructProperty, props: PropertyProps): Promise<PropertyEditResults> {\r\n const itemKey = new SchemaItemKey(property.structClass.name, context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)\r\n ? context.targetSchema.schemaKey\r\n : property.structClass.schema.schemaKey,\r\n );\r\n const type = await context.targetSchema.lookupItem<StructClass>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the context schema.` };\r\n }\r\n\r\n const structProps = {\r\n ...property.toJSON(),\r\n ...props,\r\n typeName: type.fullName,\r\n };\r\n\r\n if (property.isArray()) {\r\n return context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, structProps);\r\n }\r\n return context.editor.entities.createStructPropertyFromProps(classKey, property.name, type, structProps);\r\n }\r\n\r\n export async function mergeAttributes(context: SchemaMergeContext, property: AnyStructProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n switch (attributeName) {\r\n case \"structClass\":\r\n return { errorMessage: `Changing the property '${property.fullName}' structClass is not supported.` };\r\n }\r\n if (property.isArray()) {\r\n return ArrayPropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nnamespace NavigationPropertyMerger {\r\n export async function createFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: NavigationProperty, props: PropertyProps): Promise<PropertyEditResults> {\r\n const itemKey = new SchemaItemKey(property.relationshipClass.name, context.sourceSchema.schemaKey.matches(property.relationshipClass.schemaKey)\r\n ? context.targetSchema.schemaKey\r\n : property.relationshipClass.schemaKey,\r\n );\r\n const type = await context.targetSchema.lookupItem<RelationshipClass>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the relationship class ${property.relationshipClass.name} in the context schema.` };\r\n }\r\n\r\n const navigationProps = {\r\n ...property.toJSON(),\r\n ...props,\r\n relationshipName: type.fullName,\r\n };\r\n\r\n if (property.class.schemaItemType === SchemaItemType.EntityClass)\r\n return context.editor.entities.createNavigationPropertyFromProps(classKey, navigationProps);\r\n if (property.class.schemaItemType === SchemaItemType.Mixin)\r\n return context.editor.mixins.createNavigationPropertyFromProps(classKey, navigationProps);\r\n if (property.class.schemaItemType === SchemaItemType.RelationshipClass)\r\n return context.editor.relationships.createNavigationPropertyFromProps(classKey, navigationProps);\r\n return { errorMessage: `Navigation property can't be added to ${schemaItemTypeToString(property.class.schemaItemType)}.` };\r\n }\r\n\r\n export async function mergeAttributes(context: SchemaMergeContext, property: NavigationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n switch (attributeName) {\r\n case \"direction\": {\r\n return { errorMessage: `Changing the property '${property.fullName}' direction is not supported.` };\r\n }\r\n case \"relationshipClass\": {\r\n return { errorMessage: `Changing the property '${property.fullName}' relationship class is not supported.` };\r\n }\r\n }\r\n return PropertyMerger.mergeAttributes(context, property, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAgN;AAChN,+CAA4C;AAK5C,mEAAgE;AAEhE;;GAEG;AACH,MAAqB,uBAAwB,SAAQ,yBAA8B;IAE9D,KAAK,CAAC,MAAM,CAAC,SAAo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F;QAED,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;IACvD,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,OAAqB;QAC1E,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,EAAE;YAExF,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAoB,OAAO,CAAC,CAAC;YACjG,IAAI,iBAAiB,KAAK,SAAS,EAAE;gBACnC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,2CAA2C,OAAO,CAAC,IAAI,yBAAyB,EAAE,CAAC;aACpH;YAED,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,EAAE;gBAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,CAAC;gBACrH,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;oBACrC,OAAO,MAAM,CAAC;iBACf;aACF;YAED,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,GAAG,CAAC,EAAE;gBAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,CAAC;gBACrH,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;oBACrC,OAAO,MAAM,CAAC;iBACf;aACF;SACF;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AAxID,0CAwIC","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, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraint, RelationshipMultiplicity, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ClassChanges, RelationshipConstraintChanges } from \"../Validation/SchemaChanges\";\nimport { MutableRelationshipClass } from \"@itwin/ecschema-metadata/src/Metadata/RelationshipClass\";\nimport { MutableRelationshipConstraint } from \"../Editing/Mutable/MutableRelationshipClass\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * @internal\n */\nexport default class RelationshipClassMerger extends ClassMerger<RelationshipClass> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: RelationshipClass): Promise<SchemaItemEditResults> {\n return this.context.editor.relationships.create(schemaKey, ecClass.name, ecClass.modifier, ecClass.strength, ecClass.strengthDirection);\n }\n\n protected override async mergeAttributes(ecClass: RelationshipClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const mutableRelationship = ecClass as unknown as MutableRelationshipClass;\n switch(attributeName) {\n case \"strength\":\n if (attributeOldValue === undefined) {\n const strength = parseStrength(attributeNewValue);\n if (strength === undefined) {\n return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strength value '${attributeNewValue}' has been provided.` };\n }\n mutableRelationship.setStrength(strength);\n return true;\n }\n return { errorMessage: `Changing the relationship '${ecClass.name}' strength is not supported.` };\n\n case \"strengthDirection\":\n if (attributeOldValue === undefined) {\n const strengthDirection = parseStrengthDirection(attributeNewValue);\n if (strengthDirection === undefined) {\n return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strengthDirection value '${attributeNewValue}' has been provided.` };\n }\n mutableRelationship.setStrengthDirection(strengthDirection);\n return true;\n }\n return { errorMessage: `Changing the relationship '${ecClass.name}' strengthDirection is not supported.` };\n }\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n }\n\n private async mergeConstraintAttributes(constraint: RelationshipConstraint, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n switch(attributeName) {\n case \"multiplicity\":\n if (attributeOldValue === undefined) {\n const multiplicity = RelationshipMultiplicity.fromString(attributeNewValue);\n if (multiplicity === undefined) {\n return { errorMessage: `An invalid relationship constraint multiplicity value '${attributeNewValue}' has been provided.` };\n }\n return this.context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\n }\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };\n\n case \"polymorphic\":\n if (attributeOldValue === undefined || attributeNewValue === true) {\n return this.context.editor.relationships.setConstraintPolymorphic(constraint, attributeNewValue);\n }\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' polymorphic is not supported.` };\n\n case \"roleLabel\":\n (constraint as MutableRelationshipConstraint).roleLabel = attributeNewValue;\n return true;\n\n case \"abstractConstraint\":\n const [schemaName, itemName] = SchemaItem.parseFullName(attributeNewValue);\n const itemKey = new SchemaItemKey(itemName, this.context.sourceSchema.schemaKey.compareByName(schemaName)\n ? this.context.targetSchema.schemaKey\n : new SchemaKey(schemaName));\n\n const abstractConstraint = await this.context.targetSchema.lookupItem<Mixin | EntityClass | RelationshipClass>(itemKey);\n if (abstractConstraint === undefined) {\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${attributeNewValue} in the context schema.`};\n }\n return this.context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\n }\n return false;\n }\n\n private async mergeConstraintChanges(constraint: RelationshipConstraint, constraintChanges: IterableIterator<RelationshipConstraintChanges>): Promise<SchemaItemEditResults> {\n for (const change of constraintChanges) {\n\n for (const constraintClassChange of change.constraintClassChanges) {\n const ecClass = constraintClassChange.diagnostic.messageArgs![0];\n const itemKey = new SchemaItemKey(ecClass.name, this.context.sourceSchema.schemaKey.matches(ecClass.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : ecClass.schema.schemaKey);\n\n const constaintClass = await this.context.targetSchema.lookupItem<Mixin | EntityClass | RelationshipClass>(itemKey);\n if (constaintClass === undefined) {\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the constraint class ${itemKey.fullName} in the context schema.` };\n }\n const results = await this.context.editor.relationships.addConstraintClass(constraint, constaintClass);\n if (results.errorMessage !== undefined) {\n return results;\n }\n }\n\n for (const propertyValueChange of change.propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = propertyValueChange.diagnostic.messageArgs!;\n const results = await this.mergeConstraintAttributes(constraint, attributeName, attributeNewValue, attributeOldValue);\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n }\n\n if (change.customAttributeChanges.size > 0) {\n const results = await mergeCustomAttributes(this.context, change.customAttributeChanges.values(), async (ca) => {\n return this.context.editor.relationships.addCustomAttributeToConstraint(constraint, ca);\n });\n if (results.errorMessage !== undefined) {\n return results;\n }\n }\n }\n\n return { itemKey: constraint.relationshipClass.key };\n }\n\n protected override async merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults> {\n if (changes.sourceConstraintChanges.size > 0 || changes.targetConstraintChanges.size > 0) {\n\n const relationshipClass = await this.context.targetSchema.lookupItem<RelationshipClass>(itemKey);\n if (relationshipClass === undefined) {\n return { itemKey, errorMessage: `Unable to locate the relationship class ${itemKey.name} in the context schema.` };\n }\n\n if (changes.sourceConstraintChanges.size > 0) {\n const result = await this.mergeConstraintChanges(relationshipClass.source, changes.sourceConstraintChanges.values());\n if (result.errorMessage !== undefined) {\n return result;\n }\n }\n\n if (changes.targetConstraintChanges.size > 0) {\n const result = await this.mergeConstraintChanges(relationshipClass.target, changes.targetConstraintChanges.values());\n if (result.errorMessage !== undefined) {\n return result;\n }\n }\n }\n\n return { itemKey };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","s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,CAAC;iBACf;aACF;SACF;QAED,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF;AAxID,0CAwIC","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, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraint, RelationshipMultiplicity, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { ClassMerger } from \"./ClassMerger\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { ClassChanges, RelationshipConstraintChanges } from \"../Validation/SchemaChanges\";\r\nimport { MutableRelationshipClass } from \"@itwin/ecschema-metadata/src/Metadata/RelationshipClass\";\r\nimport { MutableRelationshipConstraint } from \"../Editing/Mutable/MutableRelationshipClass\";\r\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class RelationshipClassMerger extends ClassMerger<RelationshipClass> {\r\n\r\n protected override async create(schemaKey: SchemaKey, ecClass: RelationshipClass): Promise<SchemaItemEditResults> {\r\n return this.context.editor.relationships.create(schemaKey, ecClass.name, ecClass.modifier, ecClass.strength, ecClass.strengthDirection);\r\n }\r\n\r\n protected override async mergeAttributes(ecClass: RelationshipClass, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n const mutableRelationship = ecClass as unknown as MutableRelationshipClass;\r\n switch(attributeName) {\r\n case \"strength\":\r\n if (attributeOldValue === undefined) {\r\n const strength = parseStrength(attributeNewValue);\r\n if (strength === undefined) {\r\n return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strength value '${attributeNewValue}' has been provided.` };\r\n }\r\n mutableRelationship.setStrength(strength);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the relationship '${ecClass.name}' strength is not supported.` };\r\n\r\n case \"strengthDirection\":\r\n if (attributeOldValue === undefined) {\r\n const strengthDirection = parseStrengthDirection(attributeNewValue);\r\n if (strengthDirection === undefined) {\r\n return { itemKey: ecClass.key, errorMessage: `An invalid relationship class strengthDirection value '${attributeNewValue}' has been provided.` };\r\n }\r\n mutableRelationship.setStrengthDirection(strengthDirection);\r\n return true;\r\n }\r\n return { errorMessage: `Changing the relationship '${ecClass.name}' strengthDirection is not supported.` };\r\n }\r\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n\r\n private async mergeConstraintAttributes(constraint: RelationshipConstraint, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n switch(attributeName) {\r\n case \"multiplicity\":\r\n if (attributeOldValue === undefined) {\r\n const multiplicity = RelationshipMultiplicity.fromString(attributeNewValue);\r\n if (multiplicity === undefined) {\r\n return { errorMessage: `An invalid relationship constraint multiplicity value '${attributeNewValue}' has been provided.` };\r\n }\r\n return this.context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\r\n }\r\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };\r\n\r\n case \"polymorphic\":\r\n if (attributeOldValue === undefined || attributeNewValue === true) {\r\n return this.context.editor.relationships.setConstraintPolymorphic(constraint, attributeNewValue);\r\n }\r\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' polymorphic is not supported.` };\r\n\r\n case \"roleLabel\":\r\n (constraint as MutableRelationshipConstraint).roleLabel = attributeNewValue;\r\n return true;\r\n\r\n case \"abstractConstraint\":\r\n const [schemaName, itemName] = SchemaItem.parseFullName(attributeNewValue);\r\n const itemKey = new SchemaItemKey(itemName, this.context.sourceSchema.schemaKey.compareByName(schemaName)\r\n ? this.context.targetSchema.schemaKey\r\n : new SchemaKey(schemaName));\r\n\r\n const abstractConstraint = await this.context.targetSchema.lookupItem<Mixin | EntityClass | RelationshipClass>(itemKey);\r\n if (abstractConstraint === undefined) {\r\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${attributeNewValue} in the context schema.`};\r\n }\r\n return this.context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\r\n }\r\n return false;\r\n }\r\n\r\n private async mergeConstraintChanges(constraint: RelationshipConstraint, constraintChanges: IterableIterator<RelationshipConstraintChanges>): Promise<SchemaItemEditResults> {\r\n for (const change of constraintChanges) {\r\n\r\n for (const constraintClassChange of change.constraintClassChanges) {\r\n const ecClass = constraintClassChange.diagnostic.messageArgs![0];\r\n const itemKey = new SchemaItemKey(ecClass.name, this.context.sourceSchema.schemaKey.matches(ecClass.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : ecClass.schema.schemaKey);\r\n\r\n const constaintClass = await this.context.targetSchema.lookupItem<Mixin | EntityClass | RelationshipClass>(itemKey);\r\n if (constaintClass === undefined) {\r\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the constraint class ${itemKey.fullName} in the context schema.` };\r\n }\r\n const results = await this.context.editor.relationships.addConstraintClass(constraint, constaintClass);\r\n if (results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n\r\n for (const propertyValueChange of change.propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = propertyValueChange.diagnostic.messageArgs!;\r\n const results = await this.mergeConstraintAttributes(constraint, attributeName, attributeNewValue, attributeOldValue);\r\n if (this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n\r\n if (change.customAttributeChanges.size > 0) {\r\n const results = await mergeCustomAttributes(this.context, change.customAttributeChanges.values(), async (ca) => {\r\n return this.context.editor.relationships.addCustomAttributeToConstraint(constraint, ca);\r\n });\r\n if (results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n }\r\n }\r\n\r\n return { itemKey: constraint.relationshipClass.key };\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, changes: ClassChanges): Promise<SchemaItemEditResults> {\r\n if (changes.sourceConstraintChanges.size > 0 || changes.targetConstraintChanges.size > 0) {\r\n\r\n const relationshipClass = await this.context.targetSchema.lookupItem<RelationshipClass>(itemKey);\r\n if (relationshipClass === undefined) {\r\n return { itemKey, errorMessage: `Unable to locate the relationship class ${itemKey.name} in the context schema.` };\r\n }\r\n\r\n if (changes.sourceConstraintChanges.size > 0) {\r\n const result = await this.mergeConstraintChanges(relationshipClass.source, changes.sourceConstraintChanges.values());\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n\r\n if (changes.targetConstraintChanges.size > 0) {\r\n const result = await this.mergeConstraintChanges(relationshipClass.target, changes.targetConstraintChanges.values());\r\n if (result.errorMessage !== undefined) {\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return { itemKey };\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
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,CAAC,MAA2B,EAAE,eAA0B,EAAE,QAAoB;QACrG,IAAI,EAAE,CAAC,QAAQ,EAAE,+BAAW,CAAC;YAC3B,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AW,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"]}
|
|
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,OAA2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GAAG,CAAC,SAAS,CAAC;gBAC3E,CAAC,CAAC,IAAI,iCAAa,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC;gBAC1D,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC;YACxB,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SAChF;QACD,IAAI,EAAE,CAAC,QAAQ,EAAE,8BAAU,CAAC;YAC1B,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,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":["/*---------------------------------------------------------------------------------------------\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, CustomAttributeClass, EntityClass, Enumeration, KindOfQuantity, Phenomenon, PrimitiveType, PropertyCategory, SchemaItem, SchemaItemKey, SchemaKey, StructClass, UnitSystem } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport namespace SchemaItemFactory {\r\n\r\n /**\r\n * Creates a new Schema Item based on the given template instance.\r\n * @param context The current merging context.\r\n * @param template The Schema Items Template\r\n * @returns The SchemaItemKey of the created item.\r\n */\r\n export async function create(context: SchemaMergeContext, template: SchemaItem): Promise<SchemaItemKey> {\r\n const result = await createItem(context.editor, context.targetSchema.schemaKey, template);\r\n if(result.errorMessage) {\r\n throw new Error(result.errorMessage);\r\n }\r\n return result.itemKey!;\r\n }\r\n\r\n /**\r\n * Creates a new Schema Item in the SchemaContextEditor.\r\n * @param editor The SchemaContextEditor\r\n * @param targetSchemaKey The key of the target schema the item shall be created in.\r\n * @param template The Schema Items Template\r\n * @returns A SchemaItemEditResults with a schema key if the item could be created.\r\n */\r\n async function createItem(editor: SchemaContextEditor, targetSchemaKey: SchemaKey, template: SchemaItem): Promise<SchemaItemEditResults> {\r\n if (is(template, Enumeration))\r\n return editor.enumerations.create(targetSchemaKey, template.name, template.isInt ? PrimitiveType.Integer : PrimitiveType.String, template.label, template.isStrict);\r\n if (is(template, EntityClass))\r\n return editor.entities.create(targetSchemaKey, template.name, template.modifier);\r\n if (is(template, StructClass))\r\n return editor.structs.create(targetSchemaKey, template.name);\r\n if (is(template, CustomAttributeClass))\r\n return editor.customAttributes.create(targetSchemaKey, template.name, template.containerType);\r\n if(is(template, PropertyCategory))\r\n return editor.propertyCategories.create(targetSchemaKey, template.name, template.priority);\r\n if (is(template, Phenomenon))\r\n return editor.phenomenons.create(targetSchemaKey, template.name, template.definition);\r\n if (is(template, Constant)) {\r\n if(template.phenomenon === undefined) {\r\n throw new Error(`Invalid Constant ${template.name} has no phenomenon defined`);\r\n }\r\n const phenomenon = await template.phenomenon;\r\n const itemKey = phenomenon.key.schemaKey.matches(template.key.schemaKey)\r\n ? new SchemaItemKey(phenomenon.name, targetSchemaKey)\r\n : phenomenon.key;\r\n\r\n return editor.constants.create(targetSchemaKey, template.name, itemKey, template.definition);\r\n }\r\n if (is(template, KindOfQuantity)) {\r\n if(template.persistenceUnit === undefined) {\r\n throw new Error(`Invalid KindOfQuantity ${template.name} has no persistenceUnit defined`);\r\n }\r\n const persistenceUnit = await template.persistenceUnit;\r\n const itemKey = persistenceUnit.key.schemaKey.matches(template.key.schemaKey)\r\n ? new SchemaItemKey(persistenceUnit.name, targetSchemaKey)\r\n : persistenceUnit.key;\r\n return editor.kindOfQuantities.create(targetSchemaKey, template.name, itemKey);\r\n }\r\n if (is(template, UnitSystem))\r\n return editor.unitSystems.create(targetSchemaKey, template.name);\r\n\r\n throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);\r\n }\r\n\r\n /**\r\n * Type Guard to \"cast\" a given schema item into an implementation\r\n * @param item Item to be checked\r\n * @param type The desired implementation.\r\n * @returns true if the item could be casted, otherwise false.\r\n */\r\n function is<T extends SchemaItem>(item: SchemaItem, type: new (...args: any) => T ): item is T {\r\n return item instanceof type;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAqE;AACrE,+DAAiG;AACjG,2DAAwD;AAkBxD;;;;;;GAMG;AACH,MAAa,gBAAgB;IAI3B;;;;OAIG;IACH,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,2BAA2B;QACzC,sDAAsD;QACtD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,KAAK,CAAC,QAAuB,EAAE,OAAc,EAAE,OAA0B;QACvF,uCAAuC;IACzC,CAAC;IAES,KAAK,CAAC,MAAM,CAAuB,UAAa;QACxD,MAAM,OAAO,GAAG,IAAI,iCAAa,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC;YACzH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAC9B,CAA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AAC,MAAM,KAAK,CAAC,EAAE;YACvB,OAAO;SACR;QAED,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAa,aAAa,CAAC,CAAC,CAAC;QAC3F,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,CAAkC,CAAC;QAChF,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAElE,KAAI,MAAM,MAAM,IAAI,OAAO,EAAE;YAC3B,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,WAAkD,CAAC;YAChI,MAAM,QAAQ,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAChD,SAAS,CAAC,YAAY,CAAC,GAAG,QAAQ,KAAK,SAAS;gBAC9C,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,CAAC;gBAC7D,CAAC,CAAC,gBAAgB,CAAC;SACtB;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CACF;AAjGD,4CAiGC","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 { SchemaItem, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { ChangeType, PropertyValueChange, SchemaItemChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaItemFactory } from \"./SchemaItemFactory\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\n/**\n * Defines a type-safe interface of Property Value resolver.\n * @internal\n */\nexport type PropertyValueResolver<T extends SchemaItem, TProps=MutableSchemaItemProps<T>> = {\n [P in keyof TProps]?: (newValue: any, item: SchemaItemKey, oldValue?: any) => any;\n};\n\n/**\n * Defines a Mutable Schema Props interface.\n */\ntype MutableSchemaItemProps<T extends SchemaItem> = {\n -readonly [key in keyof ReturnType<T[\"toJSON\"]>]: ReturnType<T[\"toJSON\"]>[key];\n};\n\n/**\n * The SchemaItemMerger is an base class for several other mergers with the actual logic\n * to perform merging for a certain schema item type. The class provides the shared logics\n * that is shared for all schema item mergers and custom logic can be applied by overriding\n * the protected class members.\n * @internal\n */\nexport class SchemaItemMerger<TItem extends SchemaItem> {\n\n protected readonly context: SchemaMergeContext;\n\n /**\n * Constructor of the SchemaItemMerger class. This should not be overriden or extended\n * by sub-implementations.\n * @param context The current merging context.\n */\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n /**\n * This overridable method allows to create a property value resolver that gets defines\n * a handler function for every possible property change. This allows adding complex handing\n * if a property value requires complicated merging.\n * @returns A resolver map with resolvers for the property.\n */\n protected async createPropertyValueResolver(): Promise<PropertyValueResolver<TItem>> {\n // Can be overriden for complex property value merging\n return {};\n }\n\n /**\n * This overridable method gets called for more complex merging.\n * @param _itemKey The key of the current schema item.\n * @param _source The source item that shall gets merged into.\n * @param _change The schema item change to be applied.\n */\n protected async merge(_itemKey: SchemaItemKey, _source: TItem, _change: SchemaItemChanges) {\n // Can be overriden for complex merging\n }\n\n protected async lookup<T extends SchemaItem>(schemaItem: T): Promise<T | undefined>{\n const itemKey = new SchemaItemKey(schemaItem.name, this.context.sourceSchema.schemaKey.matches(schemaItem.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : schemaItem.schema.schemaKey,\n );\n return this.context.targetSchema.lookupItem<T>(itemKey);\n }\n\n /**\n * Merges the given schema item changes in the current context.\n * @param context The merging context\n * @param schemaItemChanges An iterable of item changes.\n */\n public static async mergeChanges<TChange extends SchemaItemChanges>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>) {\n const merger = new this(context);\n for(const change of schemaItemChanges) {\n\n // Gets the source and the target item. The target item could be undefined at that point.\n const sourceItem = (await context.sourceSchema.getItem<SchemaItem>(change.ecTypeName))!;\n let targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\n\n // In case the schema item does not exists in the target schema, an instance for\n // this schema item is created. It's properties get set by the merger then.\n if(change.schemaItemMissing?.changeType === ChangeType.Missing) {\n // Check for name to make sure there is no collision for items with the same name\n // but different type.\n if(await context.targetSchema.lookupItem(targetItemKey) !== undefined) {\n throw new Error(`Schema ${context.targetSchema.name} already contains a Schema Item ${change.ecTypeName}.`);\n }\n\n // TODO: Think about renaming the Schema Item. This could be controlled though a flag.\n targetItemKey = await SchemaItemFactory.create(context, sourceItem);\n }\n\n await merger.mergeItemPropertyValues(targetItemKey, change.propertyValueChanges);\n await merger.merge(targetItemKey, sourceItem, change);\n }\n }\n /**\n * Merges the property values.\n * @param targetItem The current schema item\n * @param changes The property changes.\n */\n private async mergeItemPropertyValues(targetItemKey: SchemaItemKey, changes: PropertyValueChange[]) {\n // No need to process anything if no properties differ.\n if(changes.length === 0) {\n return;\n }\n\n const targetItem = (await this.context.targetSchema.lookupItem<SchemaItem>(targetItemKey));\n const jsonProps = (targetItem?.toJSON() ?? {}) as MutableSchemaItemProps<TItem>;\n const propertyResolver = await this.createPropertyValueResolver();\n\n for(const change of changes) {\n const [propertyName, propertyNewValue, propertyOldValue] = change.diagnostic.messageArgs! as [keyof typeof jsonProps, any, any];\n const resolver = propertyResolver[propertyName];\n jsonProps[propertyName] = resolver !== undefined\n ? resolver(propertyNewValue, targetItemKey, propertyOldValue)\n : propertyNewValue;\n }\n\n await this.context.editor.schemaItems.applyProps(targetItemKey, jsonProps);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaItemMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAqE;AACrE,+DAAiG;AACjG,2DAAwD;AAkBxD;;;;;;GAMG;AACH,MAAa,gBAAgB;IAI3B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C7D,CAAC,CAAC,gBAAgB,CAAC;SACtB;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CACF;AAjGD,4CAiGC","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 { SchemaItem, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, PropertyValueChange, SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaItemFactory } from \"./SchemaItemFactory\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * Defines a type-safe interface of Property Value resolver.\r\n * @internal\r\n */\r\nexport type PropertyValueResolver<T extends SchemaItem, TProps=MutableSchemaItemProps<T>> = {\r\n [P in keyof TProps]?: (newValue: any, item: SchemaItemKey, oldValue?: any) => any;\r\n};\r\n\r\n/**\r\n * Defines a Mutable Schema Props interface.\r\n */\r\ntype MutableSchemaItemProps<T extends SchemaItem> = {\r\n -readonly [key in keyof ReturnType<T[\"toJSON\"]>]: ReturnType<T[\"toJSON\"]>[key];\r\n};\r\n\r\n/**\r\n * The SchemaItemMerger is an base class for several other mergers with the actual logic\r\n * to perform merging for a certain schema item type. The class provides the shared logics\r\n * that is shared for all schema item mergers and custom logic can be applied by overriding\r\n * the protected class members.\r\n * @internal\r\n */\r\nexport class SchemaItemMerger<TItem extends SchemaItem> {\r\n\r\n protected readonly context: SchemaMergeContext;\r\n\r\n /**\r\n * Constructor of the SchemaItemMerger class. This should not be overriden or extended\r\n * by sub-implementations.\r\n * @param context The current merging context.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this.context = context;\r\n }\r\n\r\n /**\r\n * This overridable method allows to create a property value resolver that gets defines\r\n * a handler function for every possible property change. This allows adding complex handing\r\n * if a property value requires complicated merging.\r\n * @returns A resolver map with resolvers for the property.\r\n */\r\n protected async createPropertyValueResolver(): Promise<PropertyValueResolver<TItem>> {\r\n // Can be overriden for complex property value merging\r\n return {};\r\n }\r\n\r\n /**\r\n * This overridable method gets called for more complex merging.\r\n * @param _itemKey The key of the current schema item.\r\n * @param _source The source item that shall gets merged into.\r\n * @param _change The schema item change to be applied.\r\n */\r\n protected async merge(_itemKey: SchemaItemKey, _source: TItem, _change: SchemaItemChanges) {\r\n // Can be overriden for complex merging\r\n }\r\n\r\n protected async lookup<T extends SchemaItem>(schemaItem: T): Promise<T | undefined>{\r\n const itemKey = new SchemaItemKey(schemaItem.name, this.context.sourceSchema.schemaKey.matches(schemaItem.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : schemaItem.schema.schemaKey,\r\n );\r\n return this.context.targetSchema.lookupItem<T>(itemKey);\r\n }\r\n\r\n /**\r\n * Merges the given schema item changes in the current context.\r\n * @param context The merging context\r\n * @param schemaItemChanges An iterable of item changes.\r\n */\r\n public static async mergeChanges<TChange extends SchemaItemChanges>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>) {\r\n const merger = new this(context);\r\n for(const change of schemaItemChanges) {\r\n\r\n // Gets the source and the target item. The target item could be undefined at that point.\r\n const sourceItem = (await context.sourceSchema.getItem<SchemaItem>(change.ecTypeName))!;\r\n let targetItemKey = new SchemaItemKey(change.ecTypeName, context.targetSchema.schemaKey);\r\n\r\n // In case the schema item does not exists in the target schema, an instance for\r\n // this schema item is created. It's properties get set by the merger then.\r\n if(change.schemaItemMissing?.changeType === ChangeType.Missing) {\r\n // Check for name to make sure there is no collision for items with the same name\r\n // but different type.\r\n if(await context.targetSchema.lookupItem(targetItemKey) !== undefined) {\r\n throw new Error(`Schema ${context.targetSchema.name} already contains a Schema Item ${change.ecTypeName}.`);\r\n }\r\n\r\n // TODO: Think about renaming the Schema Item. This could be controlled though a flag.\r\n targetItemKey = await SchemaItemFactory.create(context, sourceItem);\r\n }\r\n\r\n await merger.mergeItemPropertyValues(targetItemKey, change.propertyValueChanges);\r\n await merger.merge(targetItemKey, sourceItem, change);\r\n }\r\n }\r\n /**\r\n * Merges the property values.\r\n * @param targetItem The current schema item\r\n * @param changes The property changes.\r\n */\r\n private async mergeItemPropertyValues(targetItemKey: SchemaItemKey, changes: PropertyValueChange[]) {\r\n // No need to process anything if no properties differ.\r\n if(changes.length === 0) {\r\n return;\r\n }\r\n\r\n const targetItem = (await this.context.targetSchema.lookupItem<SchemaItem>(targetItemKey));\r\n const jsonProps = (targetItem?.toJSON() ?? {}) as MutableSchemaItemProps<TItem>;\r\n const propertyResolver = await this.createPropertyValueResolver();\r\n\r\n for(const change of changes) {\r\n const [propertyName, propertyNewValue, propertyOldValue] = change.diagnostic.messageArgs! as [keyof typeof jsonProps, any, any];\r\n const resolver = propertyResolver[propertyName];\r\n jsonProps[propertyName] = resolver !== undefined\r\n ? resolver(propertyNewValue, targetItemKey, propertyOldValue)\r\n : propertyNewValue;\r\n }\r\n\r\n await this.context.editor.schemaItems.applyProps(targetItemKey, jsonProps);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkE;AAElE,iEAA8D;AAC9D,8CAAwD;AACxD,yDAAsD;AAEtD,mEAA4D;AAC5D,mDAA4C;AAC5C,2DAAoD;AACpD,qDAA+C;AAC/C,2DAAoD;AACpD,2DAAoD;AACpD,+CAAwC;AACxC,mEAAgE;AAChE,iEAA0D;AAC1D,uEAAgE;AAYhE;;;;GAIG;AACH,MAAa,YAAY;IACvB;;;;;;;OAOG;IACK,KAAK,CAAC,gBAAgB,CAAC,YAAoB,EAAE,YAAoB;QACvE,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,MAAM,cAAc,GAAG,IAAI,+B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AA6B,EAAE,GAAG,KAAuB;IAC7H,KAAI,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YACzC,MAAM,MAAM,CAAC;SACd;KACF;AACH,CAAC","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 { Schema, SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { SchemaChanges, SchemaItemChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\nimport mergeSchemaReferences from \"./SchemaReferenceMerger\";\nimport CAClassMerger from \"./CAClassMerger\";\nimport EnumerationMerger from \"./EnumerationMerger\";\nimport ConstantsMerger from \"./ConstantMerger\";\nimport EntityClassMerger from \"./EntityClassMerger\";\nimport StructClassMerger from \"./StructClassMerger\";\nimport MixinMerger from \"./MixinMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\nimport KindOfQuantityMerger from \"./KindOfQuantityMerger\";\nimport RelationshipClassMerger from \"./RelationshipClassMerger\";\n\n/**\n * Defines the context of a Schema merging run.\n * @beta\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly sourceSchema: Schema;\n readonly editor: SchemaContextEditor;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] to merge the schemas.\n * @beta\n */\nexport class SchemaMerger {\n /**\n * Gets the @see SchemaChanges between the two given Schemas from perspective of the source\n * to the target schema. For example if source contains a class which does not exists in the\n * target one, it would be listed as missing.\n * @param targetSchema The schema the differences gets merged into.\n * @param sourceSchema The schema to compare.\n * @returns An instance of @see SchemaChanges between the two schemas.\n */\n private async getSchemaChanges(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaChanges> {\n const changesList: SchemaChanges[] = [];\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\n\n // It is important to compare the schema items by name, not full name as otherwise\n // we'd often see differences when comparing two different schemas.\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\n\n return changesList[0];\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @returns The merged target schema.\n */\n public async merge(targetSchema: Schema, sourceSchema: Schema): Promise<Schema> {\n const schemaChanges = await this.getSchemaChanges(targetSchema, sourceSchema);\n const mergeContext: SchemaMergeContext = {\n editor: new SchemaContextEditor(targetSchema.context),\n targetSchema,\n sourceSchema,\n };\n\n await mergeSchemaReferences(mergeContext, schemaChanges);\n\n const itemChanges = getSchemaItemChanges(schemaChanges);\n await EnumerationMerger.mergeChanges(mergeContext, itemChanges.enumeratations);\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.propertyCategories);\n\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.unitSystems);\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.phenomenons);\n await ConstantsMerger.mergeChanges(mergeContext, itemChanges.constants);\n await KindOfQuantityMerger.mergeChanges(mergeContext, itemChanges.kindOfQuantities);\n\n // TODO: For now we just do simple copy and merging of properties and classes. For more complex types\n // with bases classes or relationships, this might need to get extended.\n await CAClassMerger.mergeItemStubChanges(mergeContext, itemChanges.customAttributeClasses);\n await StructClassMerger.mergeItemStubChanges(mergeContext, itemChanges.structClasses);\n await EntityClassMerger.mergeItemStubChanges(mergeContext, itemChanges.entityClasses);\n await MixinMerger.mergeItemStubChanges(mergeContext, itemChanges.mixins);\n await RelationshipClassMerger.mergeItemStubChanges(mergeContext, itemChanges.relationships);\n\n // 2nd pass to complete merge changes such as properties, baseClasses and mixins.\n await CAClassMerger.mergeItemContentChanges(mergeContext, itemChanges.customAttributeClasses);\n await StructClassMerger.mergeItemContentChanges(mergeContext, itemChanges.structClasses);\n await EntityClassMerger.mergeItemContentChanges(mergeContext, itemChanges.entityClasses);\n await MixinMerger.mergeItemContentChanges(mergeContext, itemChanges.mixins);\n await RelationshipClassMerger.mergeItemContentChanges(mergeContext, itemChanges.relationships);\n\n await mergeCustomAttributes(mergeContext, schemaChanges.customAttributeChanges.values(), async (ca) => {\n return mergeContext.editor.addCustomAttribute(mergeContext.targetSchema.schemaKey, ca);\n });\n\n // TODO: For now we directly manipulate the target schema. For error handing purposes, we should first\n // merge into a temporary schema and eventually swap that with the given instance.\n return targetSchema;\n }\n}\n\n/**\n * This helper method composes the different schema change objects to a single easier\n * to use object that should improve readability when the methods get called.\n */\nfunction getSchemaItemChanges(schemaChanges: SchemaChanges) {\n return {\n get constants() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Constant); },\n get customAttributeClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.CustomAttributeClass); },\n get entityClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.EntityClass); },\n get enumeratations() { return schemaChanges.enumerationChanges.values(); },\n get kindOfQuantities() { return schemaChanges.kindOfQuantityChanges.values(); },\n get mixins() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.Mixin); },\n get phenomenons() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Phenomenon); },\n get propertyCategories() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.PropertyCategory); },\n get relationships() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.RelationshipClass); },\n get structClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.StructClass); },\n get unitSystems() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.UnitSystem); },\n };\n}\n\n/**\n * Filters and returns the changed items by its schema item type.\n * @param changes A map of changed schema items.\n * @param types A list of schema item types to filter.\n * @returns An Iterable with the filtered schema items.\n */\nfunction * filterChangesByItemType<TChange extends SchemaItemChanges>(changes: Map<string, TChange>, ...types: SchemaItemType[]): Iterable<TChange> {\n for(const change of changes.values()) {\n if (types.includes(change.schemaItemType)) {\n yield change;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkE;AAElE,iEAA8D;AAC9D,8CAAwD;AACxD,yDAAsD;AAEtD,mEAA4D;AAC5D,mDAA4C;AAC5C,2DAAoD;AACpD,qDAA+C;AAC/C,2DAAoD;AACpD,2DAAoD;AACpD,+CAAwC;AACxC,mEAAgE;AAChE,iEAA0D;AAC1D,uEAAgE;AAYhE;;;;GAIG;AACH,MAAa,YAAY;IACvB;;;;;;;OAOG;IACK,KAAK,CAAC,gBAAgB,CAAC,YAAoB,EAAE,YAAoB;QACvE,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAE1F,kFAAkF;QAClF,mEAAmE;QACnE,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAEhE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,YAAoB,EAAE,YAAoB;QAC3D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC9E,MAAM,YAAY,GAAuB;YACvC,MAAM,EAAE,IAAI,4BAAmB,CAAC,YAAY,CAAC,OAAO,CAAC;YACrD,YAAY;YACZ,YAAY;SACb,CAAC;QAEF,MAAM,IAAA,+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AC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClG,IAAI,WAAW,KAAK,OAAO,uBAAuB,CAAC,aAAa,CAAC,iBAAiB,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjH,IAAI,kBAAkB,KAAK,OAAO,uBAAuB,CAAC,aAAa,CAAC,iBAAiB,EAAE,kCAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC9H,IAAI,aAAa,KAAK,OAAO,uBAAuB,CAAC,aAAa,CAAC,YAAY,EAAE,kCAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QACrH,IAAI,aAAa,KAAK,OAAO,uBAAuB,CAAC,aAAa,CAAC,YAAY,EAAE,kCAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAC/G,IAAI,WAAW,KAAK,OAAO,uBAAuB,CAAC,aAAa,CAAC,iBAAiB,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAClH,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,QAAS,CAAC,CAAC,uBAAuB,CAAoC,OAA6B,EAAE,GAAG,KAAuB;IAC7H,KAAI,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YACzC,MAAM,MAAM,CAAC;SACd;KACF;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport { Schema, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaChanges, SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport { SchemaContextEditor } from \"../Editing/Editor\";\r\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\nimport mergeSchemaReferences from \"./SchemaReferenceMerger\";\r\nimport CAClassMerger from \"./CAClassMerger\";\r\nimport EnumerationMerger from \"./EnumerationMerger\";\r\nimport ConstantsMerger from \"./ConstantMerger\";\r\nimport EntityClassMerger from \"./EntityClassMerger\";\r\nimport StructClassMerger from \"./StructClassMerger\";\r\nimport MixinMerger from \"./MixinMerger\";\r\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\r\nimport KindOfQuantityMerger from \"./KindOfQuantityMerger\";\r\nimport RelationshipClassMerger from \"./RelationshipClassMerger\";\r\n\r\n/**\r\n * Defines the context of a Schema merging run.\r\n * @beta\r\n */\r\nexport interface SchemaMergeContext {\r\n readonly targetSchema: Schema;\r\n readonly sourceSchema: Schema;\r\n readonly editor: SchemaContextEditor;\r\n}\r\n\r\n/**\r\n * Class to merge two schemas together.\r\n * @see [[merge]] to merge the schemas.\r\n * @beta\r\n */\r\nexport class SchemaMerger {\r\n /**\r\n * Gets the @see SchemaChanges between the two given Schemas from perspective of the source\r\n * to the target schema. For example if source contains a class which does not exists in the\r\n * target one, it would be listed as missing.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to compare.\r\n * @returns An instance of @see SchemaChanges between the two schemas.\r\n */\r\n private async getSchemaChanges(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaChanges> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n\r\n // It is important to compare the schema items by name, not full name as otherwise\r\n // we'd often see differences when comparing two different schemas.\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n return changesList[0];\r\n }\r\n\r\n /**\r\n * Copy the SchemaItems of the source schemas to the target schema.\r\n * @param targetSchema The schema the SchemaItems gets merged to.\r\n * @param sourceSchema The schema the SchemaItems gets copied from.\r\n * @returns The merged target schema.\r\n */\r\n public async merge(targetSchema: Schema, sourceSchema: Schema): Promise<Schema> {\r\n const schemaChanges = await this.getSchemaChanges(targetSchema, sourceSchema);\r\n const mergeContext: SchemaMergeContext = {\r\n editor: new SchemaContextEditor(targetSchema.context),\r\n targetSchema,\r\n sourceSchema,\r\n };\r\n\r\n await mergeSchemaReferences(mergeContext, schemaChanges);\r\n\r\n const itemChanges = getSchemaItemChanges(schemaChanges);\r\n await EnumerationMerger.mergeChanges(mergeContext, itemChanges.enumeratations);\r\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.propertyCategories);\r\n\r\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.unitSystems);\r\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.phenomenons);\r\n await ConstantsMerger.mergeChanges(mergeContext, itemChanges.constants);\r\n await KindOfQuantityMerger.mergeChanges(mergeContext, itemChanges.kindOfQuantities);\r\n\r\n // TODO: For now we just do simple copy and merging of properties and classes. For more complex types\r\n // with bases classes or relationships, this might need to get extended.\r\n await CAClassMerger.mergeItemStubChanges(mergeContext, itemChanges.customAttributeClasses);\r\n await StructClassMerger.mergeItemStubChanges(mergeContext, itemChanges.structClasses);\r\n await EntityClassMerger.mergeItemStubChanges(mergeContext, itemChanges.entityClasses);\r\n await MixinMerger.mergeItemStubChanges(mergeContext, itemChanges.mixins);\r\n await RelationshipClassMerger.mergeItemStubChanges(mergeContext, itemChanges.relationships);\r\n\r\n // 2nd pass to complete merge changes such as properties, baseClasses and mixins.\r\n await CAClassMerger.mergeItemContentChanges(mergeContext, itemChanges.customAttributeClasses);\r\n await StructClassMerger.mergeItemContentChanges(mergeContext, itemChanges.structClasses);\r\n await EntityClassMerger.mergeItemContentChanges(mergeContext, itemChanges.entityClasses);\r\n await MixinMerger.mergeItemContentChanges(mergeContext, itemChanges.mixins);\r\n await RelationshipClassMerger.mergeItemContentChanges(mergeContext, itemChanges.relationships);\r\n\r\n await mergeCustomAttributes(mergeContext, schemaChanges.customAttributeChanges.values(), async (ca) => {\r\n return mergeContext.editor.addCustomAttribute(mergeContext.targetSchema.schemaKey, ca);\r\n });\r\n\r\n // TODO: For now we directly manipulate the target schema. For error handing purposes, we should first\r\n // merge into a temporary schema and eventually swap that with the given instance.\r\n return targetSchema;\r\n }\r\n}\r\n\r\n/**\r\n * This helper method composes the different schema change objects to a single easier\r\n * to use object that should improve readability when the methods get called.\r\n */\r\nfunction getSchemaItemChanges(schemaChanges: SchemaChanges) {\r\n return {\r\n get constants() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Constant); },\r\n get customAttributeClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.CustomAttributeClass); },\r\n get entityClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.EntityClass); },\r\n get enumeratations() { return schemaChanges.enumerationChanges.values(); },\r\n get kindOfQuantities() { return schemaChanges.kindOfQuantityChanges.values(); },\r\n get mixins() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.Mixin); },\r\n get phenomenons() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Phenomenon); },\r\n get propertyCategories() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.PropertyCategory); },\r\n get relationships() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.RelationshipClass); },\r\n get structClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.StructClass); },\r\n get unitSystems() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.UnitSystem); },\r\n };\r\n}\r\n\r\n/**\r\n * Filters and returns the changed items by its schema item type.\r\n * @param changes A map of changed schema items.\r\n * @param types A list of schema item types to filter.\r\n * @returns An Iterable with the filtered schema items.\r\n */\r\nfunction * filterChangesByItemType<TChange extends SchemaItemChanges>(changes: Map<string, TChange>, ...types: SchemaItemType[]): Iterable<TChange> {\r\n for(const change of changes.values()) {\r\n if (types.includes(change.schemaItemType)) {\r\n yield change;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @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;SACV;QAED,MAAM,KAAK,GAAG,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,cAAc,CAAC,CAAC;QAC7F,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEzC,MAAM,YAAY,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;KACxF;AACH,CAAC;AA/BD,wCA+BC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,IAAY,EAAE,KAAa;IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC;QACzD,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;QACf,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACpB,CAAC","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 { Schema, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\n/**\n * Merges the schema references of two schemas.\n * @param mergeContext current merge context\n * @param changes schema changes.\n * @internal\n */\nexport default async function mergeSchemaReferences(mergeContext: SchemaMergeContext, changes: SchemaChanges) {\n const targetSchema = mergeContext.targetSchema;\n\n // If the target schema does not have a reference to a schema yet, it can be added\n // but should be checked if it's schema references have collisions with existing references.\n for(const missingSchemaReference of changes.missingSchemaReferences) {\n const [referencedSchema] = missingSchemaReference.diagnostic.messageArgs! as [Schema];\n await mergeContext.editor.addSchemaReference(targetSchema.schemaKey, referencedSchema);\n }\n\n // If the source schema referenced a schema that is also referenced by the target\n // schema but in a different version, it is marked as delta. Here we need to check if\n // the source schema is compatible to the existing one. This is not be checked by the\n // schema instance when added.\n for(const differentSchemaReference of changes.schemaReferenceDeltas) {\n const [referencedSchema] = differentSchemaReference.diagnostic.messageArgs! as [Schema];\n const existingSchema = (await targetSchema.getReference(referencedSchema.name))!;\n\n const [older, latest] = compareSchemas(existingSchema, referencedSchema);\n if(!latest.schemaKey.matches(older.schemaKey, SchemaMatchType.LatestWriteCompatible)) {\n throw new Error(`Schemas references of ${referencedSchema.name} have incompatible versions: ${older.schemaKey.version} and ${latest.schemaKey.version}`);\n }\n if(latest === existingSchema) {\n continue;\n }\n\n const index = targetSchema.references.findIndex((reference) => reference === existingSchema);\n targetSchema.references.splice(index, 1);\n\n await mergeContext.editor.addSchemaReference(targetSchema.schemaKey, referencedSchema);\n }\n}\n\n/**\n * Compares the schemas and return them in order of their versions [older, latest].\n * @param left The first schema to be added.\n * @param right The second schema to be added.\n * @returns The schemas in order.\n */\nfunction compareSchemas(left: Schema, right: Schema): [Schema, Schema] {\n return left.schemaKey.compareByVersion(right.schemaKey) < 0\n ? [left, right]\n : [right, left];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaReferenceMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAmE;AAInE;;;;;GAKG;AACY,KAAK,UAAU,qBAAqB,CAAC,YAAgC,EAAE,OAAsB;IAC1G,MAAM,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC;IAE/C,kFAAkF;IAClF,4FAA4F;IAC5F,KAAI,MAAM,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,EAAE;QACnE,MAAM,CAAC,gBAAgB,CAAC,GAAG,sBAAsB,CAAC,UAAU,CAAC,WAAwB,CAAC;QACtF,MAAM,YAAY,CAAC,MAAM,CAAC,kBAAkB,CAAC,YAAY,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;KACxF;IAED,iFAAiF;IACjF,qFAAqF;IACrF,qFAAq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CAAC;AACpB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Schema, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * Merges the schema references of two schemas.\r\n * @param mergeContext current merge context\r\n * @param changes schema changes.\r\n * @internal\r\n */\r\nexport default async function mergeSchemaReferences(mergeContext: SchemaMergeContext, changes: SchemaChanges) {\r\n const targetSchema = mergeContext.targetSchema;\r\n\r\n // If the target schema does not have a reference to a schema yet, it can be added\r\n // but should be checked if it's schema references have collisions with existing references.\r\n for(const missingSchemaReference of changes.missingSchemaReferences) {\r\n const [referencedSchema] = missingSchemaReference.diagnostic.messageArgs! as [Schema];\r\n await mergeContext.editor.addSchemaReference(targetSchema.schemaKey, referencedSchema);\r\n }\r\n\r\n // If the source schema referenced a schema that is also referenced by the target\r\n // schema but in a different version, it is marked as delta. Here we need to check if\r\n // the source schema is compatible to the existing one. This is not be checked by the\r\n // schema instance when added.\r\n for(const differentSchemaReference of changes.schemaReferenceDeltas) {\r\n const [referencedSchema] = differentSchemaReference.diagnostic.messageArgs! as [Schema];\r\n const existingSchema = (await targetSchema.getReference(referencedSchema.name))!;\r\n\r\n const [older, latest] = compareSchemas(existingSchema, referencedSchema);\r\n if(!latest.schemaKey.matches(older.schemaKey, SchemaMatchType.LatestWriteCompatible)) {\r\n throw new Error(`Schemas references of ${referencedSchema.name} have incompatible versions: ${older.schemaKey.version} and ${latest.schemaKey.version}`);\r\n }\r\n if(latest === existingSchema) {\r\n continue;\r\n }\r\n\r\n const index = targetSchema.references.findIndex((reference) => reference === existingSchema);\r\n targetSchema.references.splice(index, 1);\r\n\r\n await mergeContext.editor.addSchemaReference(targetSchema.schemaKey, referencedSchema);\r\n }\r\n}\r\n\r\n/**\r\n * Compares the schemas and return them in order of their versions [older, latest].\r\n * @param left The first schema to be added.\r\n * @param right The second schema to be added.\r\n * @returns The schemas in order.\r\n */\r\nfunction compareSchemas(left: Schema, right: Schema): [Schema, Schema] {\r\n return left.schemaKey.compareByVersion(right.schemaKey) < 0\r\n ? [left, right]\r\n : [right, left];\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":";;AAKA,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAElD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;CACF;AALD,oCAKC","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 { SchemaKey, StructClass } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\n/**\n * @internal\n */\nexport default class StructClassMerger extends ClassMerger<StructClass> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: StructClass): Promise<SchemaItemEditResults> {\n return this.context.editor.structs.create(schemaKey, ecClass.name);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":";;AAKA,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAElD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;CACF;AALD,oCAKC","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 { SchemaKey, StructClass } from \"@itwin/ecschema-metadata\";\r\nimport { ClassMerger } from \"./ClassMerger\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class StructClassMerger extends ClassMerger<StructClass> {\r\n\r\n protected override async create(schemaKey: SchemaKey, ecClass: StructClass): Promise<SchemaItemEditResults> {\r\n return this.context.editor.structs.create(schemaKey, ecClass.name);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,iDAAiD;AAEjD,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,GAAG,IAAc,EAAE,EAAE;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACrD,OAAO,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,WAAW;YAC3C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACjB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACH,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,mDAAI,CAAA;IACJ,uDAAM,CAAA;IACN,+DAAU,CAAA;IACV,2DAAQ,CAAA;IACR,2FAAwB,CAAA;IACxB,uFAAsB,CAAA;AACxB,CAAC,EAPW,cAAc,GAAd,s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,IAAY;IAChC,MAAM,GAAG,GAAG,mBAAmB,IAAI,0DAA0D,CAAC;IAC9F,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvB,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","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 Diagnostic\n */\n\nimport { AnyClass, AnyECType, AnyProperty, CustomAttributeContainerProps, RelationshipConstraint, Schema, SchemaItem } from \"@itwin/ecschema-metadata\";\n\n/* eslint-disable @typescript-eslint/no-shadow */\n\nconst formatString = (format: string, ...args: string[]) => {\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\n return typeof args[theNumber] !== \"undefined\"\n ? args[theNumber]\n : match;\n });\n};\n\n/**\n * Defines the possible diagnostic types.\n * @beta\n */\nexport enum DiagnosticType {\n None,\n Schema, // eslint-disable-line @typescript-eslint/no-shadow\n SchemaItem, // eslint-disable-line @typescript-eslint/no-shadow\n Property,\n CustomAttributeContainer,\n RelationshipConstraint, // eslint-disable-line @typescript-eslint/no-shadow\n}\n\n/**\n * Defines the possible diagnostic categories.\n * @beta\n */\nexport enum DiagnosticCategory {\n Warning,\n Error,\n Suggestion,\n Message,\n}\n\n/**\n * The interface implemented by all diagnostics used during schema validation.\n * @beta\n */\nexport interface IDiagnostic<TYPE extends AnyECType, ARGS extends any[]> {\n /** The diagnostic category (error, warning, etc...). Value is static across all instances. */\n category: DiagnosticCategory;\n /** The unique string identifier of the diagnostic in the format '<ruleSetName>:<number>. Value is static across all instances. */\n code: string;\n /** The context type of diagnostic (schema, schema item, property, etc...). Value is static across all instances. */\n diagnosticType: DiagnosticType;\n /** The unformatted message text associated with the diagnostic. Value is static across all instances. */\n messageText: string;\n /** The arguments used when formatted the diagnostic instance's message. */\n messageArgs?: ARGS;\n /** The EC object associated with the diagnostic instance. */\n ecDefinition: TYPE;\n /** The schema where the diagnostic originated. */\n schema: Schema;\n}\n\n/**\n * Type which encapsulates all possible diagnostics.\n * @beta\n */\nexport type AnyDiagnostic = IDiagnostic<AnyECType, any[]>;\n\n/**\n * The abstract base class for all [[IDiagnostic]] implementations.\n * @beta\n */\nexport abstract class BaseDiagnostic<TYPE extends AnyECType, ARGS extends any[]> implements IDiagnostic<TYPE, ARGS> {\n /**\n * Initializes a new BaseDiagnostic.\n * @param ecDefinition The EC object to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(ecDefinition: TYPE, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n this.ecDefinition = ecDefinition;\n this.messageArgs = messageArgs;\n this.category = category;\n }\n\n /** Gets the unique string identifier for the diagnostic in the format '<ruleSetName>:<number>'. */\n public abstract get code(): string;\n /** Gets the context type of the diagnostic (schema, schema item, property, etc...) */\n public abstract get diagnosticType(): DiagnosticType;\n /** Gets the message associated with the diagnostic. */\n public abstract get messageText(): string;\n /** Gets the schema where the diagnostic originated. */\n public abstract get schema(): Schema;\n\n /** The EC object to associate with the diagnostic. */\n public ecDefinition: TYPE;\n /** The arguments used when formatting the diagnostic message. */\n public messageArgs?: ARGS;\n /** The diagnostic category is of the type DiagnosticCategory; which is defined as an enumeration above. */\n public category: DiagnosticCategory;\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.\n * @beta\n */\nexport abstract class SchemaDiagnostic<ARGS extends any[]> extends BaseDiagnostic<Schema, ARGS> {\n public static diagnosticType = DiagnosticType.SchemaItem;\n\n /**\n * Initializes a new SchemaDiagnostic.\n * @param ecDefinition The EC object to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(schema: Schema, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(schema, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Schema; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.\n * @beta\n */\nexport abstract class SchemaItemDiagnostic<TYPE extends SchemaItem, ARGS extends any[]> extends BaseDiagnostic<TYPE, ARGS> {\n public static diagnosticType = DiagnosticType.SchemaItem;\n /**\n * Initializes a new SchemaItemDiagnostic.\n * @param ecDefinition The EC object to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(ecDefinition: SchemaItem, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(ecDefinition as TYPE, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.SchemaItem; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.\n * @beta\n */\nexport abstract class ClassDiagnostic<ARGS extends any[]> extends SchemaItemDiagnostic<AnyClass, ARGS> {\n /**\n * Initializes a new ClassDiagnostic.\n * @param ecClass The class to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(ecClass: AnyClass, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(ecClass, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public override get schema(): Schema { return this.ecDefinition.schema; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.\n * @beta\n */\nexport abstract class PropertyDiagnostic<ARGS extends any[]> extends BaseDiagnostic<AnyProperty, ARGS> {\n /**\n * Initializes a new PropertyDiagnostic.\n * @param property The property to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(property: AnyProperty, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(property, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Property; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.\n * @beta\n */\nexport abstract class RelationshipConstraintDiagnostic<ARGS extends any[]> extends BaseDiagnostic<RelationshipConstraint, ARGS> {\n /**\n * Initializes a new RelationshipConstraintDiagnostic.\n * @param constraint The Relationship Constraint to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(constraint: RelationshipConstraint, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(constraint, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.RelationshipConstraint; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.\n * @beta\n */\nexport abstract class CustomAttributeContainerDiagnostic<ARGS extends any[]> extends BaseDiagnostic<CustomAttributeContainerProps, ARGS> {\n /**\n * Initializes a new CustomAttributeContainerDiagnostic.\n * @param constraint The Custom Attribute Container to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(container: CustomAttributeContainerProps, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(container, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.CustomAttributeContainer; }\n}\n\n/**\n * Helper method for creating [[SchemaDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createSchemaDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends SchemaDiagnostic<ARGS> {\n public static code = code;\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[SchemaItemDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createSchemaItemDiagnosticClass<ITEM extends SchemaItem, ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends SchemaItemDiagnostic<ITEM, ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[ClassDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createClassDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends ClassDiagnostic<ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[PropertyDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createPropertyDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends PropertyDiagnostic<ARGS> {\n public static code = code;\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.\n * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createRelationshipConstraintDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends RelationshipConstraintDiagnostic<ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.\n * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createCustomAttributeContainerDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends CustomAttributeContainerDiagnostic<ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/** @beta */\nexport function diagnosticCategoryToString(category: DiagnosticCategory) {\n switch (category) {\n case DiagnosticCategory.Error:\n return \"Error\";\n case DiagnosticCategory.Warning:\n return \"Warning\";\n case DiagnosticCategory.Message:\n return \"Message\";\n case DiagnosticCategory.Suggestion:\n return \"Suggestion\";\n }\n}\n\n/** @beta */\nexport function diagnosticTypeToString(type: DiagnosticType) {\n switch (type) {\n case DiagnosticType.CustomAttributeContainer:\n return \"CustomAttributeContainer\";\n case DiagnosticType.None:\n return \"None\";\n case DiagnosticType.Property:\n return \"Property\";\n case DiagnosticType.RelationshipConstraint:\n return \"RelationshipConstraint\";\n case DiagnosticType.Schema:\n return \"Schema\";\n case DiagnosticType.SchemaItem:\n return \"SchemaItem\";\n }\n}\n\nfunction validateCode(code: string) {\n const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;\n const parts = code.split(\"-\");\n if (parts.length !== 2)\n throw new Error(msg);\n\n if (isNaN(Number(parts[1])))\n throw new Error(msg);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,iDAAiD;AAEjD,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,GAAG,IAAc,EAAE,EAAE;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACrD,OAAO,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,WAAW;YAC3C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACjB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACH,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,mDAAI,CAAA;IACJ,uDAAM,CAAA;IACN,+DAAU,CAAA;IACV,2DAAQ,CAAA;IACR,2FAAwB,CAAA;IACxB,uFAAsB,CAAA;AACxB,CAAC,EAPW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAOzB;AAED;;;GAGG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iEAAO,CAAA;IACP,6DAAK,CAAA;IACL,uEAAU,CAAA;IACV,iEAAO,CAAA;AACT,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAA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AG,CAAC,CAAC;IAEvB,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Diagnostic\r\n */\r\n\r\nimport { AnyClass, AnyECType, AnyProperty, CustomAttributeContainerProps, RelationshipConstraint, Schema, SchemaItem } from \"@itwin/ecschema-metadata\";\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow */\r\n\r\nconst formatString = (format: string, ...args: string[]) => {\r\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\r\n return typeof args[theNumber] !== \"undefined\"\r\n ? args[theNumber]\r\n : match;\r\n });\r\n};\r\n\r\n/**\r\n * Defines the possible diagnostic types.\r\n * @beta\r\n */\r\nexport enum DiagnosticType {\r\n None,\r\n Schema, // eslint-disable-line @typescript-eslint/no-shadow\r\n SchemaItem, // eslint-disable-line @typescript-eslint/no-shadow\r\n Property,\r\n CustomAttributeContainer,\r\n RelationshipConstraint, // eslint-disable-line @typescript-eslint/no-shadow\r\n}\r\n\r\n/**\r\n * Defines the possible diagnostic categories.\r\n * @beta\r\n */\r\nexport enum DiagnosticCategory {\r\n Warning,\r\n Error,\r\n Suggestion,\r\n Message,\r\n}\r\n\r\n/**\r\n * The interface implemented by all diagnostics used during schema validation.\r\n * @beta\r\n */\r\nexport interface IDiagnostic<TYPE extends AnyECType, ARGS extends any[]> {\r\n /** The diagnostic category (error, warning, etc...). Value is static across all instances. */\r\n category: DiagnosticCategory;\r\n /** The unique string identifier of the diagnostic in the format '<ruleSetName>:<number>. Value is static across all instances. */\r\n code: string;\r\n /** The context type of diagnostic (schema, schema item, property, etc...). Value is static across all instances. */\r\n diagnosticType: DiagnosticType;\r\n /** The unformatted message text associated with the diagnostic. Value is static across all instances. */\r\n messageText: string;\r\n /** The arguments used when formatted the diagnostic instance's message. */\r\n messageArgs?: ARGS;\r\n /** The EC object associated with the diagnostic instance. */\r\n ecDefinition: TYPE;\r\n /** The schema where the diagnostic originated. */\r\n schema: Schema;\r\n}\r\n\r\n/**\r\n * Type which encapsulates all possible diagnostics.\r\n * @beta\r\n */\r\nexport type AnyDiagnostic = IDiagnostic<AnyECType, any[]>;\r\n\r\n/**\r\n * The abstract base class for all [[IDiagnostic]] implementations.\r\n * @beta\r\n */\r\nexport abstract class BaseDiagnostic<TYPE extends AnyECType, ARGS extends any[]> implements IDiagnostic<TYPE, ARGS> {\r\n /**\r\n * Initializes a new BaseDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecDefinition: TYPE, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n this.ecDefinition = ecDefinition;\r\n this.messageArgs = messageArgs;\r\n this.category = category;\r\n }\r\n\r\n /** Gets the unique string identifier for the diagnostic in the format '<ruleSetName>:<number>'. */\r\n public abstract get code(): string;\r\n /** Gets the context type of the diagnostic (schema, schema item, property, etc...) */\r\n public abstract get diagnosticType(): DiagnosticType;\r\n /** Gets the message associated with the diagnostic. */\r\n public abstract get messageText(): string;\r\n /** Gets the schema where the diagnostic originated. */\r\n public abstract get schema(): Schema;\r\n\r\n /** The EC object to associate with the diagnostic. */\r\n public ecDefinition: TYPE;\r\n /** The arguments used when formatting the diagnostic message. */\r\n public messageArgs?: ARGS;\r\n /** The diagnostic category is of the type DiagnosticCategory; which is defined as an enumeration above. */\r\n public category: DiagnosticCategory;\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class SchemaDiagnostic<ARGS extends any[]> extends BaseDiagnostic<Schema, ARGS> {\r\n public static diagnosticType = DiagnosticType.SchemaItem;\r\n\r\n /**\r\n * Initializes a new SchemaDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(schema: Schema, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(schema, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Schema; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class SchemaItemDiagnostic<TYPE extends SchemaItem, ARGS extends any[]> extends BaseDiagnostic<TYPE, ARGS> {\r\n public static diagnosticType = DiagnosticType.SchemaItem;\r\n /**\r\n * Initializes a new SchemaItemDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecDefinition: SchemaItem, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(ecDefinition as TYPE, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.SchemaItem; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class ClassDiagnostic<ARGS extends any[]> extends SchemaItemDiagnostic<AnyClass, ARGS> {\r\n /**\r\n * Initializes a new ClassDiagnostic.\r\n * @param ecClass The class to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecClass: AnyClass, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(ecClass, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public override get schema(): Schema { return this.ecDefinition.schema; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class PropertyDiagnostic<ARGS extends any[]> extends BaseDiagnostic<AnyProperty, ARGS> {\r\n /**\r\n * Initializes a new PropertyDiagnostic.\r\n * @param property The property to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(property: AnyProperty, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(property, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Property; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class RelationshipConstraintDiagnostic<ARGS extends any[]> extends BaseDiagnostic<RelationshipConstraint, ARGS> {\r\n /**\r\n * Initializes a new RelationshipConstraintDiagnostic.\r\n * @param constraint The Relationship Constraint to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(constraint: RelationshipConstraint, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(constraint, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.RelationshipConstraint; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class CustomAttributeContainerDiagnostic<ARGS extends any[]> extends BaseDiagnostic<CustomAttributeContainerProps, ARGS> {\r\n /**\r\n * Initializes a new CustomAttributeContainerDiagnostic.\r\n * @param constraint The Custom Attribute Container to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(container: CustomAttributeContainerProps, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(container, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.CustomAttributeContainer; }\r\n}\r\n\r\n/**\r\n * Helper method for creating [[SchemaDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createSchemaDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends SchemaDiagnostic<ARGS> {\r\n public static code = code;\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[SchemaItemDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createSchemaItemDiagnosticClass<ITEM extends SchemaItem, ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends SchemaItemDiagnostic<ITEM, ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[ClassDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createClassDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends ClassDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[PropertyDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createPropertyDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends PropertyDiagnostic<ARGS> {\r\n public static code = code;\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createRelationshipConstraintDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends RelationshipConstraintDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.\r\n * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createCustomAttributeContainerDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends CustomAttributeContainerDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/** @beta */\r\nexport function diagnosticCategoryToString(category: DiagnosticCategory) {\r\n switch (category) {\r\n case DiagnosticCategory.Error:\r\n return \"Error\";\r\n case DiagnosticCategory.Warning:\r\n return \"Warning\";\r\n case DiagnosticCategory.Message:\r\n return \"Message\";\r\n case DiagnosticCategory.Suggestion:\r\n return \"Suggestion\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function diagnosticTypeToString(type: DiagnosticType) {\r\n switch (type) {\r\n case DiagnosticType.CustomAttributeContainer:\r\n return \"CustomAttributeContainer\";\r\n case DiagnosticType.None:\r\n return \"None\";\r\n case DiagnosticType.Property:\r\n return \"Property\";\r\n case DiagnosticType.RelationshipConstraint:\r\n return \"RelationshipConstraint\";\r\n case DiagnosticType.Schema:\r\n return \"Schema\";\r\n case DiagnosticType.SchemaItem:\r\n return \"SchemaItem\";\r\n }\r\n}\r\n\r\nfunction validateCode(code: string) {\r\n const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;\r\n const parts = code.split(\"-\");\r\n if (parts.length !== 2)\r\n throw new Error(msg);\r\n\r\n if (isNaN(Number(parts[1])))\r\n throw new Error(msg);\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticReporter.js","sourceRoot":"","sources":["../../../src/Validation/DiagnosticReporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,iCAAkC;AAElC,MAAM,oBAAo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,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3G,CAAC;IAEO,aAAa,CAAC,UAAyB;QAC7C,IAAI,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAE1D,IAAI,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAC7D,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3F,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,gBAAgB,CAAC,UAAyB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY;YACpB,OAAO,UAAU,CAAC,WAAW,CAAC;QAEhC,OAAO,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;IAClF,CAAC;IAEO,iBAAiB,CAAC,UAAyB;QACjD,OAAO,GAAG,kBAAkB,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IAEO,aAAa,CAAI,KAA2B,EAAE,OAAgB;QACpE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YACvC,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAU,CAAC;QAEzC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApED,4DAoEC","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 Diagnostic\n */\n\nimport { Localization } from \"@itwin/core-common\";\nimport { AnyDiagnostic } from \"./Diagnostic\";\n\nimport assert = require(\"assert\");\n\nconst translationNamespace = \"ECSchemaMetaData\";\nconst subTranslationNamespace = \"Diagnostics\";\nconst baseTranslationKey = `${translationNamespace}:${subTranslationNamespace}`;\n\n/**\n * Interface used to report [[IDiagnostic]] objects created during schema validation.\n * @beta\n */\nexport interface IDiagnosticReporter {\n /**\n * A map where the key is a schema full name and the value is a collection\n * of diagnostics codes identifying which rules violations to ignore during validation.\n */\n suppressions?: Map<string, string[]>;\n\n /** The localization object to use for message translation. */\n localization?: Localization;\n\n /**\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\n * given reporter.\n * @param diagnostic The diagnostic to report.\n */\n report(diagnostic: AnyDiagnostic): void;\n}\n\n/**\n * An abstract base class for [[IDiagnosticReporter]] implementation that used the\n * provided Map to suppress certain rule violations from being reported. The Map's key\n * a schema full name, and the Map's value is a collection of rule codes to suppress.\n * @beta\n */\nexport abstract class SuppressionDiagnosticReporter implements IDiagnosticReporter {\n private _suppressions?: Map<string, string[]>;\n\n /**\n * Initializes a new SuppressionDiagnosticReporter\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\n */\n constructor(suppressions?: Map<string, string[]>) {\n this._suppressions = suppressions;\n }\n\n /**\n * Gets the collection of ISchemaDiagnosticSuppression objects that identify\n * rules violations to ignore during validation.\n */\n public get suppressions(): Map<string, string[]> | undefined {\n return this._suppressions;\n }\n\n /**\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\n * @param diagnostic The diagnostic to report.\n */\n public report(diagnostic: AnyDiagnostic) {\n if (this._suppressions && this._suppressions.has(diagnostic.schema.fullName)) {\n const suppressedCodes = this._suppressions.get(diagnostic.schema.fullName);\n if (suppressedCodes!.includes(diagnostic.code))\n return;\n }\n\n this.reportInternal(diagnostic);\n }\n\n /**\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\n * given reporter.\n * @param diagnostic The diagnostic to report.\n */\n protected abstract reportInternal(diagnostic: AnyDiagnostic): void;\n}\n\n/**\n * An abstract [[SuppressionDiagnosticReporter]] implementation that formats the\n * diagnostic message with the message args. If a Localization implementation is specified,\n * the message will also be translated.\n * @beta\n */\nexport abstract class FormatDiagnosticReporter extends SuppressionDiagnosticReporter {\n /**\n * Initializes a new FormatDiagnosticReporter\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\n * @param localization The Localization instance to use to translate validation messages.\n */\n constructor(suppressions?: Map<string, string[]>, localization?: Localization) {\n super(suppressions);\n this.localization = localization;\n }\n\n /** The Localization object to use for message translation. If undefined, no translation will occur. */\n public localization?: Localization;\n\n /**\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\n * @param diagnostic The diagnostic to report.\n */\n public reportInternal(diagnostic: AnyDiagnostic) {\n const message = this.formatMessage(diagnostic);\n this.reportDiagnostic(diagnostic, message);\n }\n\n /**\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\n * given reporter.\n * @param diagnostic The diagnostic to report.\n * @param messageText The formatted message.\n */\n protected abstract reportDiagnostic(diagnostic: AnyDiagnostic, messageText: string): void;\n\n /**\n * Helper method that formats string with provided arguments where the place holders\n * are in the the format '{0}', '{1}', etc.\n * @param text The text to format.\n * @param args The arguments to place in the text.\n * @param baseIndex The base index for the args, used for validation (typically 0, which is the default).\n */\n protected formatStringFromArgs(text: string, args: ArrayLike<string>, baseIndex = 0): string {\n return text.replace(/{(\\d+)}/g, (_match, index: string) => this.assertDefined(args[+index + baseIndex]));\n }\n\n private formatMessage(diagnostic: AnyDiagnostic): string {\n let translatedMessage = this.translateMessage(diagnostic);\n\n if (diagnostic.messageArgs && diagnostic.messageArgs.length > 0)\n translatedMessage = this.formatStringFromArgs(translatedMessage, diagnostic.messageArgs);\n return translatedMessage;\n }\n\n private translateMessage(diagnostic: AnyDiagnostic): string {\n if (!this.localization)\n return diagnostic.messageText;\n\n return this.localization.getLocalizedString(this.getTranslationKey(diagnostic));\n }\n\n private getTranslationKey(diagnostic: AnyDiagnostic): string {\n return `${baseTranslationKey}.${diagnostic.code}`;\n }\n\n private assertDefined<T>(value: T | null | undefined, message?: string): T {\n if (value === undefined || value === null)\n return assert(false, message) as never;\n\n return value;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DiagnosticReporter.js","sourceRoot":"","sources":["../../../src/Validation/DiagnosticReporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,iCAAkC;AAElC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAC9C,MAAM,kBAAkB,GAAG,GAAG,oBAAoB,IAAI,uBAAuB,EAAE,CAAC;AAwBhF;;;;;GAKG;AACH,MAAsB,6BAA6B;IAGjD;;;OAGG;IACH,YAAY,YAAoC;QAC9C,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAyB;QACrC,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YAC5E,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3E,IAAI,eAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;gBAC5C,OAAO;SACV;QAED,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;CAQF;AAxCD,sEAwCC;AAED;;;;;GAKG;AACH,MAAsB,wBAAyB,SAAQ,6BAA6B;IAClF;;;;OAIG;IACH,YAAY,YAAoC,EAAE,YAA2B;QAC3E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,IAAI,KAAK,KAAK,IAAI;YACvC,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAU,CAAC;QAEzC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApED,4DAoEC","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 Diagnostic\r\n */\r\n\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { AnyDiagnostic } from \"./Diagnostic\";\r\n\r\nimport assert = require(\"assert\");\r\n\r\nconst translationNamespace = \"ECSchemaMetaData\";\r\nconst subTranslationNamespace = \"Diagnostics\";\r\nconst baseTranslationKey = `${translationNamespace}:${subTranslationNamespace}`;\r\n\r\n/**\r\n * Interface used to report [[IDiagnostic]] objects created during schema validation.\r\n * @beta\r\n */\r\nexport interface IDiagnosticReporter {\r\n /**\r\n * A map where the key is a schema full name and the value is a collection\r\n * of diagnostics codes identifying which rules violations to ignore during validation.\r\n */\r\n suppressions?: Map<string, string[]>;\r\n\r\n /** The localization object to use for message translation. */\r\n localization?: Localization;\r\n\r\n /**\r\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\r\n * given reporter.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n report(diagnostic: AnyDiagnostic): void;\r\n}\r\n\r\n/**\r\n * An abstract base class for [[IDiagnosticReporter]] implementation that used the\r\n * provided Map to suppress certain rule violations from being reported. The Map's key\r\n * a schema full name, and the Map's value is a collection of rule codes to suppress.\r\n * @beta\r\n */\r\nexport abstract class SuppressionDiagnosticReporter implements IDiagnosticReporter {\r\n private _suppressions?: Map<string, string[]>;\r\n\r\n /**\r\n * Initializes a new SuppressionDiagnosticReporter\r\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\r\n */\r\n constructor(suppressions?: Map<string, string[]>) {\r\n this._suppressions = suppressions;\r\n }\r\n\r\n /**\r\n * Gets the collection of ISchemaDiagnosticSuppression objects that identify\r\n * rules violations to ignore during validation.\r\n */\r\n public get suppressions(): Map<string, string[]> | undefined {\r\n return this._suppressions;\r\n }\r\n\r\n /**\r\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\r\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n public report(diagnostic: AnyDiagnostic) {\r\n if (this._suppressions && this._suppressions.has(diagnostic.schema.fullName)) {\r\n const suppressedCodes = this._suppressions.get(diagnostic.schema.fullName);\r\n if (suppressedCodes!.includes(diagnostic.code))\r\n return;\r\n }\r\n\r\n this.reportInternal(diagnostic);\r\n }\r\n\r\n /**\r\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\r\n * given reporter.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n protected abstract reportInternal(diagnostic: AnyDiagnostic): void;\r\n}\r\n\r\n/**\r\n * An abstract [[SuppressionDiagnosticReporter]] implementation that formats the\r\n * diagnostic message with the message args. If a Localization implementation is specified,\r\n * the message will also be translated.\r\n * @beta\r\n */\r\nexport abstract class FormatDiagnosticReporter extends SuppressionDiagnosticReporter {\r\n /**\r\n * Initializes a new FormatDiagnosticReporter\r\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\r\n * @param localization The Localization instance to use to translate validation messages.\r\n */\r\n constructor(suppressions?: Map<string, string[]>, localization?: Localization) {\r\n super(suppressions);\r\n this.localization = localization;\r\n }\r\n\r\n /** The Localization object to use for message translation. If undefined, no translation will occur. */\r\n public localization?: Localization;\r\n\r\n /**\r\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\r\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n public reportInternal(diagnostic: AnyDiagnostic) {\r\n const message = this.formatMessage(diagnostic);\r\n this.reportDiagnostic(diagnostic, message);\r\n }\r\n\r\n /**\r\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\r\n * given reporter.\r\n * @param diagnostic The diagnostic to report.\r\n * @param messageText The formatted message.\r\n */\r\n protected abstract reportDiagnostic(diagnostic: AnyDiagnostic, messageText: string): void;\r\n\r\n /**\r\n * Helper method that formats string with provided arguments where the place holders\r\n * are in the the format '{0}', '{1}', etc.\r\n * @param text The text to format.\r\n * @param args The arguments to place in the text.\r\n * @param baseIndex The base index for the args, used for validation (typically 0, which is the default).\r\n */\r\n protected formatStringFromArgs(text: string, args: ArrayLike<string>, baseIndex = 0): string {\r\n return text.replace(/{(\\d+)}/g, (_match, index: string) => this.assertDefined(args[+index + baseIndex]));\r\n }\r\n\r\n private formatMessage(diagnostic: AnyDiagnostic): string {\r\n let translatedMessage = this.translateMessage(diagnostic);\r\n\r\n if (diagnostic.messageArgs && diagnostic.messageArgs.length > 0)\r\n translatedMessage = this.formatStringFromArgs(translatedMessage, diagnostic.messageArgs);\r\n return translatedMessage;\r\n }\r\n\r\n private translateMessage(diagnostic: AnyDiagnostic): string {\r\n if (!this.localization)\r\n return diagnostic.messageText;\r\n\r\n return this.localization.getLocalizedString(this.getTranslationKey(diagnostic));\r\n }\r\n\r\n private getTranslationKey(diagnostic: AnyDiagnostic): string {\r\n return `${baseTranslationKey}.${diagnostic.code}`;\r\n }\r\n\r\n private assertDefined<T>(value: T | null | undefined, message?: string): T {\r\n if (value === undefined || value === null)\r\n return assert(false, message) as never;\r\n\r\n return value;\r\n }\r\n}\r\n"]}
|