@itwin/ecschema-editing 5.2.0-dev.8 → 5.3.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 CHANGED
@@ -1,6 +1,36 @@
1
1
  # Change Log - @itwin/ecschema-editing
2
2
 
3
- This log was last generated on Thu, 14 Aug 2025 19:42:13 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 17 Sep 2025 17:22:51 GMT and should not be manually modified.
4
+
5
+ ## 5.1.8
6
+ Wed, 17 Sep 2025 17:17:16 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.1.7
11
+ Tue, 09 Sep 2025 19:28:04 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 5.1.6
16
+ Mon, 08 Sep 2025 13:53:47 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 5.1.5
21
+ Thu, 04 Sep 2025 13:51:09 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 5.1.4
26
+ Fri, 22 Aug 2025 14:22:33 GMT
27
+
28
+ _Version update only_
29
+
30
+ ## 5.1.3
31
+ Wed, 20 Aug 2025 13:57:10 GMT
32
+
33
+ _Version update only_
4
34
 
5
35
  ## 5.1.2
6
36
  Thu, 14 Aug 2025 19:38:08 GMT
@@ -37,6 +37,7 @@ export declare enum ConflictCode {
37
37
  ConflictingItemName = "C-001",
38
38
  ConflictingReferenceAlias = "C-002",
39
39
  ConflictingReferenceVersion = "C-003",
40
+ ConflictingReferenceDynamic = "C-004",
40
41
  ConflictingBaseClass = "C-100",
41
42
  RemovingBaseClass = "C-101",
42
43
  SealedBaseClass = "C-102",
@@ -79,6 +80,6 @@ type EcClassTypes = SchemaItemType.CustomAttributeClass | SchemaItemType.EntityC
79
80
  * Union of all supported schema differencing conflict types.
80
81
  * @alpha
81
82
  */
82
- export type AnySchemaDifferenceConflict = SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> | SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> | SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>;
83
+ export type AnySchemaDifferenceConflict = SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceDynamic, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> | SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> | SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>;
83
84
  export {};
84
85
  //# sourceMappingURL=SchemaConflicts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaConflicts.d.ts","sourceRoot":"","sources":["../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AY,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACzF,wBAAwB,CAAC,YAAY,CAAC,iCAAiC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACnG,wBAAwB,CAAC,YAAY,CAAC,qCAAqC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACvG,wBAAwB,CAAC,YAAY,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACzF,wBAAwB,CAAC,YAAY,CAAC,+BAA+B,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACnG,wBAAwB,CAAC,YAAY,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,GAC3H,wBAAwB,CAAC,YAAY,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,GAC3H,wBAAwB,CAAC,YAAY,CAAC,6CAA6C,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAC9H"}
@@ -43,6 +43,7 @@ var ConflictCode;
43
43
  ConflictCode["ConflictingItemName"] = "C-001";
44
44
  ConflictCode["ConflictingReferenceAlias"] = "C-002";
45
45
  ConflictCode["ConflictingReferenceVersion"] = "C-003";
46
+ ConflictCode["ConflictingReferenceDynamic"] = "C-004";
46
47
  ConflictCode["ConflictingBaseClass"] = "C-100";
47
48
  ConflictCode["RemovingBaseClass"] = "C-101";
48
49
  ConflictCode["SealedBaseClass"] = "C-102";
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaConflicts.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,IAAY,YA2BX;AA3BD,WAAY,YAAY;IAEtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,qDAAqC,CAAA;IAErC,8CAA8B,CAAA;IAC9B,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;IACzB,kDAAkC,CAAA;IAElC,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IAEpC,+CAA+B,CAAA;IAC/B,yDAAyC,CAAA;IAEzC,qDAAqC,CAAA;IACrC,+DAA+C,CAAA;IAE/C,kDAAkC,CAAA;IAClC,4DAA4C,CAAA;IAC5C,gEAAgD,CAAA;IAEhD,sEAAsD,CAAA;IACtD,sEAAsD,CAAA;IACtD,wEAAwD,CAAA;AAC1D,CAAC,EA3BW,YAAY,4BAAZ,YAAY,QA2BvB","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 Differencing\n */\n\nimport type { SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport type { AnySchemaDifference, SchemaOtherTypes, SchemaType } from \"./SchemaDifference\";\n\n/**\n * The unique conflicts codes for Schema differencing.\n *\n * To provide meaning to code values, with anticipation\n * of future rules for all current EC Types, the following\n * value ranges should be used:\n *\n * - Schema: 000-099\n * - Class: 100-199\n * - Constant: 200-299\n * - CustomAttribute 300-399\n * - CustomAttributeClass: 400-499\n * - CustomAttributeContainer: 500-599\n * - EntityClass: 600-699\n * - Enumeration: 700-799\n * - Format: 800-899\n * - InvertedUnit: 900-999\n * - KindOfQuantity: 1000-1099\n * - Mixin: 1100-1199\n * - Phenomenon: 1200-1299\n * - Property: 1300-1399\n * - PropertyCategory: 1400-1499\n * - RelationshipClass: 1500-1599\n * - RelationshipConstraint: 1600-1699\n * - StructClass: 1700-1799\n * - Unit: 1800-1899\n * - UnitSystem: 1900-1999\n *\n * @alpha\n */\nexport enum ConflictCode {\n\n ConflictingItemName = \"C-001\",\n ConflictingReferenceAlias = \"C-002\",\n ConflictingReferenceVersion = \"C-003\",\n\n ConflictingBaseClass = \"C-100\",\n RemovingBaseClass = \"C-101\",\n SealedBaseClass = \"C-102\",\n ConflictingClassModifier = \"C-103\",\n\n ConflictingEnumerationType = \"C-700\",\n ConflictingEnumeratorValue = \"C-701\",\n\n ConflictingFormatUnit = \"C-800\",\n ConflictingFormatUnitPhenomenon = \"C-801\",\n\n ConflictingPersistenceUnit = \"C-1010\",\n MixinAppliedMustDeriveFromConstraint = \"C-1100\",\n\n ConflictingPropertyName = \"C-1300\",\n ConflictingPropertyKindOfQuantity = \"C-1301\",\n ConflictingPropertyKindOfQuantityUnit = \"C-1302\",\n\n AbstractConstraintMustNarrowBaseConstraints = \"C-1500\",\n DerivedConstraintsMustNarrowBaseConstraints = \"C-1501\",\n ConstraintClassesDeriveFromAbstractConstraint = \"C-1502\",\n}\n\n/**\n * Defines the interface for a conflict during Schema Differencing. Conflicts were discovered\n * while comparing the changed elements. Conflicts in the whole schema context are not found\n * on that level.\n */\ninterface SchemaDifferenceConflict<TCode extends ConflictCode, TType extends SchemaType, TDifference = Extract<AnySchemaDifference, { schemaType: TType }>> {\n /** The associated schema difference instance */\n readonly difference: TDifference;\n\n /** The unique conflicting code. */\n readonly code: TCode;\n\n /** A description of the conflict. */\n readonly description: string;\n\n /** The value in the source schema. */\n readonly source: unknown;\n\n /** The value in the target schema. */\n readonly target: unknown;\n}\n\n/** Union type of class types */\ntype EcClassTypes = SchemaItemType.CustomAttributeClass | SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.Mixin | SchemaItemType.RelationshipClass;\n\n/**\n * Union of all supported schema differencing conflict types.\n * @alpha\n */\nexport type AnySchemaDifferenceConflict =\n SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> |\n SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>\n;\n"]}
1
+ {"version":3,"file":"SchemaConflicts.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,IAAY,YA4BX;AA5BD,WAAY,YAAY;IAEtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,qDAAqC,CAAA;IACrC,qDAAqC,CAAA;IAErC,8CAA8B,CAAA;IAC9B,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;IACzB,kDAAkC,CAAA;IAElC,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IAEpC,+CAA+B,CAAA;IAC/B,yDAAyC,CAAA;IAEzC,qDAAqC,CAAA;IACrC,+DAA+C,CAAA;IAE/C,kDAAkC,CAAA;IAClC,4DAA4C,CAAA;IAC5C,gEAAgD,CAAA;IAEhD,sEAAsD,CAAA;IACtD,sEAAsD,CAAA;IACtD,wEAAwD,CAAA;AAC1D,CAAC,EA5BW,YAAY,4BAAZ,YAAY,QA4BvB","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 Differencing\n */\n\nimport type { SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport type { AnySchemaDifference, SchemaOtherTypes, SchemaType } from \"./SchemaDifference\";\n\n/**\n * The unique conflicts codes for Schema differencing.\n *\n * To provide meaning to code values, with anticipation\n * of future rules for all current EC Types, the following\n * value ranges should be used:\n *\n * - Schema: 000-099\n * - Class: 100-199\n * - Constant: 200-299\n * - CustomAttribute 300-399\n * - CustomAttributeClass: 400-499\n * - CustomAttributeContainer: 500-599\n * - EntityClass: 600-699\n * - Enumeration: 700-799\n * - Format: 800-899\n * - InvertedUnit: 900-999\n * - KindOfQuantity: 1000-1099\n * - Mixin: 1100-1199\n * - Phenomenon: 1200-1299\n * - Property: 1300-1399\n * - PropertyCategory: 1400-1499\n * - RelationshipClass: 1500-1599\n * - RelationshipConstraint: 1600-1699\n * - StructClass: 1700-1799\n * - Unit: 1800-1899\n * - UnitSystem: 1900-1999\n *\n * @alpha\n */\nexport enum ConflictCode {\n\n ConflictingItemName = \"C-001\",\n ConflictingReferenceAlias = \"C-002\",\n ConflictingReferenceVersion = \"C-003\",\n ConflictingReferenceDynamic = \"C-004\",\n\n ConflictingBaseClass = \"C-100\",\n RemovingBaseClass = \"C-101\",\n SealedBaseClass = \"C-102\",\n ConflictingClassModifier = \"C-103\",\n\n ConflictingEnumerationType = \"C-700\",\n ConflictingEnumeratorValue = \"C-701\",\n\n ConflictingFormatUnit = \"C-800\",\n ConflictingFormatUnitPhenomenon = \"C-801\",\n\n ConflictingPersistenceUnit = \"C-1010\",\n MixinAppliedMustDeriveFromConstraint = \"C-1100\",\n\n ConflictingPropertyName = \"C-1300\",\n ConflictingPropertyKindOfQuantity = \"C-1301\",\n ConflictingPropertyKindOfQuantityUnit = \"C-1302\",\n\n AbstractConstraintMustNarrowBaseConstraints = \"C-1500\",\n DerivedConstraintsMustNarrowBaseConstraints = \"C-1501\",\n ConstraintClassesDeriveFromAbstractConstraint = \"C-1502\",\n}\n\n/**\n * Defines the interface for a conflict during Schema Differencing. Conflicts were discovered\n * while comparing the changed elements. Conflicts in the whole schema context are not found\n * on that level.\n */\ninterface SchemaDifferenceConflict<TCode extends ConflictCode, TType extends SchemaType, TDifference = Extract<AnySchemaDifference, { schemaType: TType }>> {\n /** The associated schema difference instance */\n readonly difference: TDifference;\n\n /** The unique conflicting code. */\n readonly code: TCode;\n\n /** A description of the conflict. */\n readonly description: string;\n\n /** The value in the source schema. */\n readonly source: unknown;\n\n /** The value in the target schema. */\n readonly target: unknown;\n}\n\n/** Union type of class types */\ntype EcClassTypes = SchemaItemType.CustomAttributeClass | SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.Mixin | SchemaItemType.RelationshipClass;\n\n/**\n * Union of all supported schema differencing conflict types.\n * @alpha\n */\nexport type AnySchemaDifferenceConflict =\n SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceDynamic, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> |\n SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>\n;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA2N,MAAM,EAAoD,MAAM,0BAA0B,CAAC;AAC7T,OAAO,EAA0B,mBAAmB,EAA4pB,MAAM,oBAAoB,CAAC;AAC3uB,OAAO,EAAE,2BAA2B,EAAgB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAe,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,0CAOlJ"}
1
+ {"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA2N,MAAM,EAA+D,MAAM,0BAA0B,CAAC;AACxU,OAAO,EAA0B,mBAAmB,EAA4pB,MAAM,oBAAoB,CAAC;AAC3uB,OAAO,EAAE,2BAA2B,EAAgB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAe,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,0CAOlJ"}
@@ -70,7 +70,7 @@ class SchemaDifferenceValidationVisitor {
70
70
  const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name);
