@itwin/ecschema-editing 5.4.0-dev.6 → 5.4.0-dev.7
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 +11 -1
- package/lib/cjs/Differencing/Errors.js.map +1 -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/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Differencing/Utils.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/Exception.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/MutableNavigationProperty.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/MutableSchemaItem.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableStructProperty.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/Properties.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/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/NameMapping.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.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/EnumeratorMerger.js.map +1 -1
- package/lib/cjs/Merging/FormatMerger.js.map +1 -1
- package/lib/cjs/Merging/InvertedUnitMerger.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/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.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/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.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/lib/esm/Differencing/Errors.js.map +1 -1
- package/lib/esm/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/esm/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifference.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/esm/Differencing/Utils.js.map +1 -1
- package/lib/esm/Editing/Constants.js.map +1 -1
- package/lib/esm/Editing/CustomAttributes.js.map +1 -1
- package/lib/esm/Editing/ECClasses.js.map +1 -1
- package/lib/esm/Editing/Editor.js.map +1 -1
- package/lib/esm/Editing/Entities.js.map +1 -1
- package/lib/esm/Editing/Enumerations.js.map +1 -1
- package/lib/esm/Editing/Exception.js.map +1 -1
- package/lib/esm/Editing/Formats.js.map +1 -1
- package/lib/esm/Editing/InvertedUnits.js.map +1 -1
- package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
- package/lib/esm/Editing/Mixins.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableArrayProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableSchemaItem.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableStructProperty.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/esm/Editing/Phenomena.js.map +1 -1
- package/lib/esm/Editing/Properties.js.map +1 -1
- package/lib/esm/Editing/PropertyCategories.js.map +1 -1
- package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
- package/lib/esm/Editing/SchemaItems.js.map +1 -1
- package/lib/esm/Editing/Structs.js.map +1 -1
- package/lib/esm/Editing/UnitSystems.js.map +1 -1
- package/lib/esm/Editing/Units.js.map +1 -1
- package/lib/esm/Merging/ClassMerger.js.map +1 -1
- package/lib/esm/Merging/ConstantMerger.js.map +1 -1
- package/lib/esm/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/esm/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/esm/Merging/Edits/NameMapping.js.map +1 -1
- package/lib/esm/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/esm/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/esm/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/lib/esm/Merging/EntityClassMerger.js.map +1 -1
- package/lib/esm/Merging/EnumerationMerger.js.map +1 -1
- package/lib/esm/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/esm/Merging/FormatMerger.js.map +1 -1
- package/lib/esm/Merging/InvertedUnitMerger.js.map +1 -1
- package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/esm/Merging/MixinMerger.js.map +1 -1
- package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/esm/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/esm/Merging/PropertyMerger.js.map +1 -1
- package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/esm/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/esm/Merging/StructClassMerger.js.map +1 -1
- package/lib/esm/Merging/UnitMerger.js.map +1 -1
- package/lib/esm/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/esm/Merging/Utils.js.map +1 -1
- package/lib/esm/Validation/Diagnostic.js.map +1 -1
- package/lib/esm/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/esm/Validation/ECRules.js.map +1 -1
- package/lib/esm/Validation/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/esm/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/esm/Validation/Rules.js.map +1 -1
- package/lib/esm/Validation/SchemaChanges.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/esm/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/esm/Validation/SchemaComparer.js.map +1 -1
- package/lib/esm/Validation/SchemaValidater.js.map +1 -1
- package/lib/esm/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/esm/Validation/SchemaWalker.js.map +1 -1
- package/lib/esm/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":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;AAeA,oDAuBC;AAMD,0DAyBC;AAOD,kE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AiB,CAAC,IAAI,CAAC,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport type { RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\r\nimport { locateSchemaItem, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECClass, EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new RelationshipClass into the target schema.\r\n * @internal\r\n */\r\nexport async function addRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference) {\r\n if (change.difference.strength === undefined) {\r\n throw new Error(\"RelationshipClass must define strength\");\r\n }\r\n if (change.difference.strengthDirection === undefined) {\r\n throw new Error(\"RelationshipClass must define strengthDirection\");\r\n }\r\n if (change.difference.source === undefined) {\r\n throw new Error(\"RelationshipClass must define a source constraint\");\r\n }\r\n if (change.difference.target === undefined) {\r\n throw new Error(\"RelationshipClass must define a target constraint\");\r\n }\r\n\r\n await context.editor.relationships.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n strength: change.difference.strength,\r\n strengthDirection: change.difference.strengthDirection,\r\n source: await updateRelationshipConstraintKey(context, change.difference.source),\r\n target: await updateRelationshipConstraintKey(context, change.difference.target),\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing RelationshipClass in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableRelationshipClass;\r\n if(change.changeType === \"modify\") {\r\n if(change.difference.strength !== undefined) {\r\n if (item.strength === undefined) {\r\n const strength = parseStrength(change.difference.strength);\r\n if (strength === undefined) {\r\n throw new Error(`An invalid relationship class strength value '${change.difference.strength}' has been provided.`);\r\n }\r\n item.setStrength(strength);\r\n }\r\n throw new Error(`Changing the relationship '${itemKey.name}' strength is not supported.`);\r\n }\r\n if(change.difference.strengthDirection !== undefined) {\r\n if (item.strengthDirection === undefined) {\r\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\r\n if (strengthDirection === undefined) {\r\n throw new Error(`An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.`);\r\n }\r\n item.setStrengthDirection(strengthDirection);\r\n }\r\n throw new Error(`Changing the relationship '${itemKey.name}' strengthDirection is not supported.`);\r\n }\r\n }\r\n await modifyClass(context, change, itemKey, item);\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint.\r\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\r\n if(change.changeType !== \"modify\") {\r\n throw new Error(\"RelationshipConstraints can only be modified.\");\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n if(change.difference.roleLabel !== undefined) {\r\n constraint.setRoleLabel(change.difference.roleLabel);\r\n }\r\n if(change.difference.polymorphic !== undefined) {\r\n await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\r\n }\r\n if(change.difference.multiplicity !== undefined) {\r\n if (constraint.multiplicity === undefined) {\r\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\r\n if (multiplicity === undefined) {\r\n throw new Error(`An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.`);\r\n }\r\n await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\r\n }\r\n throw new Error(`Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.`);\r\n }\r\n if(change.difference.abstractConstraint !== undefined) {\r\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\r\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey, ECClass);\r\n if (abstractConstraint === undefined || (!EntityClass.isEntityClass(abstractConstraint) && !Mixin.isMixin(abstractConstraint) && !RelationshipClass.isRelationshipClass(abstractConstraint))) {\r\n throw new Error(`Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`);\r\n }\r\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\r\n }\r\n return { itemKey: constraint.relationshipClass.key };\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {\r\n if(change.changeType !== \"add\") {\r\n throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n for(const constraintName of change.difference) {\r\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\r\n const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey, ECClass);\r\n if(constraintClass === undefined || (!EntityClass.isEntityClass(constraintClass) && !Mixin.isMixin(constraintClass) && !RelationshipClass.isRelationshipClass(constraintClass))) {\r\n throw new Error(`Could not locate relationship constraint class ${constraintClassKey.name}`);\r\n }\r\n\r\n await context.editor.relationships.addConstraintClass(constraint, constraintClass);\r\n }\r\n}\r\n\r\nfunction parseConstraint(path: string): \"source\" | \"target\" {\r\n return path.startsWith(\"$source\")\r\n ? \"source\"\r\n : \"target\";\r\n}\r\n\r\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\r\n let abstractConstraint = props.abstractConstraint;\r\n if (abstractConstraint !== undefined)\r\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\r\n\r\n const constraintClasses: string[] = [];\r\n for (const ecClass of props.constraintClasses) {\r\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\r\n }\r\n\r\n return {\r\n ...props,\r\n abstractConstraint,\r\n constraintClasses,\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;AAeA,oDAuBC;AAMD,0DAyBC;AAOD,kEAgCC;AAMD,4EAgBC;AA5HD,mCAA0F;AAC1F,+CAA4C;AAE5C,gEAAuN;AAEvN;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,MAAmC;IACzG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI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I,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IACrF,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAC/B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC;AAED,KAAK,UAAU,+BAA+B,CAAC,OAA2B,EAAE,KAAkC;IAC5G,IAAI,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IAClD,IAAI,kBAAkB,KAAK,SAAS;QAClC,kBAAkB,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAEnF,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9C,iBAAiB,CAAC,IAAI,CAAC,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,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 type { RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\nimport { locateSchemaItem, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new RelationshipClass into the target schema.\n * @internal\n */\nexport async function addRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference) {\n if (change.difference.strength === undefined) {\n throw new Error(\"RelationshipClass must define strength\");\n }\n if (change.difference.strengthDirection === undefined) {\n throw new Error(\"RelationshipClass must define strengthDirection\");\n }\n if (change.difference.source === undefined) {\n throw new Error(\"RelationshipClass must define a source constraint\");\n }\n if (change.difference.target === undefined) {\n throw new Error(\"RelationshipClass must define a target constraint\");\n }\n\n await context.editor.relationships.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n strength: change.difference.strength,\n strengthDirection: change.difference.strengthDirection,\n source: await updateRelationshipConstraintKey(context, change.difference.source),\n target: await updateRelationshipConstraintKey(context, change.difference.target),\n });\n}\n\n/**\n * Merges differences to an existing RelationshipClass in the target schema.\n * @internal\n */\nexport async function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableRelationshipClass;\n if(change.changeType === \"modify\") {\n if(change.difference.strength !== undefined) {\n if (item.strength === undefined) {\n const strength = parseStrength(change.difference.strength);\n if (strength === undefined) {\n throw new Error(`An invalid relationship class strength value '${change.difference.strength}' has been provided.`);\n }\n item.setStrength(strength);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strength is not supported.`);\n }\n if(change.difference.strengthDirection !== undefined) {\n if (item.strengthDirection === undefined) {\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\n if (strengthDirection === undefined) {\n throw new Error(`An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.`);\n }\n item.setStrengthDirection(strengthDirection);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strengthDirection is not supported.`);\n }\n }\n await modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges differences of a Relationship constraint.\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\n * @internal\n */\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\n if(change.changeType !== \"modify\") {\n throw new Error(\"RelationshipConstraints can only be modified.\");\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n if(change.difference.roleLabel !== undefined) {\n constraint.setRoleLabel(change.difference.roleLabel);\n }\n if(change.difference.polymorphic !== undefined) {\n await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\n }\n if(change.difference.multiplicity !== undefined) {\n if (constraint.multiplicity === undefined) {\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\n if (multiplicity === undefined) {\n throw new Error(`An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.`);\n }\n await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\n }\n throw new Error(`Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.`);\n }\n if(change.difference.abstractConstraint !== undefined) {\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey, ECClass);\n if (abstractConstraint === undefined || (!EntityClass.isEntityClass(abstractConstraint) && !Mixin.isMixin(abstractConstraint) && !RelationshipClass.isRelationshipClass(abstractConstraint))) {\n throw new Error(`Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`);\n }\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\n }\n return { itemKey: constraint.relationshipClass.key };\n}\n\n/**\n * Merges differences of a Relationship constraint classes.\n * @internal\n */\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {\n if(change.changeType !== \"add\") {\n throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n for(const constraintName of change.difference) {\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\n const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey, ECClass);\n if(constraintClass === undefined || (!EntityClass.isEntityClass(constraintClass) && !Mixin.isMixin(constraintClass) && !RelationshipClass.isRelationshipClass(constraintClass))) {\n throw new Error(`Could not locate relationship constraint class ${constraintClassKey.name}`);\n }\n\n await context.editor.relationships.addConstraintClass(constraint, constraintClass);\n }\n}\n\nfunction parseConstraint(path: string): \"source\" | \"target\" {\n return path.startsWith(\"$source\")\n ? \"source\"\n : \"target\";\n}\n\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\n let abstractConstraint = props.abstractConstraint;\n if (abstractConstraint !== undefined)\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\n\n const constraintClasses: string[] = [];\n for (const ecClass of props.constraintClasses) {\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\n }\n\n return {\n ...props,\n abstractConstraint,\n constraintClasses,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAAqG;AACrG,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AAclD;;;;GAIG;AACH,MAAa,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,YAAY,CAAC,YAAoB,EAAE,YAAoB,EAAE,KAAmB;QACvF,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AAQ;YACrC,aAAa,GAAG,IAAI,iCAAa,CAAC,cAAwB,EAAE,IAAI,6BAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAG,SAAS,KAAK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAAqG;AACrG,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AAclD;;;;GAIG;AACH,MAAa,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,YAAY,CAAC,YAAoB,EAAE,YAAoB,EAAE,KAAmB;QACvF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,uCAAoB,EAAC,YAAY,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,gBAAwC,EAAE,KAAmB;QAC9E,MAAM,eAAe,GAAG,6BAAS,CA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AK,SAAS,EAAE,CAAC;YAC3B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAG,eAAe,KAAK,SAAS;YAC9B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","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, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\nimport { NameMapping } from \"./Edits/NameMapping\";\n\n/**\n * Defines the context of a Schema merging run.\n * @internal\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly targetSchemaKey: SchemaKey;\n readonly sourceSchemaKey: SchemaKey;\n readonly editor: SchemaContextEditor;\n readonly nameMapping: NameMapping;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\n * @beta\n */\nexport class SchemaMerger {\n\n private readonly _editingContext: SchemaContext;\n\n /**\n * Constructs a new instance of the SchemaMerger object.\n * @param editingContext The schema contexts that holds the schema to be edited.\n */\n constructor(editingContext: SchemaContext) {\n this._editingContext = editingContext;\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 * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @returns The merged target schema.\n * @alpha\n */\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\n }\n\n /**\n * Merges the schema differences into the target schema context.\n * @param differenceResult The differences that shall be applied to the target schema.\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\n * @alpha\n */\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\n\n const nameMapping = new NameMapping();\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\n\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\n // to prevent altering the differenceResult the caller passed in.\n if (edits) {\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\n }\n\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\n throw new SchemaConflictsError(\n \"Schema's can't be merged if there are unresolved conflicts.\",\n differenceResult.conflicts,\n sourceSchemaKey,\n targetSchemaKey,\n );\n }\n\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\n }\n throw error;\n });\n\n if (!schema.isDynamic) {\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\n }\n\n const visitor = new SchemaMergingVisitor({\n editor,\n targetSchema: schema,\n targetSchemaKey,\n sourceSchemaKey,\n nameMapping,\n });\n\n const walker = new SchemaMergingWalker(visitor);\n await walker.traverse(differenceResult.differences, \"add\");\n await walker.traverse(differenceResult.differences, \"modify\");\n\n return schema;\n }\n}\n\n/**\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\n * for certain schema elements during the schema merging process.\n *\n * @internal\n */\nclass MergingSchemaContext extends SchemaContext {\n private _internalContext: SchemaContext;\n private _nameMappings: NameMapping;\n\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\n super();\n this._internalContext = internalContext;\n this._nameMappings = nameMapping;\n }\n\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getCachedSchema(schemaKey, matchType);\n }\n\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\n return this._internalContext.getSchema(schemaKey, matchType);\n }\n\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\n let schemaItemKey: SchemaItemKey;\n if (typeof schemaNameOrKey === \"string\")\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\n else\n schemaItemKey = schemaNameOrKey;\n\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\n if(mappedKey !== undefined) {\n schemaItemKey = mappedKey as SchemaItemKey;\n }\n\n if(itemConstructor === undefined)\n return this._internalContext.getSchemaItem(schemaItemKey);\n\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":";;;AAWA,qDAA+D;AAC/D,mEAA6D;AAC7D,6EAAmG;AACnG,2DAAwF;AACxF,2DAAwE;AACxE,yDAAqE;AACrE,iEAAwG;AACxG,+CAAgE;AAChE,yDAAqE;AACrE,qEAAuF;AACvF,u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,oBAAO;YACZ,MAAM,EAAE,uBAAU;SACnB,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,yBAAyB,CAAC,KAA2B;QAChE,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,gCAAa;YAClB,MAAM,EAAE,mCAAgB;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;;MAGE;IACK,KAAK,CAAC,+CAA+C,CAAC,KAAiD;QAC5G,QAAO,KAAK,CAAC,UAAU,EAAE,CAAC;YACxB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAA,4CAAqB,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAA,iBAAS,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;CACF;AAzUD,oDAyUC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, \r\n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, \r\n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, \r\n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, \r\n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, \r\n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, \r\n StructClassDifference, UnitDifference, UnitSystemDifference } from \"../Differencing/SchemaDifference\";\r\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\r\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\r\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\r\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\r\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\r\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\r\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\r\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\r\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\r\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\r\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\r\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\r\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\r\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\r\nimport { mergePropertyDifference } from \"./PropertyMerger\";\r\nimport { isClassDifference } from \"../Differencing/Utils\";\r\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { toItemKey } from \"./Utils\";\r\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\r\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\r\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\r\n\r\n/** Definition of schema items change type handler array. */\r\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\r\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\r\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\r\n * differences to call the appropriated merger methods.\r\n * @internal\r\n */\r\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\r\n\r\n private readonly _context: SchemaMergeContext;\r\n\r\n /**\r\n * Initializes a new instance of SchemaMergingVisitor class.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: async (context) => {\r\n // To add classes a slightly different approach is done. In fact the class entries gets processed\r\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\r\n // the class gets completed with all properties, mixins, etc...\r\n if(entry.changeType === \"add\" && !await context.targetSchema.getItem(entry.itemName)) {\r\n await handler.add(this._context, {\r\n ...entry,\r\n difference: {\r\n ...entry.difference,\r\n // Remove everything we want to validate before setting, this is done in the second iteration.\r\n baseClass: undefined,\r\n mixins: undefined,\r\n properties: undefined,\r\n customAttributes: undefined,\r\n },\r\n });\r\n\r\n // Searches for the last class difference and adds the entry after it. That way,\r\n // the class is completed before class related entries get processed.\r\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\r\n array.splice(insertIndex, 0, entry);\r\n\r\n return;\r\n }\r\n\r\n // Now both a modification change or the second add iteration is a modification of an existing class.\r\n // So, regardless of the actual change type, modify is called.\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n },\r\n modify: handler.modify,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ConstantDifference.\r\n * @internal\r\n */\r\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeClassDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addCustomAttributeClass,\r\n modify: modifyCustomAttributeClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addEntityClass,\r\n modify: modifyEntityClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassMixinDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumerationDifference.\r\n * @internal\r\n */\r\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumeratorDifference.\r\n * @internal\r\n */\r\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addEnumerator(this._context, entry);\r\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling MixinClassDifference.\r\n * @internal\r\n */\r\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addMixinClass,\r\n modify: modifyMixinClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PhenomenonDifference.\r\n * @internal\r\n */\r\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PropertyCategoryDifference.\r\n * @internal\r\n */\r\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ClassPropertyDifference.\r\n * @internal\r\n */\r\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\r\n await mergePropertyDifference(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addRelationshipClass,\r\n modify: modifyRelationshipClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\r\n await mergeRelationshipClassConstraint(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\r\n await mergeRelationshipConstraint(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference({ difference }: SchemaDifference): Promise<void> {\r\n if (difference.label !== undefined) {\r\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\r\n }\r\n if (difference.description !== undefined) {\r\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\r\n }\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\r\n switch(entry.changeType) {\r\n case \"add\": {\r\n return handler.add(this._context, entry);\r\n }\r\n case \"modify\": {\r\n if(\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\r\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\r\n }\r\n\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaReferenceDifference.\r\n * @internal\r\n */\r\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addSchemaReferences(this._context, entry);\r\n case \"modify\": return modifySchemaReferences(this._context, entry);\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling StructClassDifference.\r\n * @internal\r\n */\r\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addStructClass,\r\n modify: modifyStructClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitDifference.\r\n * @internal\r\n */\r\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitSystemDifference.\r\n * @internal\r\n */\r\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\r\n switch(entry.changeType) {\r\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\r\n * @param array Array to search.\r\n * @param predicate Function to execute on each value in the array.\r\n * @param fromIndex The index to start the search at.\r\n * @returns An index in the array if an element passes the test; otherwise, false.\r\n */\r\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\r\n for (let i = fromIndex; i < array.length; i++) {\r\n if (predicate(array[i]))\r\n return i;\r\n }\r\n return false;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":";;;AAWA,qDAA+D;AAC/D,mEAA6D;AAC7D,6EAAmG;AACnG,2DAAwF;AACxF,2DAAwE;AACxE,yDAAqE;AACrE,iEAAwG;AACxG,+CAAgE;AAChE,yDAAqE;AACrE,qEAAuF;AACvF,uEAAyJ;AACzJ,mEAAsF;AACtF,2DAAwE;AACxE,yDAAqE;AACrE,qDAA2D;AAC3D,iDAA0D;AAI1D,mCAAoC;AACpC,6CAAmD;AACnD,6DAA2E;AAC3E,iDAAkG;AAQlG;;;;GAIG;AACH,MAAa,oBAAoB;IAEd,QAAQ,CAAqB;IAE9C;;OAEG;IACH,YAAY,OAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,oBAAoB,CAAmC,KAAQ,EAAE,KAAa,EAAE,KAA4B,EAAE,OAAiC;QAC3J,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBACrB,iGAAiG;gBACjG,mGAAmG;gBACn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;QAC3G,CAAC;IACH,CAAC;CACF;AAzUD,oDAyUC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, \n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, \n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, \n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, \n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, \n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, \n StructClassDifference, UnitDifference, UnitSystemDifference } from \"../Differencing/SchemaDifference\";\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\nimport { mergePropertyDifference } from \"./PropertyMerger\";\nimport { isClassDifference } from \"../Differencing/Utils\";\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { toItemKey } from \"./Utils\";\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\n\n/** Definition of schema items change type handler array. */\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\n}\n\n/**\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\n * differences to call the appropriated merger methods.\n * @internal\n */\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\n\n private readonly _context: SchemaMergeContext;\n\n /**\n * Initializes a new instance of SchemaMergingVisitor class.\n */\n constructor(context: SchemaMergeContext) {\n this._context = context;\n }\n\n /**\n * Shared merging logic for all types of ClassItemDifference union.\n */\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\n return this.visitSchemaItemDifference(entry, {\n add: async (context) => {\n // To add classes a slightly different approach is done. In fact the class entries gets processed\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\n // the class gets completed with all properties, mixins, etc...\n if(entry.changeType === \"add\" && !await context.targetSchema.getItem(entry.itemName)) {\n await handler.add(this._context, {\n ...entry,\n difference: {\n ...entry.difference,\n // Remove everything we want to validate before setting, this is done in the second iteration.\n baseClass: undefined,\n mixins: undefined,\n properties: undefined,\n customAttributes: undefined,\n },\n });\n\n // Searches for the last class difference and adds the entry after it. That way,\n // the class is completed before class related entries get processed.\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\n array.splice(insertIndex, 0, entry);\n\n return;\n }\n\n // Now both a modification change or the second add iteration is a modification of an existing class.\n // So, regardless of the actual change type, modify is called.\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\n },\n modify: handler.modify,\n });\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addConstant,\n modify: modifyConstant,\n });\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addCustomAttributeClass,\n modify: modifyCustomAttributeClass,\n });\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addCustomAttribute(this._context, entry);\n }\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addEntityClass,\n modify: modifyEntityClass,\n });\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addClassMixins(this._context, entry);\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addEnumeration,\n modify: modifyEnumeration,\n });\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addEnumerator(this._context, entry);\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addFormat,\n modify: modifyFormat,\n });\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\n switch(entry.changeType) {\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\n switch(entry.changeType) {\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addInvertedUnit,\n modify: modifyInvertedUnit,\n });\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addKindOfQuantity,\n modify: modifyKindOfQuantity,\n });\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addMixinClass,\n modify: modifyMixinClass,\n });\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addPhenomenon,\n modify: modifyPhenomenon,\n });\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addPropertyCategory,\n modify: modifyPropertyCategory,\n });\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\n await mergePropertyDifference(this._context, entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addRelationshipClass,\n modify: modifyRelationshipClass,\n });\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\n await mergeRelationshipClassConstraint(this._context, entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\n await mergeRelationshipConstraint(this._context, entry);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference({ difference }: SchemaDifference): Promise<void> {\n if (difference.label !== undefined) {\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\n }\n if (difference.description !== undefined) {\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\n }\n }\n\n /**\n * Shared merging logic for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\n switch(entry.changeType) {\n case \"add\": {\n return handler.add(this._context, entry);\n }\n case \"modify\": {\n if(\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\n }\n\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\n };\n }\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addSchemaReferences(this._context, entry);\n case \"modify\": return modifySchemaReferences(this._context, entry);\n }\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\n return this.visitClassDifference(entry, index, array, {\n add: addStructClass,\n modify: modifyStructClass,\n });\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addUnit,\n modify: modifyUnit,\n });\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\n return this.visitSchemaItemDifference(entry, {\n add: addUnitSystem,\n modify: modifyUnitSystem,\n });\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\n switch(entry.changeType) {\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\n }\n }\n}\n\n/**\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\n * @param array Array to search.\n * @param predicate Function to execute on each value in the array.\n * @param fromIndex The index to start the search at.\n * @returns An index in the array if an element passes the test; otherwise, false.\n */\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\n for (let i = fromIndex; i < array.length; i++) {\n if (predicate(array[i]))\n return i;\n }\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0D;AAC1D,qFAAiF;AACjF,uEAAqH;AAErH;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,gDAAsB;IAE7D;;;;;;;OAOG;IACa,KAAK,CAAC,QAAQ,CAAC,WAAuC,EAAE,UAA2B;QAEjG,MAAM,YAAY,GAAG,CAAC,UAAsB,EAAE,EAAE;YAC9C,OAAO,CAAC,KAA0B,EAAE,EAAE;gBACpC,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;YAC7F,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC,QAAQ,CAAC;YACpB,wDAAwD;YACxD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,MAAM,CAAC,CAAC;YAC5D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,eAAe,CAAC,CAAC;YAErE,+CAA+C;YAC/C,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,UAAU,CAAC,CAAC;YAC9D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,gBAAgB,CAAC,CAAC;YACpE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CA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AiB,CAAC,CAAC;YACrE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,CAAC;YACtE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,sBAAsB,CAAC,CAAC;YAC5E,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF;AArDD,kDAqDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0D;AAC1D,qFAAiF;AACjF,uEAAqH;AAErH;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,gDAAsB;IAE7D;;;;;;;OAOG;IACa,KAAK,CAAC,QAAQ,CAAC,WAAuC,EAAE,UAA2B;QAEjG,MAAM,YAAY,GAAG,CAAC,UAAsB,EAAE,EAAE;YAC9C,OAAO,CAAC,KAA0B,EAAE,EAAE;gBACpC,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;YAC7F,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC,QAAQ,CAAC;YACpB,wDAAwD;YACxD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,MAAM,CAAC,CAAC;YAC5D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,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AAC,YAAY,CAAC,kCAAc,CAAC,KAAK,CAAC,CAAC;YACzD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,iBAAiB,CAAC,CAAC;YACrE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,gBAAgB,CAAC,CAAC;YACtE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,sBAAsB,CAAC,CAAC;YAC5E,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF;AArDD,kDAqDC","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 { SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { SchemaDifferenceWalker } from \"../Differencing/SchemaDifferenceVisitor\";\nimport { AnySchemaDifference, DifferenceType, SchemaOtherTypes, SchemaType } from \"../Differencing/SchemaDifference\";\n\n/**\n * A walker that traverses the schema differences in a certain oder and invokes the appropriate\n * visitor method for each kind of schema difference.\n * @internal\n */\nexport class SchemaMergingWalker extends SchemaDifferenceWalker {\n\n /**\n * Traverses the schema differences and calls the appropriate method on the visitor.\n * This method overrides the derived class method to apply some ordering how the\n * differences are traversed.\n *\n * @param differences The differences to traverse.\n * @param changeType Optional type of change to filter by.\n */\n public override async traverse(differences: Array<AnySchemaDifference>, changeType?: DifferenceType): Promise<void> {\n\n const filterByType = (schemaType: SchemaType) => {\n return (entry: AnySchemaDifference) => {\n return entry.schemaType === schemaType && (!changeType || entry.changeType === changeType);\n };\n };\n\n return super.traverse([\n // First the schema related differences are traversed...\n ...differences.filter(filterByType(SchemaOtherTypes.Schema)),\n ...differences.filter(filterByType(SchemaOtherTypes.SchemaReference)),\n\n // Then the schema items (excluding classes)...\n ...differences.filter(filterByType(SchemaItemType.UnitSystem)),\n ...differences.filter(filterByType(SchemaItemType.PropertyCategory)),\n ...differences.filter(filterByType(SchemaItemType.Enumeration)),\n ...differences.filter(filterByType(SchemaOtherTypes.Enumerator)),\n ...differences.filter(filterByType(SchemaItemType.Phenomenon)),\n ...differences.filter(filterByType(SchemaItemType.Unit)),\n ...differences.filter(filterByType(SchemaItemType.InvertedUnit)),\n ...differences.filter(filterByType(SchemaItemType.Format)),\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnit)),\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnitLabel)),\n ...differences.filter(filterByType(SchemaItemType.KindOfQuantity)),\n ...differences.filter(filterByType(SchemaItemType.Constant)),\n ...differences.filter(filterByType(SchemaOtherTypes.KindOfQuantityPresentationFormat)),\n\n // Followed by classes and class related differences...\n ...differences.filter(filterByType(SchemaItemType.CustomAttributeClass)),\n ...differences.filter(filterByType(SchemaItemType.Mixin)),\n ...differences.filter(filterByType(SchemaItemType.StructClass)),\n ...differences.filter(filterByType(SchemaItemType.EntityClass)),\n ...differences.filter(filterByType(SchemaItemType.RelationshipClass)),\n ...differences.filter(filterByType(SchemaOtherTypes.EntityClassMixin)),\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraint)),\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraintClass)),\n ...differences.filter(filterByType(SchemaOtherTypes.Property)),\n\n // And then the custom attributes.\n ...differences.filter(filterByType(SchemaOtherTypes.CustomAttributeInstance)),\n ]);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaReferenceMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":";;AAaA,kDAGC;AAMD,wDAgBC;AA/BD,gEAAyF;AAEzF;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,MAAiC;IACtG,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/G,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AACrF,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CAAC,OAA2B,EAAE,MAAiC;IACzG,MAAM,cAAc,GAAI,MAAM,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAW,CAAC;IAClG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,6BAAS,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,6BAAS,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtJ,IAAG,MAAM,KAAK,cAAc,CAAC,SAAS,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IAED,IAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,mCAAe,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,UAAU,CAAC,IAAI,gCAAgC,KAAK,CAAC,OAAO,QAAQ,MA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CAAC,GAAG,CAAC;QACrC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC;QACf,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACpB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SchemaReferenceMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":";;AAaA,kDAGC;AAMD,wDAgBC;AA/BD,gEAAyF;AAEzF;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,MAAiC;IACtG,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/G,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;AACrF,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CAAC,OAA2B,EAAE,MAAiC;IACzG,MAAM,cAAc,GAAI,MAAM,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAW,CAAC;IAClG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,6BAAS,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,6BAAS,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtJ,IAAG,MAAM,KAAK,cAAc,CAAC,SAAS,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IAED,IAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,mCAAe,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,yBAAyB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AC,IAAe,EAAE,KAAgB;IACpD,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC;QACrC,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 type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaReferenceDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaContextEditor } from \"../Editing/Editor\";\nimport { ECVersion, Schema, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new reference to an external schema into the target schema.\n * @internal\n */\nexport async function addSchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\n await context.editor.addSchemaReference(context.targetSchemaKey, referencedSchema);\n}\n\n/**\n * Merges differences to an existing schema references in the target schema.\n * @internal\n */\nexport async function modifySchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\n const existingSchema = await context.targetSchema.getReference(change.difference.name) as Schema;\n const [older, latest] = sortSchemas(existingSchema.schemaKey, new SchemaKey(change.difference.name, ECVersion.fromString(change.difference.version)));\n if(latest === existingSchema.schemaKey) {\n return;\n }\n\n if(!latest.matches(older, SchemaMatchType.LatestWriteCompatible)) {\n throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version} and ${latest.version}`);\n }\n\n const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);\n context.targetSchema.references.splice(index, 1);\n\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\n await context.editor.addSchemaReference(context.targetSchema.schemaKey, referencedSchema);\n}\n\n/**\n * Tries to locate the Schema in the current Context\n * @param editor Current editor context.\n * @param schemaName The schema name to be looked up.\n * @param version The schemas version to beo looked up.\n * @returns The schema found in the context.\n */\nasync function locateSchema(editor: SchemaContextEditor, schemaName?: string, version?: string): Promise<Schema> {\n if(schemaName === undefined || version === undefined) {\n throw new Error(\"Schema name and version must not be undefined.\");\n }\n\n const schemaKey = new SchemaKey(schemaName, ECVersion.fromString(version));\n const schema = await editor.schemaContext.getSchema(schemaKey, SchemaMatchType.LatestWriteCompatible);\n if(schema === undefined) {\n throw new Error(`Referenced schema ${schemaKey.toString()} could not be found in target context`);\n }\n return schema;\n}\n\n/**\n * Sorts the schemas and return them in order of their versions [older, latest].\n * @param left The first schema key to be added.\n * @param right The second schema key to be added.\n * @returns The schemas in order.\n */\nfunction sortSchemas(left: SchemaKey, right: SchemaKey): [SchemaKey, SchemaKey] {\n return left.compareByVersion(right) < 0\n ? [left, right]\n : [right, left];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":";;AAcA,wCAKC;AAMD,8CAGC;AApBD,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACpE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC5E,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":";;AAcA,wCAKC;AAMD,8CAGC;AApBD,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACpE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC5E,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,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 type { StructClassDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableClass } from \"../Editing/Mutable/MutableClass\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Merges a new StructClass into the target schema.\n * @internal\n */\nexport async function addStructClass(context: SchemaMergeContext, change: StructClassDifference) {\n await context.editor.structs.createFromProps(context.targetSchemaKey, {\n name: change.itemName,\n ...change.difference,\n });\n}\n\n/**\n * Merges differences to an existing StructClass in the target schema.\n * @internal\n */\nexport async function modifyStructClass(context: SchemaMergeContext, change: StructClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableClass;\n return modifyClass(context, change, itemKey, item);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitMerger.ts"],"names":[],"mappings":";;AAaA,0BAsBC;AAMD,gCA2BC;AA7DD,mCAAmD;AAEnD;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAC,OAA2B,EAAE,MAAsB;IAC/E,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrG,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAErG,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAClE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CA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,KAAK,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACpF,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"UnitMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitMerger.ts"],"names":[],"mappings":";;AAaA,0BAsBC;AAMD,gCA2BC;AA7DD,mCAAmD;AAEnD;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAC,OAA2B,EAAE,MAAsB;IAC/E,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrG,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAErG,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAClE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,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A4B,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACpF,CAAC;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*--------------------------------------------------------------------------------------------*/\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { UnitDifference } from \"../Differencing/SchemaDifference\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName } from \"./Utils\";\n\n/**\n * Merges a new Unit into the target schema.\n * @internal\n */\nexport async function addUnit(context: SchemaMergeContext, change: UnitDifference) {\n if (change.difference.phenomenon === undefined) {\n throw new Error(\"Unit must define phenomenon\");\n }\n if (change.difference.unitSystem === undefined) {\n throw new Error(\"Unit must define unitSystem\");\n }\n if (change.difference.definition === undefined) {\n throw new Error(\"Unit must define definition\");\n }\n\n change.difference.phenomenon = await updateSchemaItemFullName(context, change.difference.phenomenon);\n change.difference.unitSystem = await updateSchemaItemFullName(context, change.difference.unitSystem);\n\n await context.editor.units.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n phenomenon: change.difference.phenomenon,\n unitSystem: change.difference.unitSystem,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Unit in the target schema.\n * @internal\n */\nexport async function modifyUnit(context: SchemaMergeContext, change: UnitDifference, itemKey: SchemaItemKey) {\n if (change.difference.unitSystem !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' unitSystem is not supported.`);\n }\n if (change.difference.phenomenon !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' phenomenon is not supported.`);\n }\n if (change.difference.definition !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' definition is not supported.`);\n }\n // we have consider later should we allow to change these values on merging\n if (change.difference.denominator !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' denominator is not supported.`);\n }\n if (change.difference.numerator !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' numerator is not supported.`);\n }\n if (change.difference.offset !== undefined) {\n throw new Error(`Changing the unit '${change.itemName}' offset is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.units.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.units.setDescription(itemKey, change.difference.description);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":";;AAYA,sCAMC;AAMD,4CAOC;AAvBD;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":";;AAYA,sCAMC;AAMD,4CAOC;AAvBD;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;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*--------------------------------------------------------------------------------------------*/\nimport type { UnitSystemDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new UnitSystem into the target schema.\n * @internal\n */\nexport async function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference) {\n await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n });\n}\n\n/**\n * Merges differences to an existing UnitSystem in the target schema.\n * @internal\n */\nexport async function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey) {\n if(change.difference.label !== undefined) {\n await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.unitSystems.setDescription(itemKey, change.difference.description);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":";;AAaA,8BAGC;AAMD,sCAGC;AAMD,4DAGC;AAOD,kDAaC;AAmBD,4CAQC;AAKD,wCAmBC;AApGD,qDAAkD;AAElD,gEAA4I;AAE5I;;;GAGG;AACH,SAAgB,SAAS,CAAC,OAA2B,EAAE,QAAgB;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1G,OAAO,IAAI,iCAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAA2B,EAAE,QAAgB,EAAE,YAAoB;IAC/F,MAAM,QAAQ,GAAG,IAAI,i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AAgB,CAAC;QACzC,KAAK,kCAAc,CAAC,iBAAiB;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QACtC;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":";;AAaA,8BAGC;AAMD,sCAGC;AAMD,4DAGC;AAOD,kDAaC;AAmBD,4CAQC;AAKD,wCAmBC;AApGD,qDAAkD;AAElD,gEAA4I;AAE5I;;;GAGG;AACH,SAAgB,SAAS,CAAC,OAA2B,EAAE,QAAgB;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1G,OAAO,IAAI,iCAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAA2B,EAAE,QAAgB,EAAE,YAAoB;IAC/F,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,yBAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzF,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,SAAiB;IAC3F,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,SAAiB;IACtF,MA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7B,MAAM,IAAI,iCAAa,CAAC,kCAAc,CAAC,aAAa,EAAE,GAAG,UAAU,IAAI,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;IAChI,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,OAAgC;IAChG,MAAM,cAAc,GAAG,2BAAO,CAAC,SAAS,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,OAAO,CAAC,cAAc;QACxB,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,OAAO,EAAE,2BAAO,CAAC,CAAC,EAAE,cAAc,CAAC;IAEzF,QAAO,cAAc,EAAE,CAAC;QACtB,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,KAAK,kCAAc,CAAC,KAAK;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,KAAK,kCAAc,CAAC,oBAAoB;YACtC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzC,KAAK,kCAAc,CAAC,iBAAiB;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QACtC;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;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*--------------------------------------------------------------------------------------------*/\nimport { ECClasses } from \"../Editing/ECClasses\";\nimport { PropertyKey } from \"./Edits/NameMapping\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, ECSchemaError, ECSchemaStatus, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Resolves a SchemaItemKey for the given item name.\n * @internal\n */\nexport function toItemKey(context: SchemaMergeContext, itemName: string): SchemaItemKey {\n const classKey = context.nameMapping.resolveItemKey(new SchemaItemKey(itemName, context.sourceSchemaKey));\n return new SchemaItemKey(classKey.name, context.targetSchemaKey);\n}\n\n/**\n * Resolves a SchemaItemKey for the given class property name.\n * @internal\n */\nexport function toPropertyKey(context: SchemaMergeContext, itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, context.sourceSchemaKey);\n return context.nameMapping.resolvePropertyKey(new PropertyKey(propertyName, classKey));\n}\n\n/**\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\n * @internal\n */\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\n const schemaItemKey = await updateSchemaItemKey(context, reference);\n return schemaItemKey.fullName;\n}\n\n/**\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\n * @internal\n */\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\n if (context.sourceSchemaKey.compareByName(schemaName)) {\n const schemaItemKey = toItemKey(context, itemName);\n return resolveSchemaItemKey(context.editor.schemaContext, schemaItemKey);\n }\n\n const referencedSchema = await context.targetSchema.getReference(schemaName);\n if (referencedSchema !== undefined) {\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\n }\n\n throw new Error(`Cannot locate referenced schema item ${reference}`);\n}\n\n/**\n * To support case insensitivity for schema items, the given key is checked if there\n * exists an item for it.\n * @internal\n */\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\n const item = await schemaContext.getSchemaItem(itemKey);\n if (item === undefined) {\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\n return itemKey;\n }\n return item.key;\n}\n\n/**\n * @internal\n */\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\n const schemaItemKey = toItemKey(context, itemName);\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined) {\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\n }\n\n return schemaItem;\n}\n\n/**\n * @internal\n */\nexport async function getClassEditor(context: SchemaMergeContext, ecClass: ECClass | SchemaItemKey): Promise<ECClasses> {\n const schemaItemType = ECClass.isECClass(ecClass)\n ? ecClass.schemaItemType\n : (await context.editor.schemaContext.getSchemaItem(ecClass, ECClass))?.schemaItemType;\n\n switch(schemaItemType) {\n case SchemaItemType.EntityClass:\n return context.editor.entities;\n case SchemaItemType.Mixin:\n return context.editor.mixins;\n case SchemaItemType.StructClass:\n return context.editor.structs;\n case SchemaItemType.CustomAttributeClass:\n return context.editor.customAttributes;\n case SchemaItemType.RelationshipClass:\n return context.editor.relationships;\n default:\n throw new Error(\"SchemaItemType not supported\");\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA6OH,kEAOC;AAQD,0EAMC;AAQD,gEAMC;AAQD,sEAOC;AAQD,kGAMC;AAQD,sGAMC;AAGD,gEAWC;AAGD,wDAeC;AAvVD,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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,CAAC,IAAI;YACtB,OAAO,MAAM,CAAC;QAChB,KAAK,cAAc,CAAC,QAAQ;YAC1B,OAAO,UAAU,CAAC;QACpB,KAAK,cAAc,CAAC,sBAAsB;YACxC,OAAO,wBAAwB,CAAC;QAClC,KAAK,cAAc,CAAC,MAAM;YACxB,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc,CAAC,UAAU;YAC5B,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,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":["/*---------------------------------------------------------------------------------------------\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,\r\n SchemaItem,\r\n Property,\r\n CustomAttributeContainer,\r\n RelationshipConstraint,\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
|
+
{"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA6OH,kEAOC;AAQD,0EAMC;AAQD,gEAMC;AAQD,sEAOC;AAQD,kGAMC;AAQD,sGAMC;AAGD,gEAWC;AAGD,wDAeC;AAvVD,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,8BAAd,cAAc,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,kCAAlB,kBAAkB,QAK7B;AA6BD;;;GAGG;AACH,MAAsB,cAAc;IAClC;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M,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,\n SchemaItem,\n Property,\n CustomAttributeContainer,\n RelationshipConstraint,\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticReporter.js","sourceRoot":"","sources":["../../../src/Validation/DiagnosticReporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,iCAAiC;AAEjC,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;IACzC,aAAa,CAAyB;IAE9C;;;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,CAAC;YAC7E,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;QACX,CAAC;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,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,I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I,KAAK,KAAK,IAAI;YACvC,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAU,CAAC;QAEzC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApED,4DAoEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"DiagnosticReporter.js","sourceRoot":"","sources":["../../../src/Validation/DiagnosticReporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,iCAAiC;AAEjC,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;IACzC,aAAa,CAAyB;IAE9C;;;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,CAAC;YAC7E,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;QACX,CAAC;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,KAAK,CAA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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 * as assert from \"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"]}
|