@itwin/ecschema-editing 4.9.0-dev.9 → 4.10.0-dev.1
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 +28 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +3 -2
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +3 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +0 -8
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +18 -151
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +3 -1
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +17 -0
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +450 -0
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts +29 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +82 -0
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -0
- package/lib/cjs/Editing/Editor.d.ts +6 -0
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +26 -0
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts +62 -58
- package/lib/cjs/Editing/Exception.d.ts.map +1 -1
- package/lib/cjs/Editing/Exception.js +65 -58
- package/lib/cjs/Editing/Exception.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +2 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts +7 -0
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +17 -0
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js +27 -45
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +4 -4
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/SchemaEdits.js +8 -8
- package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.js +4 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/package.json +10 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,uEAAoE;AAEpE,iEAA8D;AA4B9D;;;GAGG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;AACvC,CAAC,EATW,gBAAgB,gCAAhB,gBAAgB,QAS3B;AAiVD;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,YAAoB,EAAE,YAAoB;IACnF,MAAM,WAAW,GAAoB,EAAE,CAAC;IACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1F,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,IAAI,iDAAuB,EAAE,CAAC;IAC9C,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACvD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,WAAW,GAA0B;QACzC,GAAG,OAAO,CAAC,iBAAiB;QAC5B,GAAG,OAAO,CAAC,qBAAqB;QAChC,GAAG,OAAO,CAAC,yBAAyB;QACpC,GAAG,OAAO,CAAC,0BAA0B;KACtC,CAAC;IAEF,OAAO;QACL,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACvE,WAAW;KACZ,CAAC;AACJ,CAAC;AAvBD,oDAuBC","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 Differencing\r\n */\r\n\r\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\r\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\r\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\r\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\r\n} from \"@itwin/ecschema-metadata\";\r\n\r\n/** Utility-Type to remove possible readonly flags on the given type. */\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\r\n * that are not needed for the schema differencing. Also all properties are made mutable\r\n * by removing the readonly flag if present.\r\n */\r\ntype SchemaItemProperties<T extends SchemaItemProps> = {\r\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\r\n};\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @alpha\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines the SchemaTypes that are not SchemaItems.\r\n * @alpha\r\n */\r\nexport enum SchemaOtherTypes {\r\n Schema = \"Schema\",\r\n SchemaReference = \"SchemaReference\",\r\n Property = \"Property\",\r\n Enumerator = \"Enumerator\",\r\n CustomAttributeInstance = \"CustomAttributeInstance\",\r\n RelationshipConstraint = \"RelationshipConstraint\",\r\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\r\n EntityClassMixin = \"EntityClassMixin\",\r\n}\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @alpha\r\n */\r\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\r\n\r\n/**\r\n * Definition of the difference result between two Schemas.\r\n * @alpha\r\n */\r\nexport interface SchemaDifferenceResult {\r\n /** Full name of the source schema */\r\n readonly sourceSchemaName: string;\r\n /** Full name of the target schema */\r\n readonly targetSchemaName: string;\r\n\r\n /** List of differences between the compared schemas. */\r\n readonly differences: AnySchemaDifference[];\r\n\r\n /** List of conflicts found while comparing the schemas. */\r\n readonly conflicts?: SchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * Union of all supported schema differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaReferenceDifference |\r\n AnySchemaItemDifference |\r\n AnySchemaItemPathDifference |\r\n CustomAttributeDifference;\r\n\r\n/**\r\n * Differencing entry for changes on a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Schema;\r\n readonly difference: {\r\n label?: string;\r\n description?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Schema References of a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaReferenceDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.SchemaReference;\r\n readonly difference: SchemaReferenceProps;\r\n}\r\n\r\n/**\r\n * Union of all supported schema item differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemDifference =\r\n ClassItemDifference |\r\n ConstantDifference |\r\n EnumerationDifference |\r\n EntityClassMixinDifference |\r\n FormatDifference |\r\n KindOfQuantityDifference |\r\n InvertedUnitDifference |\r\n PhenomenonDifference |\r\n PropertyCategoryDifference |\r\n UnitDifference |\r\n UnitSystemDifference;\r\n\r\n/**\r\n * Union for supported class Schema Items.\r\n * @alpha\r\n */\r\nexport type ClassItemDifference =\r\n EntityClassDifference |\r\n MixinClassDifference |\r\n StructClassDifference |\r\n CustomAttributeClassDifference |\r\n RelationshipClassDifference;\r\n\r\n/**\r\n * Union of all differences that have a path pointing inside a schema item.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemPathDifference =\r\n RelationshipConstraintDifference |\r\n RelationshipConstraintClassDifference |\r\n CustomAttributePropertyDifference |\r\n EnumeratorDifference |\r\n ClassPropertyDifference;\r\n\r\n/**\r\n * Internal base class for all Schema Item differencing entries.\r\n * @alpha\r\n */\r\ninterface SchemaItemDifference<T extends SchemaItemProps> {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly itemName: string;\r\n readonly difference: SchemaItemProperties<T>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Constant Schema Items.\r\n * @alpha\r\n */\r\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\r\n readonly schemaType: SchemaItemType.Constant;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attribute Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\r\n readonly schemaType: SchemaItemType.CustomAttributeClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Entity Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\r\n readonly schemaType: SchemaItemType.EntityClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Enumerator Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\r\n readonly schemaType: SchemaItemType.Enumeration;\r\n}\r\n\r\n/**\r\n * Differencing entry for Kind-Of-Quantities Schema Items.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\r\n readonly schemaType: SchemaItemType.KindOfQuantity;\r\n}\r\n\r\n/**\r\n * Differencing entry for Mixin Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\r\n readonly schemaType: SchemaItemType.Mixin;\r\n}\r\n\r\n/**\r\n * Differencing entry for Phenomenon Schema Items.\r\n * @alpha\r\n */\r\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\r\n readonly schemaType: SchemaItemType.Phenomenon;\r\n}\r\n\r\n/**\r\n * Differencing entry for Property Category Schema Items.\r\n * @alpha\r\n */\r\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\r\n readonly schemaType: SchemaItemType.PropertyCategory;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\r\n readonly schemaType: SchemaItemType.RelationshipClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Struct Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\r\n readonly schemaType: SchemaItemType.StructClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit System Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\r\n readonly schemaType: SchemaItemType.UnitSystem;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\r\n readonly schemaType: SchemaItemType.Unit;\r\n}\r\n\r\n/**\r\n * Differencing entry for Inverted Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\r\n readonly schemaType: SchemaItemType.InvertedUnit;\r\n}\r\n/**\r\n * Differencing entry for Format Schema Items.\r\n * @alpha\r\n */\r\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\r\n readonly schemaType: SchemaItemType.Format;\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Properties.\r\n * @alpha\r\n */\r\nexport interface ClassPropertyDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Property;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyPropertyProps>;\r\n}\r\n\r\n/**\r\n * Union of supported Custom Attribute Differences.\r\n * @alpha\r\n */\r\nexport type CustomAttributeDifference =\r\n CustomAttributeSchemaDifference |\r\n CustomAttributeSchemaItemDifference |\r\n CustomAttributePropertyDifference |\r\n CustomAttributeRelationshipConstraintDifference;\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Schema\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaItemDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"SchemaItem\";\r\n readonly itemName: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Properties.\r\n * @alpha\r\n */\r\nexport interface CustomAttributePropertyDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Property\";\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeRelationshipConstraintDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"RelationshipConstraint\";\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for changed mixins on EntityClasses.\r\n * @alpha\r\n */\r\nexport interface EntityClassMixinDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumeratorDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Enumerator;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\r\n}\r\n\r\n/**\r\n * Differencing entry for constraint classes added to Relationship Constrains.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintClassDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Creates a [[SchemaDifferenceResult]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifferenceResult]] object.\r\n * @alpha\r\n */\r\nexport async function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferenceResult> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n const visitor = new SchemaDiagnosticVisitor();\r\n for (const diagnostic of changesList[0].allDiagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n const differences: AnySchemaDifference[] = [\r\n ...visitor.schemaDifferences,\r\n ...visitor.schemaItemDifferences,\r\n ...visitor.schemaItemPathDifferences,\r\n ...visitor.customAttributeDifferences,\r\n ];\r\n\r\n return {\r\n sourceSchemaName: sourceSchema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,\r\n differences,\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,uEAAoE;AAEpE,iEAA8D;AAO9D,2EAAkE;AAsBlE;;;GAGG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;AACvC,CAAC,EATW,gBAAgB,gCAAhB,gBAAgB,QAS3B;AAiVD;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,YAAoB,EAAE,YAAoB;IACnF,MAAM,WAAW,GAAoB,EAAE,CAAC;IACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1F,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,IAAI,iDAAuB,EAAE,CAAC;IAC9C,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACvD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,WAAW,GAA0B;QACzC,GAAG,OAAO,CAAC,iBAAiB;QAC5B,GAAG,OAAO,CAAC,qBAAqB;QAChC,GAAG,OAAO,CAAC,yBAAyB;QACpC,GAAG,OAAO,CAAC,0BAA0B;KACtC,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAA,+CAAmB,EAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAErF,OAAO;QACL,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACvD,WAAW;KACZ,CAAC;AACJ,CAAC;AAzBD,oDAyBC","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 Differencing\r\n */\r\n\r\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\r\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\r\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\r\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { validateDifferences } from \"./SchemaDifferenceValidator\";\r\n\r\n/** Utility-Type to remove possible readonly flags on the given type. */\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\r\n * that are not needed for the schema differencing. Also all properties are made mutable\r\n * by removing the readonly flag if present.\r\n */\r\ntype SchemaItemProperties<T extends SchemaItemProps> = {\r\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\r\n};\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @alpha\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines the SchemaTypes that are not SchemaItems.\r\n * @alpha\r\n */\r\nexport enum SchemaOtherTypes {\r\n Schema = \"Schema\",\r\n SchemaReference = \"SchemaReference\",\r\n Property = \"Property\",\r\n Enumerator = \"Enumerator\",\r\n CustomAttributeInstance = \"CustomAttributeInstance\",\r\n RelationshipConstraint = \"RelationshipConstraint\",\r\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\r\n EntityClassMixin = \"EntityClassMixin\",\r\n}\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @alpha\r\n */\r\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\r\n\r\n/**\r\n * Definition of the difference result between two Schemas.\r\n * @alpha\r\n */\r\nexport interface SchemaDifferenceResult {\r\n /** Full name of the source schema */\r\n readonly sourceSchemaName: string;\r\n /** Full name of the target schema */\r\n readonly targetSchemaName: string;\r\n\r\n /** List of differences between the compared schemas. */\r\n readonly differences: AnySchemaDifference[];\r\n\r\n /** List of conflicts found while comparing the schemas. */\r\n readonly conflicts?: SchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * Union of all supported schema differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaReferenceDifference |\r\n AnySchemaItemDifference |\r\n AnySchemaItemPathDifference |\r\n CustomAttributeDifference;\r\n\r\n/**\r\n * Differencing entry for changes on a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Schema;\r\n readonly difference: {\r\n label?: string;\r\n description?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Schema References of a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaReferenceDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.SchemaReference;\r\n readonly difference: SchemaReferenceProps;\r\n}\r\n\r\n/**\r\n * Union of all supported schema item differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemDifference =\r\n ClassItemDifference |\r\n ConstantDifference |\r\n EnumerationDifference |\r\n EntityClassMixinDifference |\r\n FormatDifference |\r\n KindOfQuantityDifference |\r\n InvertedUnitDifference |\r\n PhenomenonDifference |\r\n PropertyCategoryDifference |\r\n UnitDifference |\r\n UnitSystemDifference;\r\n\r\n/**\r\n * Union for supported class Schema Items.\r\n * @alpha\r\n */\r\nexport type ClassItemDifference =\r\n EntityClassDifference |\r\n MixinClassDifference |\r\n StructClassDifference |\r\n CustomAttributeClassDifference |\r\n RelationshipClassDifference;\r\n\r\n/**\r\n * Union of all differences that have a path pointing inside a schema item.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemPathDifference =\r\n RelationshipConstraintDifference |\r\n RelationshipConstraintClassDifference |\r\n CustomAttributePropertyDifference |\r\n EnumeratorDifference |\r\n ClassPropertyDifference;\r\n\r\n/**\r\n * Internal base class for all Schema Item differencing entries.\r\n * @alpha\r\n */\r\ninterface SchemaItemDifference<T extends SchemaItemProps> {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly itemName: string;\r\n readonly difference: SchemaItemProperties<T>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Constant Schema Items.\r\n * @alpha\r\n */\r\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\r\n readonly schemaType: SchemaItemType.Constant;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attribute Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\r\n readonly schemaType: SchemaItemType.CustomAttributeClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Entity Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\r\n readonly schemaType: SchemaItemType.EntityClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Enumerator Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\r\n readonly schemaType: SchemaItemType.Enumeration;\r\n}\r\n\r\n/**\r\n * Differencing entry for Kind-Of-Quantities Schema Items.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\r\n readonly schemaType: SchemaItemType.KindOfQuantity;\r\n}\r\n\r\n/**\r\n * Differencing entry for Mixin Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\r\n readonly schemaType: SchemaItemType.Mixin;\r\n}\r\n\r\n/**\r\n * Differencing entry for Phenomenon Schema Items.\r\n * @alpha\r\n */\r\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\r\n readonly schemaType: SchemaItemType.Phenomenon;\r\n}\r\n\r\n/**\r\n * Differencing entry for Property Category Schema Items.\r\n * @alpha\r\n */\r\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\r\n readonly schemaType: SchemaItemType.PropertyCategory;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\r\n readonly schemaType: SchemaItemType.RelationshipClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Struct Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\r\n readonly schemaType: SchemaItemType.StructClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit System Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\r\n readonly schemaType: SchemaItemType.UnitSystem;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\r\n readonly schemaType: SchemaItemType.Unit;\r\n}\r\n\r\n/**\r\n * Differencing entry for Inverted Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\r\n readonly schemaType: SchemaItemType.InvertedUnit;\r\n}\r\n/**\r\n * Differencing entry for Format Schema Items.\r\n * @alpha\r\n */\r\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\r\n readonly schemaType: SchemaItemType.Format;\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Properties.\r\n * @alpha\r\n */\r\nexport interface ClassPropertyDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Property;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyPropertyProps>;\r\n}\r\n\r\n/**\r\n * Union of supported Custom Attribute Differences.\r\n * @alpha\r\n */\r\nexport type CustomAttributeDifference =\r\n CustomAttributeSchemaDifference |\r\n CustomAttributeSchemaItemDifference |\r\n CustomAttributePropertyDifference |\r\n CustomAttributeRelationshipConstraintDifference;\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Schema\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaItemDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"SchemaItem\";\r\n readonly itemName: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Properties.\r\n * @alpha\r\n */\r\nexport interface CustomAttributePropertyDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Property\";\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeRelationshipConstraintDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"RelationshipConstraint\";\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for changed mixins on EntityClasses.\r\n * @alpha\r\n */\r\nexport interface EntityClassMixinDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumeratorDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Enumerator;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\r\n}\r\n\r\n/**\r\n * Differencing entry for constraint classes added to Relationship Constrains.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintClassDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Creates a [[SchemaDifferenceResult]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifferenceResult]] object.\r\n * @alpha\r\n */\r\nexport async function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferenceResult> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n const visitor = new SchemaDiagnosticVisitor();\r\n for (const diagnostic of changesList[0].allDiagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n const differences: AnySchemaDifference[] = [\r\n ...visitor.schemaDifferences,\r\n ...visitor.schemaItemDifferences,\r\n ...visitor.schemaItemPathDifferences,\r\n ...visitor.customAttributeDifferences,\r\n ];\r\n\r\n const conflicts = await validateDifferences(differences, targetSchema, sourceSchema);\r\n\r\n return {\r\n sourceSchemaName: sourceSchema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n conflicts: conflicts.length > 0 ? conflicts : undefined,\r\n differences,\r\n };\r\n}\r\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Differencing
|
|
3
|
+
*/
|
|
4
|
+
import { Schema } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { AnySchemaDifference } from "./SchemaDifference";
|
|
6
|
+
import { SchemaDifferenceConflict } from "./SchemaConflicts";
|
|
7
|
+
/**
|
|
8
|
+
* Validates the given array of schema differences and returns a list of conflicts if the
|
|
9
|
+
* validation finds violation against rules.
|
|
10
|
+
* @param differences An array of schema differences.
|
|
11
|
+
* @param targetSchema The target schema reference.
|
|
12
|
+
* @param sourceSchema The source schema reference.
|
|
13
|
+
* @returns An array of conflicts found when validating the difference.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferenceConflict[]>;
|
|
17
|
+
//# sourceMappingURL=SchemaDifferenceValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAqM,MAAM,EAA6C,MAAM,0BAA0B,CAAC;AAChS,OAAO,EAAE,mBAAmB,EAAsmB,MAAM,oBAAoB,CAAC;AAC7pB,OAAO,EAAgB,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG3E;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,uCAOvH"}
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Differencing
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.validateDifferences = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const SchemaDifference_1 = require("./SchemaDifference");
|
|
13
|
+
const SchemaConflicts_1 = require("./SchemaConflicts");
|
|
14
|
+
const SchemaDifferenceVisitor_1 = require("./SchemaDifferenceVisitor");
|
|
15
|
+
/**
|
|
16
|
+
* Validates the given array of schema differences and returns a list of conflicts if the
|
|
17
|
+
* validation finds violation against rules.
|
|
18
|
+
* @param differences An array of schema differences.
|
|
19
|
+
* @param targetSchema The target schema reference.
|
|
20
|
+
* @param sourceSchema The source schema reference.
|
|
21
|
+
* @returns An array of conflicts found when validating the difference.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
async function validateDifferences(differences, targetSchema, sourceSchema) {
|
|
25
|
+
const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema);
|
|
26
|
+
const walker = new SchemaDifferenceVisitor_1.SchemaDifferenceWalker(visitor);
|
|
27
|
+
await walker.traverse(differences);
|
|
28
|
+
return visitor.conflicts;
|
|
29
|
+
}
|
|
30
|
+
exports.validateDifferences = validateDifferences;
|
|
31
|
+
/**
|
|
32
|
+
* The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and
|
|
33
|
+
* validates the given SchemaDifferences if the violate against some EC Rules.
|
|
34
|
+
*/
|
|
35
|
+
class SchemaDifferenceValidationVisitor {
|
|
36
|
+
/** Initializes a new instance of SchemaDifferenceValidationVisitor class. */
|
|
37
|
+
constructor(targetSchema, sourceSchema) {
|
|
38
|
+
this.conflicts = [];
|
|
39
|
+
this._targetSchema = targetSchema;
|
|
40
|
+
this._sourceSchema = sourceSchema;
|
|
41
|
+
}
|
|
42
|
+
addConflict(conflict) {
|
|
43
|
+
this.conflicts.push(conflict);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Visitor implementation for handling SchemaDifference.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
async visitSchemaDifference(_entry) {
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Visitor implementation for handling SchemaReferenceDifference.
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
async visitSchemaReferenceDifference(entry) {
|
|
56
|
+
const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name);
|
|
57
|
+
const targetSchemaReference = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);
|
|
58
|
+
if (targetSchemaReference && targetSchemaReference !== sourceSchemaReference.name) {
|
|
59
|
+
this.addConflict({
|
|
60
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingReferenceAlias,
|
|
61
|
+
schemaType: SchemaDifference_1.SchemaOtherTypes.SchemaReference,
|
|
62
|
+
source: entry.difference.name,
|
|
63
|
+
target: targetSchemaReference,
|
|
64
|
+
description: "Target schema already references a different schema with this alias.",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Shared schema item validation for all types of AnySchemaItemDifference union.
|
|
70
|
+
*/
|
|
71
|
+
async visitSchemaItemDifference(entry, targetSchemaItem) {
|
|
72
|
+
// If the item shall be added, but the target schema already has an item with this name,
|
|
73
|
+
// will produce an ConflictingItemName conflict.
|
|
74
|
+
if (entry.changeType === "add" && targetSchemaItem !== undefined) {
|
|
75
|
+
this.addConflict({
|
|
76
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingItemName,
|
|
77
|
+
schemaType: targetSchemaItem.schemaItemType,
|
|
78
|
+
itemName: targetSchemaItem.name,
|
|
79
|
+
source: entry.schemaType,
|
|
80
|
+
target: targetSchemaItem.schemaItemType,
|
|
81
|
+
description: "Target schema already contains a schema item with the name but different type.",
|
|
82
|
+
});
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Shared base-class validation for all types of ClassItemDifference union.
|
|
89
|
+
*/
|
|
90
|
+
async visitBaseClassDifference(entry, targetClassItem) {
|
|
91
|
+
if (entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {
|
|
92
|
+
return this.addConflict({
|
|
93
|
+
code: SchemaConflicts_1.ConflictCode.RemovingBaseClass,
|
|
94
|
+
schemaType: targetClassItem.schemaItemType,
|
|
95
|
+
itemName: targetClassItem.name,
|
|
96
|
+
path: "$baseClass",
|
|
97
|
+
source: null,
|
|
98
|
+
target: resolveLazyItemFullName(targetClassItem.baseClass),
|
|
99
|
+
description: "BaseClass cannot be removed, if there has been a baseClass before.",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (entry.difference.baseClass === undefined) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass);
|
|
106
|
+
if (sourceBaseClass.modifier === ecschema_metadata_1.ECClassModifier.Sealed) {
|
|
107
|
+
return this.addConflict({
|
|
108
|
+
code: SchemaConflicts_1.ConflictCode.SealedBaseClass,
|
|
109
|
+
schemaType: targetClassItem.schemaItemType,
|
|
110
|
+
itemName: targetClassItem.name,
|
|
111
|
+
path: "$baseClass",
|
|
112
|
+
source: sourceBaseClass.fullName,
|
|
113
|
+
target: resolveLazyItemFullName(targetClassItem.baseClass) || null,
|
|
114
|
+
description: "BaseClass is sealed.",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {
|
|
118
|
+
return this.addConflict({
|
|
119
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingBaseClass,
|
|
120
|
+
schemaType: targetClassItem.schemaItemType,
|
|
121
|
+
itemName: targetClassItem.name,
|
|
122
|
+
path: "$baseClass",
|
|
123
|
+
source: sourceBaseClass.fullName,
|
|
124
|
+
target: resolveLazyItemFullName(targetClassItem.baseClass),
|
|
125
|
+
description: "BaseClass is not valid, source class must derive from target.",
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Shared validation for all types of ClassItemDifference union.
|
|
131
|
+
*/
|
|
132
|
+
async visitClassDifference(entry) {
|
|
133
|
+
const targetClassItem = await this._targetSchema.getItem(entry.itemName);
|
|
134
|
+
if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (entry.changeType === "modify" && targetClassItem !== undefined) {
|
|
138
|
+
await this.visitClassModifierDifference(entry, targetClassItem);
|
|
139
|
+
await this.visitBaseClassDifference(entry, targetClassItem);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validation the modifiers of all types of ClassItemDifference union.
|
|
144
|
+
*/
|
|
145
|
+
async visitClassModifierDifference(entry, targetClass) {
|
|
146
|
+
if (entry.difference.modifier) {
|
|
147
|
+
const changedModifier = (0, ecschema_metadata_1.parseClassModifier)(entry.difference.modifier);
|
|
148
|
+
if (changedModifier !== undefined && changedModifier !== ecschema_metadata_1.ECClassModifier.None) {
|
|
149
|
+
this.addConflict({
|
|
150
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingClassModifier,
|
|
151
|
+
schemaType: targetClass.schemaItemType,
|
|
152
|
+
itemName: targetClass.name,
|
|
153
|
+
source: entry.difference.modifier,
|
|
154
|
+
target: (0, ecschema_metadata_1.classModifierToString)(targetClass.modifier),
|
|
155
|
+
description: "Class has conflicting modifiers.",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Visitor implementation for handling ConstantDifference.
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
async visitConstantDifference(entry) {
|
|
165
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Visitor implementation for handling CustomAttributeClassDifference.
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
async visitCustomAttributeClassDifference(entry) {
|
|
172
|
+
await this.visitClassDifference(entry);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Visitor implementation for handling CustomAttributeDifference.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
async visitCustomAttributeInstanceDifference(_entry) {
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Visitor implementation for handling EntityClassDifference.
|
|
182
|
+
* @internal
|
|
183
|
+
*/
|
|
184
|
+
async visitEntityClassDifference(entry) {
|
|
185
|
+
await this.visitClassDifference(entry);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Visitor implementation for handling EntityClassMixinDifference.
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
async visitEntityClassMixinDifference(entry) {
|
|
192
|
+
const targetEntityClass = await this._targetSchema.getItem(entry.itemName);
|
|
193
|
+
for (const addedMixin of entry.difference) {
|
|
194
|
+
// To validate the added mixins, the instance from the source schema it fetched,
|
|
195
|
+
// otherwise validation gets too complicated as the mixin must not be existing in
|
|
196
|
+
// the current target schema, it could also be added to the schema.
|
|
197
|
+
const sourceMixin = await this._sourceSchema.lookupItem(addedMixin);
|
|
198
|
+
const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName);
|
|
199
|
+
if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {
|
|
200
|
+
this.addConflict({
|
|
201
|
+
code: SchemaConflicts_1.ConflictCode.MixinAppliedMustDeriveFromConstraint,
|
|
202
|
+
schemaType: targetEntityClass.schemaItemType,
|
|
203
|
+
itemName: targetEntityClass.name,
|
|
204
|
+
path: "$mixins",
|
|
205
|
+
source: addedMixin,
|
|
206
|
+
target: undefined,
|
|
207
|
+
description: "Mixin cannot applied to this class.",
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Visitor implementation for handling EnumerationDifference.
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
async visitEnumerationDifference(entry) {
|
|
217
|
+
const enumeration = await this._targetSchema.getItem(entry.itemName);
|
|
218
|
+
if (!await this.visitSchemaItemDifference(entry, enumeration)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (entry.changeType === "modify" && enumeration !== undefined) {
|
|
222
|
+
if (entry.difference.type) {
|
|
223
|
+
this.addConflict({
|
|
224
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingEnumerationType,
|
|
225
|
+
schemaType: ecschema_metadata_1.SchemaItemType.Enumeration,
|
|
226
|
+
itemName: enumeration.name,
|
|
227
|
+
source: entry.difference.type,
|
|
228
|
+
target: (0, ecschema_metadata_1.primitiveTypeToString)(enumeration.type),
|
|
229
|
+
description: "Enumeration has a different primitive type.",
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Visitor implementation for handling EnumeratorDifference.
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
async visitEnumeratorDifference(entry) {
|
|
239
|
+
if (entry.changeType !== "modify") {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const enumeration = await this._targetSchema.getItem(entry.itemName);
|
|
243
|
+
const enumerator = enumeration.getEnumeratorByName(entry.path);
|
|
244
|
+
if (!enumerator) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (entry.difference.value) {
|
|
248
|
+
this.addConflict({
|
|
249
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingEnumeratorValue,
|
|
250
|
+
schemaType: ecschema_metadata_1.SchemaItemType.Enumeration,
|
|
251
|
+
itemName: enumeration.name,
|
|
252
|
+
path: enumerator.name,
|
|
253
|
+
source: entry.difference.value,
|
|
254
|
+
target: enumerator.value,
|
|
255
|
+
description: "Enumerators must have unique values.",
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Visitor implementation for handling FormatDifference.
|
|
261
|
+
* @internal
|
|
262
|
+
*/
|
|
263
|
+
async visitFormatDifference(entry) {
|
|
264
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Visitor implementation for handling InvertedUnitDifference.
|
|
268
|
+
* @internal
|
|
269
|
+
*/
|
|
270
|
+
async visitInvertedUnitDifference(entry) {
|
|
271
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Visitor implementation for handling KindOfQuantityDifference.
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
async visitKindOfQuantityDifference(entry) {
|
|
278
|
+
const kindOfQuantity = await this._targetSchema.getItem(entry.itemName);
|
|
279
|
+
if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (entry.changeType === "modify" && kindOfQuantity !== undefined) {
|
|
283
|
+
if (entry.difference.persistenceUnit) {
|
|
284
|
+
this.addConflict({
|
|
285
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingPersistenceUnit,
|
|
286
|
+
schemaType: ecschema_metadata_1.SchemaItemType.KindOfQuantity,
|
|
287
|
+
itemName: kindOfQuantity.name,
|
|
288
|
+
source: entry.difference.persistenceUnit,
|
|
289
|
+
target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),
|
|
290
|
+
description: "Kind of Quantity has a different persistence unit.",
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Visitor implementation for handling MixinClassDifference.
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
async visitMixinDifference(entry) {
|
|
300
|
+
await this.visitClassDifference(entry);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Visitor implementation for handling PhenomenonDifference.
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
306
|
+
async visitPhenomenonDifference(entry) {
|
|
307
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Visitor implementation for handling ClassPropertyDifference.
|
|
311
|
+
* @internal
|
|
312
|
+
*/
|
|
313
|
+
async visitPropertyDifference(entry) {
|
|
314
|
+
const targetClass = await this._targetSchema.getItem(entry.itemName);
|
|
315
|
+
const targetProperty = await targetClass.getProperty(entry.path);
|
|
316
|
+
const sourceClass = await this._sourceSchema.getItem(entry.itemName);
|
|
317
|
+
const sourceProperty = await sourceClass.getProperty(entry.path);
|
|
318
|
+
// If property shall be added but there is already a property with this name
|
|
319
|
+
// in target, a ConflictingPropertyName is issued.
|
|
320
|
+
if (entry.changeType === "add" && targetProperty !== undefined) {
|
|
321
|
+
return this.addConflict({
|
|
322
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingPropertyName,
|
|
323
|
+
schemaType: targetProperty.class.schemaItemType,
|
|
324
|
+
itemName: targetProperty.class.name,
|
|
325
|
+
path: targetProperty.name,
|
|
326
|
+
source: resolvePropertyTypeName(sourceProperty),
|
|
327
|
+
target: resolvePropertyTypeName(targetProperty),
|
|
328
|
+
description: "Target class already contains a property with a different type.",
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
if (entry.changeType === "modify" && targetProperty !== undefined) {
|
|
332
|
+
if (entry.difference.kindOfQuantity) {
|
|
333
|
+
const sourceKoQ = await sourceProperty.kindOfQuantity;
|
|
334
|
+
const targetKoQ = await targetProperty.kindOfQuantity;
|
|
335
|
+
if (!targetKoQ || sourceKoQ && resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {
|
|
336
|
+
this.addConflict({
|
|
337
|
+
code: SchemaConflicts_1.ConflictCode.ConflictingPropertyKindOfQuantity,
|
|
338
|
+
schemaType: targetClass.schemaItemType,
|
|
339
|
+
itemName: targetClass.name,
|
|
340
|
+
path: targetProperty.name,
|
|
341
|
+
source: entry.difference.kindOfQuantity,
|
|
342
|
+
target: resolveLazyItemFullName(targetProperty.kindOfQuantity),
|
|
343
|
+
description: "The property has different kind of quantities with conflicting units defined.",
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Visitor implementation for handling PropertyCategoryDifference.
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
async visitPropertyCategoryDifference(entry) {
|
|
354
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Visitor implementation for handling RelationshipClassDifference.
|
|
358
|
+
* @internal
|
|
359
|
+
*/
|
|
360
|
+
async visitRelationshipClassDifference(entry) {
|
|
361
|
+
await this.visitClassDifference(entry);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Visitor implementation for handling RelationshipConstraintDifference.
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
async visitRelationshipConstraintDifference(_entry) {
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Visitor implementation for handling RelationshipConstraintClassDifference.
|
|
371
|
+
* @internal
|
|
372
|
+
*/
|
|
373
|
+
async visitRelationshipConstraintClassDifference(_entry) {
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Visitor implementation for handling StructClassDifference.
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
async visitStructClassDifference(entry) {
|
|
380
|
+
await this.visitClassDifference(entry);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Visitor implementation for handling UnitDifference.
|
|
384
|
+
* @internal
|
|
385
|
+
*/
|
|
386
|
+
async visitUnitDifference(entry) {
|
|
387
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Visitor implementation for handling UnitSystemDifference.
|
|
391
|
+
* @internal
|
|
392
|
+
*/
|
|
393
|
+
async visitUnitSystemDifference(entry) {
|
|
394
|
+
await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Recursive synchronous function to figure whether a given class derived from
|
|
398
|
+
* a class with the given baseClass name.
|
|
399
|
+
*/
|
|
400
|
+
async derivedFrom(ecClass, baseClassKey) {
|
|
401
|
+
if (ecClass === undefined) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
// First check for name which must be same in any case...
|
|
405
|
+
if (ecClass.name === baseClassKey.name) {
|
|
406
|
+
// ... then check if the class is in the same schema as the expected base class...
|
|
407
|
+
if (ecClass.schema.name === baseClassKey.schemaName)
|
|
408
|
+
return true;
|
|
409
|
+
// ... if not, whether it's in the source schema, but then we expect the baseclass
|
|
410
|
+
// to be in the target schema.
|
|
411
|
+
if (ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
return this.derivedFrom(await ecClass.baseClass, baseClassKey);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Helper method to resolve the schema item name from lazy loaded schema items.
|
|
419
|
+
* @param lazyItem LazyLoaded item
|
|
420
|
+
* @returns The full name of the item or undefined item was not set.
|
|
421
|
+
*/
|
|
422
|
+
function resolveLazyItemFullName(lazyItem) {
|
|
423
|
+
return lazyItem && lazyItem.fullName;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Helper method to resolve the schema item name from lazy loaded schema items.
|
|
427
|
+
* @param lazyItem LazyLoaded item
|
|
428
|
+
* @returns The full name of the item or undefined item was not set.
|
|
429
|
+
*/
|
|
430
|
+
function resolveLazyItemName(lazyItem) {
|
|
431
|
+
return lazyItem && lazyItem.name;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Helper method to resolve the type name of a property.
|
|
435
|
+
* @param property The property which's type shall be resolved.
|
|
436
|
+
* @returns The (full) name of the properties type.
|
|
437
|
+
*/
|
|
438
|
+
function resolvePropertyTypeName(property) {
|
|
439
|
+
const [prefix, suffix] = property.isArray() ? ["[", "]"] : ["", ""];
|
|
440
|
+
if (property.isEnumeration())
|
|
441
|
+
return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;
|
|
442
|
+
if (property.isPrimitive())
|
|
443
|
+
return `${prefix}${(0, ecschema_metadata_1.primitiveTypeToString)(property.primitiveType)}${suffix}`;
|
|
444
|
+
if (property.isStruct())
|
|
445
|
+
return `${prefix}${property.structClass.fullName}${suffix}`;
|
|
446
|
+
if (property.isNavigation())
|
|
447
|
+
return `${prefix}${property.relationshipClass.fullName}${suffix}`;
|
|
448
|
+
return (0, ecschema_metadata_1.propertyTypeToString)(property.propertyType);
|
|
449
|
+
}
|
|
450
|
+
//# sourceMappingURL=SchemaDifferenceValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgS;AAChS,yDAA6pB;AAC7pB,uDAA2E;AAC3E,uEAA6F;AAE7F;;;;;;;;GAQG;AACI,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB;IACtH,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAClF,MAAM,MAAM,GAAG,IAAI,gDAAsB,CAA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CAAC;IACpE,IAAI,QAAQ,CAAC,aAAa,EAAE;QAC1B,OAAO,GAAG,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,WAAW,EAAE;QACxB,OAAO,GAAG,MAAM,GAAG,IAAA,yCAAqB,EAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAAC;IAC9E,IAAI,QAAQ,CAAC,QAAQ,EAAE;QACrB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IAC9D,IAAI,QAAQ,CAAC,YAAY,EAAE;QACzB,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC;IACpE,OAAO,IAAA,wCAAoB,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { AnySchemaDifference, AnySchemaItemDifference, ClassItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, InvertedUnitDifference, KindOfQuantityDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaOtherTypes, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\r\nimport { ConflictCode, SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { ISchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\r\n\r\n/**\r\n * Validates the given array of schema differences and returns a list of conflicts if the\r\n * validation finds violation against rules.\r\n * @param differences An array of schema differences.\r\n * @param targetSchema The target schema reference.\r\n * @param sourceSchema The source schema reference.\r\n * @returns An array of conflicts found when validating the difference.\r\n * @internal\r\n */\r\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema) {\r\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema);\r\n const walker = new SchemaDifferenceWalker(visitor);\r\n\r\n await walker.traverse(differences);\r\n\r\n return visitor.conflicts;\r\n}\r\n\r\n/**\r\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\r\n * validates the given SchemaDifferences if the violate against some EC Rules.\r\n */\r\nclass SchemaDifferenceValidationVisitor implements ISchemaDifferenceVisitor {\r\n\r\n public readonly conflicts: Array<SchemaDifferenceConflict>;\r\n private readonly _sourceSchema: Schema;\r\n private readonly _targetSchema: Schema;\r\n\r\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\r\n constructor(targetSchema: Schema, sourceSchema: Schema) {\r\n this.conflicts = [];\r\n this._targetSchema = targetSchema;\r\n this._sourceSchema = sourceSchema;\r\n }\r\n\r\n private addConflict(conflict: SchemaDifferenceConflict) {\r\n this.conflicts.push(conflict);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference(_entry: SchemaDifference) {\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) {\r\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\r\n const targetSchemaReference = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\r\n if (targetSchemaReference && targetSchemaReference !== sourceSchemaReference.name) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingReferenceAlias,\r\n schemaType: SchemaOtherTypes.SchemaReference,\r\n source: entry.difference.name,\r\n target: targetSchemaReference,\r\n description: \"Target schema already references a different schema with this alias.\",\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shared schema item validation for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\r\n // If the item shall be added, but the target schema already has an item with this name,\r\n // will produce an ConflictingItemName conflict.\r\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingItemName,\r\n schemaType: targetSchemaItem.schemaItemType,\r\n itemName: targetSchemaItem.name,\r\n source: entry.schemaType,\r\n target: targetSchemaItem.schemaItemType,\r\n description: \"Target schema already contains a schema item with the name but different type.\",\r\n });\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Shared base-class validation for all types of ClassItemDifference union.\r\n */\r\n private async visitBaseClassDifference(entry: ClassItemDifference, targetClassItem: ECClass) {\r\n if (entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\r\n return this.addConflict({\r\n code: ConflictCode.RemovingBaseClass,\r\n schemaType: targetClassItem.schemaItemType,\r\n itemName: targetClassItem.name,\r\n path: \"$baseClass\",\r\n source: null,\r\n target: resolveLazyItemFullName(targetClassItem.baseClass),\r\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\r\n });\r\n }\r\n\r\n if (entry.difference.baseClass === undefined) {\r\n return;\r\n }\r\n\r\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\r\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\r\n return this.addConflict({\r\n code: ConflictCode.SealedBaseClass,\r\n schemaType: targetClassItem.schemaItemType,\r\n itemName: targetClassItem.name,\r\n path: \"$baseClass\",\r\n source: sourceBaseClass.fullName,\r\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\r\n description: \"BaseClass is sealed.\",\r\n });\r\n }\r\n\r\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\r\n return this.addConflict({\r\n code: ConflictCode.ConflictingBaseClass,\r\n schemaType: targetClassItem.schemaItemType,\r\n itemName: targetClassItem.name,\r\n path: \"$baseClass\",\r\n source: sourceBaseClass.fullName,\r\n target: resolveLazyItemFullName(targetClassItem.baseClass),\r\n description: \"BaseClass is not valid, source class must derive from target.\",\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shared validation for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference(entry: ClassItemDifference) {\r\n const targetClassItem = await this._targetSchema.getItem<ECClass>(entry.itemName);\r\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\r\n return;\r\n }\r\n\r\n if (entry.changeType === \"modify\" && targetClassItem !== undefined) {\r\n await this.visitClassModifierDifference(entry, targetClassItem);\r\n await this.visitBaseClassDifference(entry, targetClassItem);\r\n }\r\n }\r\n\r\n /**\r\n * Validation the modifiers of all types of ClassItemDifference union.\r\n */\r\n private async visitClassModifierDifference(entry: ClassItemDifference, targetClass: ECClass) {\r\n if (entry.difference.modifier) {\r\n const changedModifier = parseClassModifier(entry.difference.modifier);\r\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingClassModifier,\r\n schemaType: targetClass.schemaItemType,\r\n itemName: targetClass.name,\r\n source: entry.difference.modifier,\r\n target: classModifierToString(targetClass.modifier),\r\n description: \"Class has conflicting modifiers.\",\r\n });\r\n }\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\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) {\r\n await this.visitClassDifference(entry);\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) {\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) {\r\n await this.visitClassDifference(entry);\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) {\r\n const targetEntityClass = await this._targetSchema.getItem(entry.itemName) as EntityClass;\r\n for (const addedMixin of entry.difference) {\r\n // To validate the added mixins, the instance from the source schema it fetched,\r\n // otherwise validation gets too complicated as the mixin must not be existing in\r\n // the current target schema, it could also be added to the schema.\r\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\r\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\r\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\r\n this.addConflict({\r\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\r\n schemaType: targetEntityClass.schemaItemType,\r\n itemName: targetEntityClass.name,\r\n path: \"$mixins\",\r\n source: addedMixin,\r\n target: undefined,\r\n description: \"Mixin cannot applied to this class.\",\r\n });\r\n }\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) {\r\n const enumeration = await this._targetSchema.getItem<Enumeration>(entry.itemName);\r\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\r\n return;\r\n }\r\n\r\n if (entry.changeType === \"modify\" && enumeration !== undefined) {\r\n if (entry.difference.type) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingEnumerationType,\r\n schemaType: SchemaItemType.Enumeration,\r\n itemName: enumeration.name,\r\n source: entry.difference.type,\r\n target: primitiveTypeToString(enumeration.type!),\r\n description: \"Enumeration has a different primitive type.\",\r\n });\r\n }\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) {\r\n if (entry.changeType !== \"modify\") {\r\n return;\r\n }\r\n\r\n const enumeration = await this._targetSchema.getItem(entry.itemName) as Enumeration;\r\n const enumerator = enumeration.getEnumeratorByName(entry.path);\r\n if (!enumerator) {\r\n return;\r\n }\r\n\r\n if (entry.difference.value) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingEnumeratorValue,\r\n schemaType: SchemaItemType.Enumeration,\r\n itemName: enumeration.name,\r\n path: enumerator.name,\r\n source: entry.difference.value,\r\n target: enumerator.value,\r\n description: \"Enumerators must have unique values.\",\r\n });\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\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) {\r\n const kindOfQuantity = await this._targetSchema.getItem<KindOfQuantity>(entry.itemName);\r\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\r\n return;\r\n }\r\n\r\n if (entry.changeType === \"modify\" && kindOfQuantity !== undefined) {\r\n if (entry.difference.persistenceUnit) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingPersistenceUnit,\r\n schemaType: SchemaItemType.KindOfQuantity,\r\n itemName: kindOfQuantity.name,\r\n source: entry.difference.persistenceUnit,\r\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\r\n description: \"Kind of Quantity has a different persistence unit.\",\r\n });\r\n }\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) {\r\n await this.visitClassDifference(entry);\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\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) {\r\n const targetClass = await this._targetSchema.getItem(entry.itemName) as ECClass;\r\n const targetProperty = await targetClass.getProperty(entry.path);\r\n\r\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\r\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\r\n\r\n // If property shall be added but there is already a property with this name\r\n // in target, a ConflictingPropertyName is issued.\r\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\r\n return this.addConflict({\r\n code: ConflictCode.ConflictingPropertyName,\r\n schemaType: targetProperty.class.schemaItemType,\r\n itemName: targetProperty.class.name,\r\n path: targetProperty.name,\r\n source: resolvePropertyTypeName(sourceProperty),\r\n target: resolvePropertyTypeName(targetProperty),\r\n description: \"Target class already contains a property with a different type.\",\r\n });\r\n }\r\n\r\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\r\n if (entry.difference.kindOfQuantity) {\r\n const sourceKoQ = await sourceProperty.kindOfQuantity;\r\n const targetKoQ = await targetProperty.kindOfQuantity;\r\n if (!targetKoQ || sourceKoQ && resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\r\n schemaType: targetClass.schemaItemType,\r\n itemName: targetClass.name,\r\n path: targetProperty.name,\r\n source: entry.difference.kindOfQuantity,\r\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\r\n description: \"The property has different kind of quantities with conflicting units defined.\",\r\n });\r\n }\r\n }\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\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) {\r\n await this.visitClassDifference(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) {\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) {\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) {\r\n await this.visitClassDifference(entry);\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\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) {\r\n await this.visitSchemaItemDifference(entry, await this._targetSchema.getItem(entry.itemName));\r\n }\r\n\r\n /**\r\n * Recursive synchronous function to figure whether a given class derived from\r\n * a class with the given baseClass name.\r\n */\r\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\r\n if (ecClass === undefined) {\r\n return false;\r\n }\r\n\r\n // First check for name which must be same in any case...\r\n if (ecClass.name === baseClassKey.name) {\r\n // ... then check if the class is in the same schema as the expected base class...\r\n if(ecClass.schema.name === baseClassKey.schemaName)\r\n return true;\r\n // ... if not, whether it's in the source schema, but then we expect the baseclass\r\n // to be in the target schema.\r\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\r\n return true;\r\n }\r\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to resolve the schema item name from lazy loaded schema items.\r\n * @param lazyItem LazyLoaded item\r\n * @returns The full name of the item or undefined item was not set.\r\n */\r\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\r\n return lazyItem && lazyItem.fullName;\r\n}\r\n\r\n/**\r\n * Helper method to resolve the schema item name from lazy loaded schema items.\r\n * @param lazyItem LazyLoaded item\r\n * @returns The full name of the item or undefined item was not set.\r\n */\r\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\r\n return lazyItem && lazyItem.name;\r\n}\r\n\r\n/**\r\n * Helper method to resolve the type name of a property.\r\n * @param property The property which's type shall be resolved.\r\n * @returns The (full) name of the properties type.\r\n */\r\nfunction resolvePropertyTypeName(property: Property) {\r\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\r\n if (property.isEnumeration())\r\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\r\n if (property.isPrimitive())\r\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\r\n if (property.isStruct())\r\n return `${prefix}${property.structClass.fullName}${suffix}`;\r\n if (property.isNavigation())\r\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\r\n return propertyTypeToString(property.propertyType);\r\n}\r\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Differencing
|
|
3
|
+
*/
|
|
4
|
+
import { type AnySchemaDifference } from "./SchemaDifference";
|
|
5
|
+
/**
|
|
6
|
+
* Defines the interface for a visitor that can be used to traverse schema differences.
|
|
7
|
+
* It dynamically creates a method for each schema difference type.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export type ISchemaDifferenceVisitor = {
|
|
11
|
+
[Difference in AnySchemaDifference as `visit${Difference["schemaType"]}Difference`]: (entry: Difference) => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Implementation of a walker that traverses schema differences and calls the appropriate
|
|
15
|
+
* method on the visitor.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare class SchemaDifferenceWalker {
|
|
19
|
+
private readonly _visitor;
|
|
20
|
+
/** Initializes a new instance of SchemaDifferenceWalker class. */
|
|
21
|
+
constructor(visitor: ISchemaDifferenceVisitor);
|
|
22
|
+
/**
|
|
23
|
+
* Traverses the schema differences and calls the appropriate method on the visitor.
|
|
24
|
+
* @param differences The differences to traverse.
|
|
25
|
+
*/
|
|
26
|
+
traverse(differences: Iterable<AnySchemaDifference>): Promise<void>;
|
|
27
|
+
private visit;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=SchemaDifferenceVisitor.d.ts.map
|