71
71
  const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);
72
72
  if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {
73
- this.addConflict({
73
+ return this.addConflict({
74
74
  code: SchemaConflicts_1.ConflictCode.ConflictingReferenceAlias,
75
75
  difference: entry,
76
76
  source: entry.difference.name,
@@ -78,10 +78,24 @@ class SchemaDifferenceValidationVisitor {
78
78
  description: "Target schema already references a different schema with this alias.",
79
79
  });
80
80
  }
81
+ // The targetSchemaReference can be undefined, if the reference will be added by the source schema.
82
+ // In this case further validation is not needed.
83
+ const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);
84
+ if (targetSchemaReference === undefined) {
85
+ return;
86
+ }
81
87
  const sourceSchemaKey = sourceSchemaReference.schemaKey;
82
- const targetSchemaKey = await this._targetSchema.getReference(entry.difference.name)
83
- .then((schema) => schema?.schemaKey);
84
- if (entry.changeType === "modify" && targetSchemaKey && !sourceSchemaKey.matches(targetSchemaKey, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible)) {
88
+ const targetSchemaKey = targetSchemaReference.schemaKey;
89
+ if (targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {
90
+ return this.addConflict({
91
+ code: SchemaConflicts_1.ConflictCode.ConflictingReferenceDynamic,
92
+ difference: entry,
93
+ description: "Cannot update a schema reference to or from a dynamic schema.",
94
+ source: sourceSchemaKey.toString(),
95
+ target: targetSchemaKey.toString(),
96
+ });
97
+ }
98
+ if (entry.changeType === "modify" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {
85
99
  return this.addConflict({
86
100
  code: SchemaConflicts_1.ConflictCode.ConflictingReferenceVersion,
87
101
  difference: entry,
@@ -521,4 +535,12 @@ function resolvePropertyTypeName(property) {
521
535
  return `${prefix}${property.relationshipClass.fullName}${suffix}`;
522
536
  return (0, ecschema_metadata_1.propertyTypeToString)(property.propertyType);
523
537
  }
538
+ /**
539
+ * Checks if the two schemas are compatible. Since the merger will eventually take the most
540
+ * recent schema version, it is sufficient to check if they are write compatible in one direction.
541
+ */
542
+ function areCompatible(leftSchemaKey, rightSchemaKey) {
543
+ return leftSchemaKey.matches(rightSchemaKey, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible)
544
+ || rightSchemaKey.matches(leftSchemaKey, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible);
545
+ }
524
546
  //# sourceMappingURL=SchemaDifferenceValidator.js.map
@@ -1 +1 @@
1
- {"version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entley 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 Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = await this._targetSchema.getReference(entry.difference.name)\n .then((schema) => schema?.schemaKey);\n\n if(entry.changeType === \"modify\" && targetSchemaKey && !sourceSchemaKey.matches(targetSchemaKey, SchemaMatchType.LatestWriteCompatible)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n"]}
1
+ {"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/Schema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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;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,aAAwB,EAAE,cAAyB;IACxE,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,mCAAe,CAAC,qBAAqB,CAAC;WAC5E,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,mCAAe,CAAC,qBAAqB,CAAC,CAAC;AACtF,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 Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n // The targetSchemaReference can be undefined, if the reference will be added by the source schema.\n // In this case further validation is not needed.\n const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);\n if(targetSchemaReference === undefined) {\n return;\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = targetSchemaReference.schemaKey;\n\n if(targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceDynamic,\n difference: entry,\n description: \"Cannot update a schema reference to or from a dynamic schema.\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n\n if(entry.changeType === \"modify\" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n\n/**\n * Checks if the two schemas are compatible. Since the merger will eventually take the most\n * recent schema version, it is sufficient to check if they are write compatible in one direction.\n */\nfunction areCompatible(leftSchemaKey: SchemaKey, rightSchemaKey: SchemaKey): boolean {\n return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)\n || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);\n}\n"]}
@@ -66,7 +66,7 @@ class SchemaMerger {
66
66
  }
67
67
  throw error;
68
68
  });
69
- if (!schema.customAttributes || !schema.customAttributes.has("CoreCustomAttributes.DynamicSchema")) {
69
+ if (!schema.isDynamic) {
70
70
  throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);
71
71
  }
72
72
  const visitor = new SchemaMergingVisitor_1.SchemaMergingVisitor({
@@ -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,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,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QACjF,MAAM,eAAe,GAAG,6BAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAEjF,MAAM,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,4BAAmB,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;QAEpG,oGAAoG;QACpG,iEAAiE;QACjE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,KAAK,CAAC,OAAO,CAAC,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,EAAE,WAAW,CAAC,CAAC;QAC/E,CAAC;QAED,IAAI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;IAChC,aAAa,CAAc;IAEnC,YAAmB,eAA8B,EAAE,WAAwB;QACzE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC;IACnC,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA2B;QACrF,OAAO,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC;IAEe,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA2B;QAC/E,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAEe,KAAK,CAAC,aAAa,CAA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;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":["/*---------------------------------------------------------------------------------------------\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.customAttributes || !schema.customAttributes.has(\"CoreCustomAttributes.DynamicSchema\")) {\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
+ {"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,EAA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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":["/*---------------------------------------------------------------------------------------------\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"]}
@@ -37,6 +37,7 @@ export declare enum ConflictCode {
37
37
  ConflictingItemName = "C-001",
38
38
  ConflictingReferenceAlias = "C-002",
39
39
  ConflictingReferenceVersion = "C-003",
40
+ ConflictingReferenceDynamic = "C-004",
40
41
  ConflictingBaseClass = "C-100",
41
42
  RemovingBaseClass = "C-101",
42
43
  SealedBaseClass = "C-102",
@@ -79,6 +80,6 @@ type EcClassTypes = SchemaItemType.CustomAttributeClass | SchemaItemType.EntityC
79
80
  * Union of all supported schema differencing conflict types.
80
81
  * @alpha
81
82
  */
82
- export type AnySchemaDifferenceConflict = SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> | SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> | SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>;
83
+ export type AnySchemaDifferenceConflict = SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingReferenceDynamic, SchemaOtherTypes.SchemaReference> | SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> | SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> | SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> | SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> | SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> | SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>;
83
84
  export {};
84
85
  //# sourceMappingURL=SchemaConflicts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaConflicts.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,oBAAY,YAAY;IAEtB,mBAAmB,UAAU;IAC7B,yBAAyB,UAAU;IACnC,2BAA2B,UAAU;IAErC,oBAAoB,UAAU;IAC9B,iBAAiB,UAAU;IAC3B,eAAe,UAAU;IACzB,wBAAwB,UAAU;IAElC,0BAA0B,UAAU;IACpC,0BAA0B,UAAU;IAEpC,qBAAqB,UAAU;IAC/B,+BAA+B,UAAU;IAEzC,0BAA0B,WAAW;IACrC,oCAAoC,WAAW;IAE/C,uBAAuB,WAAW;IAClC,iCAAiC,WAAW;IAC5C,qCAAqC,WAAW;IAEhD,2CAA2C,WAAW;IACtD,2CAA2C,WAAW;IACtD,6CAA6C,WAAW;CACzD;AAED;;;;GAIG;AACH,UAAU,wBAAwB,CAAC,KAAK,SAAS,YAAY,EAAE,KAAK,SAAS,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,EAAE;IAAE,UAAU,EAAE,KAAK,CAAA;CAAE,CAAC;IACxJ,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IAEjC,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAErB,qCAAqC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,sCAAsC;IACtC,Q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gBAAgB,CAAC,UAAU,CAAC,GAC9F,wBAAwB,CAAC,YAAY,CAAC,0BAA0B,EAAE,cAAc,CAAC,cAAc,CAAC,GAChG,wBAAwB,CAAC,YAAY,CAAC,oCAAoC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAC9G,wBAAwB,CAAC,YAAY,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACzF,wBAAwB,CAAC,YAAY,CAAC,iCAAiC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACnG,wBAAwB,CAAC,YAAY,CAAC,qCAAqC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACvG,wBAAwB,CAAC,YAAY,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACzF,wBAAwB,CAAC,YAAY,CAAC,+BAA+B,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACnG,wBAAwB,CAAC,YAAY,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,GAC3H,wBAAwB,CAAC,YAAY,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,GAC3H,wBAAwB,CAAC,YAAY,CAAC,6CAA6C,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAC9H"}
@@ -40,6 +40,7 @@ export var ConflictCode;
40
40
  ConflictCode["ConflictingItemName"] = "C-001";
41
41
  ConflictCode["ConflictingReferenceAlias"] = "C-002";
42
42
  ConflictCode["ConflictingReferenceVersion"] = "C-003";
43
+ ConflictCode["ConflictingReferenceDynamic"] = "C-004";
43
44
  ConflictCode["ConflictingBaseClass"] = "C-100";
44
45
  ConflictCode["RemovingBaseClass"] = "C-101";
45
46
  ConflictCode["SealedBaseClass"] = "C-102";
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaConflicts.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAN,IAAY,YA2BX;AA3BD,WAAY,YAAY;IAEtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,qDAAqC,CAAA;IAErC,8CAA8B,CAAA;IAC9B,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;IACzB,kDAAkC,CAAA;IAElC,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IAEpC,+CAA+B,CAAA;IAC/B,yDAAyC,CAAA;IAEzC,qDAAqC,CAAA;IACrC,+DAA+C,CAAA;IAE/C,kDAAkC,CAAA;IAClC,4DAA4C,CAAA;IAC5C,gEAAgD,CAAA;IAEhD,sEAAsD,CAAA;IACtD,sEAAsD,CAAA;IACtD,wEAAwD,CAAA;AAC1D,CAAC,EA3BW,YAAY,KAAZ,YAAY,QA2BvB","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 Differencing\n */\n\nimport type { SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport type { AnySchemaDifference, SchemaOtherTypes, SchemaType } from \"./SchemaDifference\";\n\n/**\n * The unique conflicts codes for Schema differencing.\n *\n * To provide meaning to code values, with anticipation\n * of future rules for all current EC Types, the following\n * value ranges should be used:\n *\n * - Schema: 000-099\n * - Class: 100-199\n * - Constant: 200-299\n * - CustomAttribute 300-399\n * - CustomAttributeClass: 400-499\n * - CustomAttributeContainer: 500-599\n * - EntityClass: 600-699\n * - Enumeration: 700-799\n * - Format: 800-899\n * - InvertedUnit: 900-999\n * - KindOfQuantity: 1000-1099\n * - Mixin: 1100-1199\n * - Phenomenon: 1200-1299\n * - Property: 1300-1399\n * - PropertyCategory: 1400-1499\n * - RelationshipClass: 1500-1599\n * - RelationshipConstraint: 1600-1699\n * - StructClass: 1700-1799\n * - Unit: 1800-1899\n * - UnitSystem: 1900-1999\n *\n * @alpha\n */\nexport enum ConflictCode {\n\n ConflictingItemName = \"C-001\",\n ConflictingReferenceAlias = \"C-002\",\n ConflictingReferenceVersion = \"C-003\",\n\n ConflictingBaseClass = \"C-100\",\n RemovingBaseClass = \"C-101\",\n SealedBaseClass = \"C-102\",\n ConflictingClassModifier = \"C-103\",\n\n ConflictingEnumerationType = \"C-700\",\n ConflictingEnumeratorValue = \"C-701\",\n\n ConflictingFormatUnit = \"C-800\",\n ConflictingFormatUnitPhenomenon = \"C-801\",\n\n ConflictingPersistenceUnit = \"C-1010\",\n MixinAppliedMustDeriveFromConstraint = \"C-1100\",\n\n ConflictingPropertyName = \"C-1300\",\n ConflictingPropertyKindOfQuantity = \"C-1301\",\n ConflictingPropertyKindOfQuantityUnit = \"C-1302\",\n\n AbstractConstraintMustNarrowBaseConstraints = \"C-1500\",\n DerivedConstraintsMustNarrowBaseConstraints = \"C-1501\",\n ConstraintClassesDeriveFromAbstractConstraint = \"C-1502\",\n}\n\n/**\n * Defines the interface for a conflict during Schema Differencing. Conflicts were discovered\n * while comparing the changed elements. Conflicts in the whole schema context are not found\n * on that level.\n */\ninterface SchemaDifferenceConflict<TCode extends ConflictCode, TType extends SchemaType, TDifference = Extract<AnySchemaDifference, { schemaType: TType }>> {\n /** The associated schema difference instance */\n readonly difference: TDifference;\n\n /** The unique conflicting code. */\n readonly code: TCode;\n\n /** A description of the conflict. */\n readonly description: string;\n\n /** The value in the source schema. */\n readonly source: unknown;\n\n /** The value in the target schema. */\n readonly target: unknown;\n}\n\n/** Union type of class types */\ntype EcClassTypes = SchemaItemType.CustomAttributeClass | SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.Mixin | SchemaItemType.RelationshipClass;\n\n/**\n * Union of all supported schema differencing conflict types.\n * @alpha\n */\nexport type AnySchemaDifferenceConflict =\n SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> |\n SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>\n;\n"]}
1
+ {"version":3,"file":"SchemaConflicts.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAN,IAAY,YA4BX;AA5BD,WAAY,YAAY;IAEtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,qDAAqC,CAAA;IACrC,qDAAqC,CAAA;IAErC,8CAA8B,CAAA;IAC9B,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;IACzB,kDAAkC,CAAA;IAElC,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IAEpC,+CAA+B,CAAA;IAC/B,yDAAyC,CAAA;IAEzC,qDAAqC,CAAA;IACrC,+DAA+C,CAAA;IAE/C,kDAAkC,CAAA;IAClC,4DAA4C,CAAA;IAC5C,gEAAgD,CAAA;IAEhD,sEAAsD,CAAA;IACtD,sEAAsD,CAAA;IACtD,wEAAwD,CAAA;AAC1D,CAAC,EA5BW,YAAY,KAAZ,YAAY,QA4BvB","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 Differencing\n */\n\nimport type { SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport type { AnySchemaDifference, SchemaOtherTypes, SchemaType } from \"./SchemaDifference\";\n\n/**\n * The unique conflicts codes for Schema differencing.\n *\n * To provide meaning to code values, with anticipation\n * of future rules for all current EC Types, the following\n * value ranges should be used:\n *\n * - Schema: 000-099\n * - Class: 100-199\n * - Constant: 200-299\n * - CustomAttribute 300-399\n * - CustomAttributeClass: 400-499\n * - CustomAttributeContainer: 500-599\n * - EntityClass: 600-699\n * - Enumeration: 700-799\n * - Format: 800-899\n * - InvertedUnit: 900-999\n * - KindOfQuantity: 1000-1099\n * - Mixin: 1100-1199\n * - Phenomenon: 1200-1299\n * - Property: 1300-1399\n * - PropertyCategory: 1400-1499\n * - RelationshipClass: 1500-1599\n * - RelationshipConstraint: 1600-1699\n * - StructClass: 1700-1799\n * - Unit: 1800-1899\n * - UnitSystem: 1900-1999\n *\n * @alpha\n */\nexport enum ConflictCode {\n\n ConflictingItemName = \"C-001\",\n ConflictingReferenceAlias = \"C-002\",\n ConflictingReferenceVersion = \"C-003\",\n ConflictingReferenceDynamic = \"C-004\",\n\n ConflictingBaseClass = \"C-100\",\n RemovingBaseClass = \"C-101\",\n SealedBaseClass = \"C-102\",\n ConflictingClassModifier = \"C-103\",\n\n ConflictingEnumerationType = \"C-700\",\n ConflictingEnumeratorValue = \"C-701\",\n\n ConflictingFormatUnit = \"C-800\",\n ConflictingFormatUnitPhenomenon = \"C-801\",\n\n ConflictingPersistenceUnit = \"C-1010\",\n MixinAppliedMustDeriveFromConstraint = \"C-1100\",\n\n ConflictingPropertyName = \"C-1300\",\n ConflictingPropertyKindOfQuantity = \"C-1301\",\n ConflictingPropertyKindOfQuantityUnit = \"C-1302\",\n\n AbstractConstraintMustNarrowBaseConstraints = \"C-1500\",\n DerivedConstraintsMustNarrowBaseConstraints = \"C-1501\",\n ConstraintClassesDeriveFromAbstractConstraint = \"C-1502\",\n}\n\n/**\n * Defines the interface for a conflict during Schema Differencing. Conflicts were discovered\n * while comparing the changed elements. Conflicts in the whole schema context are not found\n * on that level.\n */\ninterface SchemaDifferenceConflict<TCode extends ConflictCode, TType extends SchemaType, TDifference = Extract<AnySchemaDifference, { schemaType: TType }>> {\n /** The associated schema difference instance */\n readonly difference: TDifference;\n\n /** The unique conflicting code. */\n readonly code: TCode;\n\n /** A description of the conflict. */\n readonly description: string;\n\n /** The value in the source schema. */\n readonly source: unknown;\n\n /** The value in the target schema. */\n readonly target: unknown;\n}\n\n/** Union type of class types */\ntype EcClassTypes = SchemaItemType.CustomAttributeClass | SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.Mixin | SchemaItemType.RelationshipClass;\n\n/**\n * Union of all supported schema differencing conflict types.\n * @alpha\n */\nexport type AnySchemaDifferenceConflict =\n SchemaDifferenceConflict<ConflictCode.ConflictingItemName, SchemaItemType> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceAlias, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceVersion, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingReferenceDynamic, SchemaOtherTypes.SchemaReference> |\n SchemaDifferenceConflict<ConflictCode.ConflictingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.RemovingBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.SealedBaseClass, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingClassModifier, EcClassTypes> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumerationType, SchemaItemType.Enumeration> |\n SchemaDifferenceConflict<ConflictCode.ConflictingEnumeratorValue, SchemaOtherTypes.Enumerator> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPersistenceUnit, SchemaItemType.KindOfQuantity> |\n SchemaDifferenceConflict<ConflictCode.MixinAppliedMustDeriveFromConstraint, SchemaOtherTypes.EntityClassMixin> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyName, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantity, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingPropertyKindOfQuantityUnit, SchemaOtherTypes.Property> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnit, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.ConflictingFormatUnitPhenomenon, SchemaOtherTypes.FormatUnit> |\n SchemaDifferenceConflict<ConflictCode.AbstractConstraintMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.DerivedConstraintsMustNarrowBaseConstraints, SchemaOtherTypes.RelationshipConstraint> |\n SchemaDifferenceConflict<ConflictCode.ConstraintClassesDeriveFromAbstractConstraint, SchemaOtherTypes.RelationshipConstraint>\n;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA2N,MAAM,EAAoD,MAAM,0BAA0B,CAAC;AAC7T,OAAO,EAA0B,mBAAmB,EAA4pB,MAAM,oBAAoB,CAAC;AAC3uB,OAAO,EAAE,2BAA2B,EAAgB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAe,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,0CAOlJ"}
1
+ {"version":3,"file":"SchemaDifferenceValidator.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAA2N,MAAM,EAA+D,MAAM,0BAA0B,CAAC;AACxU,OAAO,EAA0B,mBAAmB,EAA4pB,MAAM,oBAAoB,CAAC;AAC3uB,OAAO,EAAE,2BAA2B,EAAgB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAe,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,0CAOlJ"}
@@ -67,7 +67,7 @@ class SchemaDifferenceValidationVisitor {
67
67
  const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name);
68
68
  const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);
69
69
  if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {
70
- this.addConflict({
70
+ return this.addConflict({
71
71
  code: ConflictCode.ConflictingReferenceAlias,
72
72
  difference: entry,
73
73
  source: entry.difference.name,
@@ -75,10 +75,24 @@ class SchemaDifferenceValidationVisitor {
75
75
  description: "Target schema already references a different schema with this alias.",
76
76
  });
77
77
  }
78
+ // The targetSchemaReference can be undefined, if the reference will be added by the source schema.
79
+ // In this case further validation is not needed.
80
+ const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);
81
+ if (targetSchemaReference === undefined) {
82
+ return;
83
+ }
78
84
  const sourceSchemaKey = sourceSchemaReference.schemaKey;
79
- const targetSchemaKey = await this._targetSchema.getReference(entry.difference.name)
80
- .then((schema) => schema?.schemaKey);
81
- if (entry.changeType === "modify" && targetSchemaKey && !sourceSchemaKey.matches(targetSchemaKey, SchemaMatchType.LatestWriteCompatible)) {
85
+ const targetSchemaKey = targetSchemaReference.schemaKey;
86
+ if (targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {
87
+ return this.addConflict({
88
+ code: ConflictCode.ConflictingReferenceDynamic,
89
+ difference: entry,
90
+ description: "Cannot update a schema reference to or from a dynamic schema.",
91
+ source: sourceSchemaKey.toString(),
92
+ target: targetSchemaKey.toString(),
93
+ });
94
+ }
95
+ if (entry.changeType === "modify" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {
82
96
  return this.addConflict({
83
97
  code: ConflictCode.ConflictingReferenceVersion,
84
98
  difference: entry,
@@ -518,4 +532,12 @@ function resolvePropertyTypeName(property) {
518
532
  return `${prefix}${property.relationshipClass.fullName}${suffix}`;
519
533
  return propertyTypeToString(property.propertyType);
520
534
  }
535
+ /**
536
+ * Checks if the two schemas are compatible. Since the merger will eventually take the most
537
+ * recent schema version, it is sufficient to check if they are write compatible in one direction.
538
+ */
539
+ function areCompatible(leftSchemaKey, rightSchemaKey) {
540
+ return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)
541
+ || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);
542
+ }
521
543
  //# sourceMappingURL=SchemaDifferenceValidator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAe,WAAW,EAAU,YAAY,EAAE,cAAc,EAA+B,kBAAkB,EAAE,qBAAqB,EAAY,oBAAoB,EAAsB,aAAa,EAAE,eAAe,EAAQ,MAAM,0BAA0B,CAAC;AAE7T,OAAO,EAA+B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAA2B,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAe,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB,EAAE,YAAyB;IACjJ,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAChG,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAiC;IAErB,SAAS,CAAqC;IAC7C,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,aAAa,CAAc;IAE5C,6EAA6E;IAC7E,YAAY,YAAoB,EAAE,YAAoB,EAAE,YAAyB;QAC/E,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GA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AE;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,oBAAoB,CAAC,QAAQ,CAAC,YAAY,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*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = await this._targetSchema.getReference(entry.difference.name)\n .then((schema) => schema?.schemaKey);\n\n if(entry.changeType === \"modify\" && targetSchemaKey && !sourceSchemaKey.matches(targetSchemaKey, SchemaMatchType.LatestWriteCompatible)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n"]}
1
+ {"version":3,"file":"SchemaDifferenceValidator.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifferenceValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAe,WAAW,EAAU,YAAY,EAAE,cAAc,EAA+B,kBAAkB,EAAE,qBAAqB,EAAY,oBAAoB,EAAsB,aAAa,EAAa,eAAe,EAAQ,MAAM,0BAA0B,CAAC;AAExU,OAAO,EAA+B,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAA2B,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAe,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAkC,EAAE,YAAoB,EAAE,YAAoB,EAAE,YAAyB;IACjJ,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAChG,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAEnD,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAiC;IAErB,SAAS,CAAqC;IAC7C,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,aAAa,CAAc;IAE5C,6EAA6E;IAC7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C,IAAI,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,QAAkB;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,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,qBAAqB,CAAC,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,oBAAoB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,aAAwB,EAAE,cAAyB;IACxE,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,qBAAqB,CAAC;WAC5E,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;AACtF,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 Differencing\n */\n\nimport { classModifierToString, ECClass, ECClassModifier, EntityClass, Enumeration, Format, InvertedUnit, KindOfQuantity, LazyLoadedSchemaItem, Mixin, parseClassModifier, primitiveTypeToString, Property, propertyTypeToString, Schema, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType, Unit } from \"@itwin/ecschema-metadata\";\nimport { AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from \"./SchemaDifference\";\nimport { AnySchemaDifferenceConflict, ConflictCode } from \"./SchemaConflicts\";\nimport { SchemaDifferenceVisitor, SchemaDifferenceWalker } from \"./SchemaDifferenceVisitor\";\nimport { NameMapping, PropertyKey } from \"../Merging/Edits/NameMapping\";\n\n/**\n * Validates the given array of schema differences and returns a list of conflicts if the\n * validation finds violation against rules.\n * @param differences An array of schema differences.\n * @param targetSchema The target schema reference.\n * @param sourceSchema The source schema reference.\n * @returns An array of conflicts found when validating the difference.\n * @internal\n */\nexport async function validateDifferences(differences: AnySchemaDifference[], targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n const visitor = new SchemaDifferenceValidationVisitor(targetSchema, sourceSchema, nameMappings);\n const walker = new SchemaDifferenceWalker(visitor);\n\n await walker.traverse(differences);\n\n return visitor.conflicts;\n}\n\n/**\n * The SchemaDifferenceValidationVisitor class is an implementation of ISchemaDifferenceVisitor and\n * validates the given SchemaDifferences if the violate against some EC Rules.\n */\nclass SchemaDifferenceValidationVisitor implements SchemaDifferenceVisitor {\n\n public readonly conflicts: Array<AnySchemaDifferenceConflict>;\n private readonly _sourceSchema: Schema;\n private readonly _targetSchema: Schema;\n private readonly _nameMappings: NameMapping;\n\n /** Initializes a new instance of SchemaDifferenceValidationVisitor class. */\n constructor(targetSchema: Schema, sourceSchema: Schema, nameMappings: NameMapping) {\n this.conflicts = [];\n this._targetSchema = targetSchema;\n this._sourceSchema = sourceSchema;\n this._nameMappings = nameMappings;\n }\n\n private addConflict(conflict: AnySchemaDifferenceConflict) {\n this.conflicts.push(conflict);\n }\n\n private async getTargetSchemaItem(name: string): Promise<SchemaItem | undefined> {\n const itemKey = new SchemaItemKey(name, this._sourceSchema.schemaKey);\n const mappedKey = this._nameMappings.resolveItemKey(itemKey);\n return this._targetSchema.getItem(mappedKey.name);\n }\n\n private getTargetProperty(itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, this._sourceSchema.schemaKey);\n const propertyKey = new PropertyKey(propertyName, classKey);\n return this._nameMappings.resolvePropertyKey(propertyKey);\n }\n\n /**\n * Visitor implementation for handling SchemaDifference.\n * @internal\n */\n public async visitSchemaDifference(_entry: SchemaDifference) {\n }\n\n /**\n * Visitor implementation for handling SchemaReferenceDifference.\n * @internal\n */\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference) {\n const sourceSchemaReference = await this._sourceSchema.getReference(entry.difference.name) as Schema;\n const targetSchemaReferenceName = this._targetSchema.getReferenceNameByAlias(sourceSchemaReference.alias);\n if (targetSchemaReferenceName && targetSchemaReferenceName !== sourceSchemaReference.name) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceAlias,\n difference: entry,\n source: entry.difference.name,\n target: targetSchemaReferenceName,\n description: \"Target schema already references a different schema with this alias.\",\n });\n }\n\n // The targetSchemaReference can be undefined, if the reference will be added by the source schema.\n // In this case further validation is not needed.\n const targetSchemaReference = await this._targetSchema.getReference(entry.difference.name);\n if(targetSchemaReference === undefined) {\n return;\n }\n\n const sourceSchemaKey = sourceSchemaReference.schemaKey;\n const targetSchemaKey = targetSchemaReference.schemaKey;\n\n if(targetSchemaReference.isDynamic !== sourceSchemaReference.isDynamic) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceDynamic,\n difference: entry,\n description: \"Cannot update a schema reference to or from a dynamic schema.\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n\n if(entry.changeType === \"modify\" && !targetSchemaReference.isDynamic && !areCompatible(sourceSchemaKey, targetSchemaKey)) {\n return this.addConflict({\n code: ConflictCode.ConflictingReferenceVersion,\n difference: entry,\n description: \"Schema reference cannot be updated, incompatible versions\",\n source: sourceSchemaKey.toString(),\n target: targetSchemaKey.toString(),\n });\n }\n }\n\n /**\n * Shared schema item validation for all types of AnySchemaItemDifference union.\n */\n private async visitSchemaItemDifference(entry: AnySchemaItemDifference, targetSchemaItem: SchemaItem | undefined) {\n // If the item shall be added, but the target schema already has an item with this name,\n // will produce an ConflictingItemName conflict.\n if (entry.changeType === \"add\" && targetSchemaItem !== undefined) {\n this.addConflict({\n code: ConflictCode.ConflictingItemName,\n difference: entry,\n source: entry.schemaType,\n target: targetSchemaItem.schemaItemType,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n return false;\n }\n\n return true;\n }\n\n /**\n * Shared base-class validation for all types of ClassItemDifference union.\n */\n private async visitBaseClassDifference(entry: AnyClassItemDifference, targetClassItem: ECClass) {\n if (\"baseClass\" in entry.difference && entry.difference.baseClass === undefined && targetClassItem.baseClass !== undefined) {\n return this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass cannot be removed, if there has been a baseClass before.\",\n });\n }\n\n if (entry.difference.baseClass === undefined) {\n return;\n }\n\n const sourceBaseClass = await this._sourceSchema.lookupItem(entry.difference.baseClass) as ECClass;\n if (sourceBaseClass.modifier === ECClassModifier.Sealed) {\n return this.addConflict({\n code: ConflictCode.SealedBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass) || null,\n description: \"BaseClass is sealed.\",\n });\n }\n\n if (targetClassItem.baseClass && !await this.derivedFrom(sourceBaseClass, targetClassItem.baseClass)) {\n return this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n difference: entry,\n source: sourceBaseClass.fullName,\n target: resolveLazyItemFullName(targetClassItem.baseClass),\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n }\n }\n\n /**\n * Shared validation for all types of ClassItemDifference union.\n */\n private async visitClassDifference(entry: AnyClassItemDifference) {\n const targetClassItem = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, targetClassItem)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && ECClass.isECClass(targetClassItem)) {\n await this.visitClassModifierDifference(entry, targetClassItem);\n await this.visitBaseClassDifference(entry, targetClassItem);\n }\n }\n\n /**\n * Validation the modifiers of all types of ClassItemDifference union.\n */\n private async visitClassModifierDifference(entry: AnyClassItemDifference, targetClass: ECClass) {\n if (entry.difference.modifier) {\n const changedModifier = parseClassModifier(entry.difference.modifier);\n if (changedModifier !== undefined && changedModifier !== ECClassModifier.None) {\n this.addConflict({\n code: ConflictCode.ConflictingClassModifier,\n difference: entry,\n source: entry.difference.modifier,\n target: classModifierToString(targetClass.modifier),\n description: \"Class has conflicting modifiers.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling ConstantDifference.\n * @internal\n */\n public async visitConstantDifference(entry: ConstantDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling CustomAttributeClassDifference.\n * @internal\n */\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling CustomAttributeDifference.\n * @internal\n */\n public async visitCustomAttributeInstanceDifference(_entry: CustomAttributeDifference) {\n }\n\n /**\n * Visitor implementation for handling EntityClassDifference.\n * @internal\n */\n public async visitEntityClassDifference(entry: EntityClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling EntityClassMixinDifference.\n * @internal\n */\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference) {\n for (const addedMixin of entry.difference) {\n // To validate the added mixins, the instance from the source schema it fetched,\n // otherwise validation gets too complicated as the mixin must not be existing in\n // the current target schema, it could also be added to the schema.\n const sourceMixin = await this._sourceSchema.lookupItem(addedMixin) as Mixin;\n const sourceSchemaItem = await this._sourceSchema.getItem(entry.itemName) as EntityClass;\n if (sourceMixin.appliesTo && !await sourceSchemaItem.is(await sourceMixin.appliesTo)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n difference: entry,\n source: addedMixin,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumerationDifference.\n * @internal\n */\n public async visitEnumerationDifference(entry: EnumerationDifference) {\n const enumeration = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, enumeration)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && Enumeration.isEnumeration(enumeration) && enumeration.type !== undefined) {\n if (entry.difference.type) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n difference: entry,\n source: entry.difference.type,\n target: primitiveTypeToString(enumeration.type),\n description: \"Enumeration has a different primitive type.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling EnumeratorDifference.\n * @internal\n */\n public async visitEnumeratorDifference(entry: EnumeratorDifference) {\n if (entry.changeType !== \"modify\") {\n return;\n }\n\n const enumeration = await this.getTargetSchemaItem(entry.itemName) as Enumeration;\n const enumerator = enumeration.getEnumeratorByName(entry.path);\n if (!enumerator) {\n return;\n }\n\n if (entry.difference.value) {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n difference: entry,\n source: entry.difference.value,\n target: enumerator.value,\n description: \"Enumerators must have unique values.\",\n });\n }\n }\n\n /**\n * Visitor implementation for handling FormatDifference.\n * @internal\n */\n public async visitFormatDifference(entry: FormatDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling InvertedUnitDifference.\n * @internal\n */\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityDifference.\n * @internal\n */\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference) {\n const kindOfQuantity = await this.getTargetSchemaItem(entry.itemName);\n if (!await this.visitSchemaItemDifference(entry, kindOfQuantity)) {\n return;\n }\n\n if (entry.changeType === \"modify\" && KindOfQuantity.isKindOfQuantity(kindOfQuantity)) {\n if (entry.difference.persistenceUnit) {\n this.addConflict({\n code: ConflictCode.ConflictingPersistenceUnit,\n difference: entry,\n source: entry.difference.persistenceUnit,\n target: resolveLazyItemFullName(kindOfQuantity.persistenceUnit),\n description: \"Kind of Quantity has a different persistence unit.\",\n });\n }\n }\n }\n\n /**\n * Visitor implementation for handling MixinClassDifference.\n * @internal\n */\n public async visitMixinDifference(entry: MixinClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling PhenomenonDifference.\n * @internal\n */\n public async visitPhenomenonDifference(entry: PhenomenonDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling ClassPropertyDifference.\n * @internal\n */\n public async visitPropertyDifference(entry: ClassPropertyDifference) {\n const targetClass = await this.getTargetSchemaItem(entry.itemName) as ECClass;\n const propertyKey = this.getTargetProperty(entry.itemName, entry.path);\n const targetProperty = await targetClass.getProperty(propertyKey.propertyName);\n\n const sourceClass = await this._sourceSchema.getItem(entry.itemName) as ECClass;\n const sourceProperty = await sourceClass.getProperty(entry.path) as Property;\n\n // If property shall be added but there is already a property with this name\n // in target, a ConflictingPropertyName is issued.\n if (entry.changeType === \"add\" && targetProperty !== undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n difference: entry,\n source: resolvePropertyTypeName(sourceProperty),\n target: resolvePropertyTypeName(targetProperty),\n description: \"Target class already contains a property with a different type.\",\n });\n }\n\n if (entry.changeType === \"modify\" && targetProperty !== undefined) {\n if (\"kindOfQuantity\" in entry.difference) {\n const sourceKoQ = await sourceProperty.kindOfQuantity;\n const targetKoQ = await targetProperty.kindOfQuantity;\n if(!targetKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: null,\n description: \"The kind of quantity cannot be assiged if the property did not have a kind of quantities before.\",\n });\n }\n\n if(!sourceKoQ) {\n return this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantity,\n difference: entry,\n source: null,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The kind of quantity cannot be undefined if the property had a kind of quantities before.\",\n });\n }\n\n if (resolveLazyItemName(sourceKoQ.persistenceUnit) !== resolveLazyItemName(targetKoQ.persistenceUnit)) {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyKindOfQuantityUnit,\n difference: entry,\n source: entry.difference.kindOfQuantity,\n target: resolveLazyItemFullName(targetProperty.kindOfQuantity),\n description: \"The property has different kind of quantities with conflicting units.\",\n });\n }\n }\n }\n }\n\n /**\n * Visitor implementation for handling PropertyCategoryDifference.\n * @internal\n */\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling RelationshipClassDifference.\n * @internal\n */\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintDifference.\n * @internal\n */\n public async visitRelationshipConstraintDifference(_entry: RelationshipConstraintDifference) {\n }\n\n /**\n * Visitor implementation for handling RelationshipConstraintClassDifference.\n * @internal\n */\n public async visitRelationshipConstraintClassDifference(_entry: RelationshipConstraintClassDifference) {\n }\n\n /**\n * Visitor implementation for handling StructClassDifference.\n * @internal\n */\n public async visitStructClassDifference(entry: StructClassDifference) {\n await this.visitClassDifference(entry);\n }\n\n /**\n * Visitor implementation for handling UnitDifference.\n * @internal\n */\n public async visitUnitDifference(entry: UnitDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling UnitSystemDifference.\n * @internal\n */\n public async visitUnitSystemDifference(entry: UnitSystemDifference) {\n await this.visitSchemaItemDifference(entry, await this.getTargetSchemaItem(entry.itemName));\n }\n\n /**\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\n * @internal\n */\n public async visitKindOfQuantityPresentationFormatDifference(_entry: KindOfQuantityPresentationFormatDifference) {\n }\n\n /**\n * Visitor implementation for handling FormatUnitDifference.\n * @internal\n */\n public async visitFormatUnitDifference(entry: FormatUnitDifference) {\n const targetFormat = await this.getTargetSchemaItem(entry.itemName) as Format;\n\n if (targetFormat.units === undefined) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnit,\n difference: entry,\n source: entry.difference[0].name,\n target: null,\n description: \"The unit cannot be assiged if the format did not have a unit before.\",\n });\n };\n\n const targetUnit = await targetFormat.units[0][0];\n const targetPhenomenon = InvertedUnit.isInvertedUnit(targetUnit)\n ? (await targetUnit.invertsUnit)?.phenomenon\n : targetUnit.phenomenon;\n\n const sourceUnit = await this._sourceSchema.lookupItem(entry.difference[0].name) as Unit | InvertedUnit;\n const sourcePhenomenon = InvertedUnit.isInvertedUnit(sourceUnit)\n ? (await sourceUnit.invertsUnit)?.phenomenon\n : sourceUnit.phenomenon;\n\n if (resolveLazyItemName(targetPhenomenon) !== resolveLazyItemName(sourcePhenomenon)) {\n return this.addConflict({\n code: ConflictCode.ConflictingFormatUnitPhenomenon,\n difference: entry,\n source: entry.difference[0].name,\n target: targetUnit.fullName,\n description: \"Format units has a different phenomenon.\",\n });\n };\n };\n\n /**\n * Visitor implementation for handling FormatUnitLabelDifference.\n * @internal\n */\n public async visitFormatUnitLabelDifference(_entry: FormatUnitLabelDifference) {\n }\n\n /**\n * Recursive synchronous function to figure whether a given class derived from\n * a class with the given baseClass name.\n */\n private async derivedFrom(ecClass: ECClass | undefined, baseClassKey: Readonly<SchemaItemKey>): Promise<boolean> {\n if (ecClass === undefined) {\n return false;\n }\n\n // First check for name which must be same in any case...\n if (ecClass.name === baseClassKey.name) {\n // ... then check if the class is in the same schema as the expected base class...\n if(ecClass.schema.name === baseClassKey.schemaName)\n return true;\n // ... if not, whether it's in the source schema, but then we expect the baseclass\n // to be in the target schema.\n if(ecClass.schema.name === this._sourceSchema.name && baseClassKey.schemaName === this._targetSchema.name)\n return true;\n }\n return this.derivedFrom(await ecClass.baseClass, baseClassKey);\n }\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemFullName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.fullName;\n}\n\n/**\n * Helper method to resolve the schema item name from lazy loaded schema items.\n * @param lazyItem LazyLoaded item\n * @returns The full name of the item or undefined item was not set.\n */\nfunction resolveLazyItemName(lazyItem?: LazyLoadedSchemaItem<SchemaItem>) {\n return lazyItem && lazyItem.name;\n}\n\n/**\n * Helper method to resolve the type name of a property.\n * @param property The property which's type shall be resolved.\n * @returns The (full) name of the properties type.\n */\nfunction resolvePropertyTypeName(property: Property) {\n const [prefix, suffix] = property.isArray() ? [\"[\", \"]\"] : [\"\", \"\"];\n if (property.isEnumeration())\n return `${prefix}${resolveLazyItemFullName(property.enumeration)}${suffix}`;\n if (property.isPrimitive())\n return `${prefix}${primitiveTypeToString(property.primitiveType)}${suffix}`;\n if (property.isStruct())\n return `${prefix}${property.structClass.fullName}${suffix}`;\n if (property.isNavigation())\n return `${prefix}${property.relationshipClass.fullName}${suffix}`;\n return propertyTypeToString(property.propertyType);\n}\n\n/**\n * Checks if the two schemas are compatible. Since the merger will eventually take the most\n * recent schema version, it is sufficient to check if they are write compatible in one direction.\n */\nfunction areCompatible(leftSchemaKey: SchemaKey, rightSchemaKey: SchemaKey): boolean {\n return leftSchemaKey.matches(rightSchemaKey, SchemaMatchType.LatestWriteCompatible)\n || rightSchemaKey.matches(leftSchemaKey, SchemaMatchType.LatestWriteCompatible);\n}\n"]}
@@ -63,7 +63,7 @@ export class SchemaMerger {
63
63
  }
64
64
  throw error;
65
65
  });
66
- if (!schema.customAttributes || !schema.customAttributes.has("CoreCustomAttributes.DynamicSchema")) {
66
+ if (!schema.isDynamic) {
67
67
  throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);
68
68
  }
69
69
  const visitor = new SchemaMergingVisitor({
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAU,aAAa,EAAc,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAclD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OA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AI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAEe,KAAK,CAAC,aAAa,CAA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,aAAa,CAAC,cAAwB,EAAE,IAAI,SAAS,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":["/*---------------------------------------------------------------------------------------------\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.customAttributes || !schema.customAttributes.has(\"CoreCustomAttributes.DynamicSchema\")) {\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
+ {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAU,aAAa,EAAc,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAclD;;;;GAIG;AACH,MAAM,OAAO,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,oBAAoB,CAAC,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,SAAS,CAAC,W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,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-editing",
3
- "version": "5.2.0-dev.8",
3
+ "version": "5.3.0-dev.1",
4
4
  "description": "ECSchema editing and validation API",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-editing.js",
@@ -42,16 +42,16 @@
42
42
  "rimraf": "^6.0.1",
43
43
  "sinon": "^17.0.2",
44
44
  "typescript": "~5.6.2",
45
- "@itwin/ecschema-metadata": "5.2.0-dev.8",
46
- "@itwin/core-bentley": "5.2.0-dev.8",
47
- "@itwin/build-tools": "5.2.0-dev.8",
48
- "@itwin/core-common": "5.2.0-dev.8",
49
- "@itwin/core-quantity": "5.2.0-dev.8"
45
+ "@itwin/core-common": "5.3.0-dev.1",
46
+ "@itwin/build-tools": "5.3.0-dev.1",
47
+ "@itwin/core-quantity": "5.3.0-dev.1",
48
+ "@itwin/core-bentley": "5.3.0-dev.1",
49
+ "@itwin/ecschema-metadata": "5.3.0-dev.1"
50
50
  },
51
51
  "peerDependencies": {
52
- "@itwin/core-bentley": "5.2.0-dev.8",
53
- "@itwin/core-quantity": "5.2.0-dev.8",
54
- "@itwin/ecschema-metadata": "5.2.0-dev.8"
52
+ "@itwin/core-bentley": "5.3.0-dev.1",
53
+ "@itwin/core-quantity": "5.3.0-dev.1",
54
+ "@itwin/ecschema-metadata": "5.3.0-dev.1"
55
55
  },
56
56
  "nyc": {
57
57
  "extends": "./node_modules/@itwin/build-tools/.nycrc"