@itwin/ecschema-editing 4.6.0-dev.8 → 4.6.0

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/lib/cjs/Differencing/SchemaConflicts.d.ts +14 -0
  3. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  4. package/lib/cjs/Differencing/SchemaConflicts.js +15 -2
  5. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  7. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +0 -52
  8. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  9. package/lib/cjs/Differencing/SchemaDifference.d.ts +2 -2
  10. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  11. package/lib/cjs/Differencing/SchemaDifference.js +3 -3
  12. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  13. package/lib/cjs/Editing/Constants.js.map +1 -1
  14. package/lib/cjs/Editing/CustomAttributes.d.ts +1 -1
  15. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  16. package/lib/cjs/Editing/CustomAttributes.js +2 -2
  17. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  18. package/lib/cjs/Editing/ECClasses.d.ts +29 -23
  19. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  20. package/lib/cjs/Editing/ECClasses.js +51 -95
  21. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  22. package/lib/cjs/Editing/Editor.js.map +1 -1
  23. package/lib/cjs/Editing/Entities.d.ts +6 -7
  24. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  25. package/lib/cjs/Editing/Entities.js +7 -27
  26. package/lib/cjs/Editing/Entities.js.map +1 -1
  27. package/lib/cjs/Editing/Formats.js.map +1 -1
  28. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  29. package/lib/cjs/Editing/Mixins.d.ts +6 -2
  30. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  31. package/lib/cjs/Editing/Mixins.js +7 -22
  32. package/lib/cjs/Editing/Mixins.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +2 -2
  34. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.d.ts +8 -0
  36. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.d.ts.map +1 -0
  37. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js +16 -0
  38. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -0
  39. package/lib/cjs/Editing/Mutable/MutableStructProperty.d.ts +8 -0
  40. package/lib/cjs/Editing/Mutable/MutableStructProperty.d.ts.map +1 -0
  41. package/lib/cjs/Editing/Mutable/MutableStructProperty.js +16 -0
  42. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -0
  43. package/lib/cjs/Editing/Properties.d.ts +201 -0
  44. package/lib/cjs/Editing/Properties.d.ts.map +1 -0
  45. package/lib/cjs/Editing/Properties.js +349 -0
  46. package/lib/cjs/Editing/Properties.js.map +1 -0
  47. package/lib/cjs/Editing/RelationshipClasses.d.ts +12 -1
  48. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  49. package/lib/cjs/Editing/RelationshipClasses.js +26 -3
  50. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  51. package/lib/cjs/Editing/Structs.d.ts +1 -1
  52. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  53. package/lib/cjs/Editing/Structs.js +2 -2
  54. package/lib/cjs/Editing/Structs.js.map +1 -1
  55. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  56. package/lib/cjs/Merging/ClassMerger.js +7 -16
  57. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  58. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  59. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  60. package/lib/cjs/Merging/CustomAttributeMerger.js +6 -1
  61. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  62. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  63. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  64. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  65. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  66. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  67. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  68. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  69. package/lib/cjs/Merging/PropertyMerger.js +54 -23
  70. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  71. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  72. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  73. package/lib/cjs/Merging/SchemaMerger.d.ts +1 -1
  74. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  75. package/lib/cjs/Merging/SchemaMerger.js +12 -8
  76. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  77. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  78. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  79. package/lib/cjs/Validation/Diagnostic.d.ts +2 -2
  80. package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
  81. package/lib/cjs/Validation/Diagnostic.js +4 -4
  82. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  83. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  84. package/lib/cjs/Validation/ECRules.d.ts +58 -58
  85. package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
  86. package/lib/cjs/Validation/ECRules.js.map +1 -1
  87. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  88. package/lib/cjs/Validation/SchemaChanges.d.ts +38 -6
  89. package/lib/cjs/Validation/SchemaChanges.d.ts.map +1 -1
  90. package/lib/cjs/Validation/SchemaChanges.js +97 -27
  91. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  92. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  93. package/lib/cjs/Validation/SchemaCompareVisitor.js +4 -3
  94. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  95. package/lib/cjs/Validation/SchemaComparer.d.ts +1 -0
  96. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  97. package/lib/cjs/Validation/SchemaComparer.js +238 -260
  98. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  99. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  100. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  101. package/lib/cjs/ecschema-editing.d.ts +2 -0
  102. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  103. package/lib/cjs/ecschema-editing.js +2 -0
  104. package/lib/cjs/ecschema-editing.js.map +1 -1
  105. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iEAA8D;AAE9D,uEAAoE;AACpE,gEAKkC;AAsBlC;;;GAGG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;AACvC,CAAC,EATW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAS3B;AAQD;;GAEG;AACH,IAAiB,gBAAgB,CAoMhC;AApMD,WAAiB,gBAAgB;IAC/B;;;;;;OAMG;IACI,KAAK,UAAU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CAAC,iBAAiB,CAAC;IACpE,CAAC;IAFe,8CAA6B,gCAE5C,CAAA;IAED;;;OAGG;IACH,SAAgB,kCAAkC,CAAC,UAA+B;QAChF,OAAO,UAAU,CAAC,UAAU,KAAK,gBAAgB,CAAC,sBAAsB,CAAC;IAC3E,CAAC;IAFe,mDAAkC,qCAEjD,CAAA;IAED;;;OAGG;IACH,SAAgB,uCAAuC,CAAC,UAA+B;QACrF,OAAO,UAAU,CAAC,UAAU,KAAK,gBAAgB,CAAC,2BAA2B,CAAC;IAChF,CAAC;IAFe,wDAAuC,0CAEtD,CAAA;AAEH,CAAC,EApMgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAoMhC","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 { SchemaChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\nimport {\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\n} from \"@itwin/ecschema-metadata\";\n\n/** Utility-Type to remove possible readonly flags on the given type. */\ntype PartialEditable<T> = {\n -readonly [P in keyof T]?: T[P];\n};\n\n/**\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\n * that are not needed for the schema differencing. Also all properties are made mutable\n * by removing the readonly flag if present.\n */\ntype SchemaItemProperties<T extends SchemaItemProps> = {\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\n};\n\n/**\n * Defines the type of the difference operation.\n * @alpha\n */\nexport type DifferenceType = \"add\" | \"modify\";\n\n/**\n * Defines the SchemaTypes that are not SchemaItems.\n * @alpha\n */\nexport enum SchemaOtherTypes {\n Schema = \"Schema\",\n SchemaReference = \"SchemaReference\",\n Property = \"Property\",\n Enumerator = \"Enumerator\",\n CustomAttributeInstance = \"CustomAttributeInstance\",\n RelationshipConstraint = \"RelationshipConstraint\",\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\n EntityClassMixin = \"EntityClassMixin\",\n}\n\n/**\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\n * @alpha\n */\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\n\n/**\n * @alpha\n */\nexport namespace SchemaDifference {\n /**\n * Creates a [[SchemaDifference]] for two given schemas.\n * @param targetSchema The schema the differences gets merged into.\n * @param sourceSchema The schema to get merged in the target.\n * @returns An [[SchemaDifference]] object.\n * @alpha\n */\n export async function fromSchemas(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferences> {\n const changesList: SchemaChanges[] = [];\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\n\n return fromSchemaChanges(targetSchema, changesList[0]);\n }\n\n /**\n * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.\n * @param targetSchema\n * @param schemaChanges A changes report of two schemas.\n * @returns An [[SchemaDifference]] object.\n * @internal\n */\n export async function fromSchemaChanges(targetSchema: Schema, schemaChanges: SchemaChanges): Promise<SchemaDifferences> {\n const visitor = new SchemaDiagnosticVisitor();\n for (const diagnostic of schemaChanges.allDiagnostics) {\n visitor.visit(diagnostic);\n }\n\n const changes: AnySchemaDifference[] = [\n ...visitor.schemaChanges,\n ...visitor.schemaItemChanges,\n ...visitor.schemaItemPathChanges,\n ...visitor.customAttributeChanges,\n ];\n\n return {\n sourceSchemaName: schemaChanges.schema.schemaKey.toString(),\n targetSchemaName: targetSchema.schemaKey.toString(),\n changes: changes.length > 0 ? changes : undefined,\n conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,\n };\n }\n\n /**\n * Indicates whether the given difference is type of ConstantDifference.\n * @alpha\n */\n export function isConstantDifference(difference: AnySchemaDifference): difference is ConstantDifference {\n return difference.schemaType === SchemaItemType.Constant;\n }\n\n /**\n * Indicates whether the given difference is type of ClassPropertyDifference.\n * @alpha\n */\n export function isClassPropertyDifference(difference: AnySchemaDifference): difference is ClassPropertyDifference {\n return difference.schemaType === SchemaOtherTypes.Property;\n }\n\n /**\n * Indicates whether the given difference is type of CustomAttributeClassDifference.\n * @alpha\n */\n export function isCustomAttributeClassDifference(difference: AnySchemaDifference): difference is CustomAttributeClassDifference {\n return difference.schemaType === SchemaItemType.CustomAttributeClass;\n }\n\n /**\n * Indicates whether the given difference is type of CustomAttributeDifference.\n * @alpha\n */\n export function isCustomAttributeDifference(difference: AnySchemaDifference): difference is CustomAttributeDifference {\n return difference.schemaType === SchemaOtherTypes.CustomAttributeInstance;\n }\n\n /**\n * Indicates whether the given difference is type of EntityClassDifference.\n * @alpha\n */\n export function isEntityClassDifference(difference: AnySchemaDifference): difference is EntityClassDifference {\n return difference.schemaType === SchemaItemType.EntityClass;\n }\n\n /**\n * Indicates whether the given difference is type of EntityClassMixinDifference.\n * @alpha\n */\n export function isEntityClassMixinDifference(difference: AnySchemaDifference): difference is EntityClassMixinDifference {\n return difference.schemaType === SchemaOtherTypes.EntityClassMixin;\n }\n\n /**\n * Indicates whether the given difference is type of EnumerationDifference.\n * @alpha\n */\n export function isEnumerationDifference(difference: AnySchemaDifference): difference is EnumerationDifference {\n return difference.schemaType === SchemaItemType.Enumeration;\n }\n\n /**\n * Indicates whether the given difference is type of EnumeratorDifference.\n * @alpha\n */\n export function isEnumeratorDifference(difference: AnySchemaDifference): difference is EnumeratorDifference {\n return difference.schemaType === SchemaOtherTypes.Enumerator;\n }\n\n /**\n * Indicates whether the given difference is type of KindOfQuantityDifference.\n * @alpha\n */\n export function isKindOfQuantityDifference(difference: AnySchemaDifference): difference is KindOfQuantityDifference {\n return difference.schemaType === SchemaItemType.KindOfQuantity;\n }\n\n /**\n * Indicates whether the given difference is type of MixinClassDifference.\n * @alpha\n */\n export function isMixinClassDifference(difference: AnySchemaDifference): difference is MixinClassDifference {\n return difference.schemaType === SchemaItemType.Mixin;\n }\n\n /**\n * Indicates whether the given difference is type of PhenomenonDifference.\n * @alpha\n */\n export function isPhenomenonDifference(difference: AnySchemaDifference): difference is PhenomenonDifference {\n return difference.schemaType === SchemaItemType.Phenomenon;\n }\n\n /**\n * Indicates whether the given difference is type of PropertyCategoryDifference.\n * @alpha\n */\n export function isPropertyCategoryDifference(difference: AnySchemaDifference): difference is PropertyCategoryDifference {\n return difference.schemaType === SchemaItemType.PropertyCategory;\n }\n\n /**\n * Indicates whether the given difference is type of SchemaDifference.\n * @alpha\n */\n export function isSchemaDifference(difference: AnySchemaDifference): difference is SchemaDifference {\n return difference.schemaType === SchemaOtherTypes.Schema;\n }\n\n /**\n * Indicates whether the given difference is type of SchemaReferenceDifference.\n * @alpha\n */\n export function isSchemaReferenceDifference(difference: AnySchemaDifference): difference is SchemaReferenceDifference {\n return difference.schemaType === SchemaOtherTypes.SchemaReference;\n }\n\n /**\n * Indicates whether the given difference is type of CustomAttributeDifference.\n * @alpha\n */\n export function isStructClassDifference(difference: AnySchemaDifference): difference is StructClassDifference {\n return difference.schemaType === SchemaItemType.StructClass;\n }\n\n /**\n * Indicates whether the given difference is type of UnitSystemDifference.\n * @alpha\n */\n export function isUnitSystemDifference(difference: AnySchemaDifference): difference is UnitSystemDifference {\n return difference.schemaType === SchemaItemType.UnitSystem;\n }\n\n /**\n * Indicates whether the given difference is type of RelationshipClassDifference.\n * @alpha\n */\n export function isRelationshipClassDifference(difference: AnySchemaDifference): difference is RelationshipClassDifference {\n return difference.schemaType === SchemaItemType.RelationshipClass;\n }\n\n /**\n * Indicates whether the given difference is type of RelationshipConstraintDifference.\n * @alpha\n */\n export function isRelationshipConstraintDifference(difference: AnySchemaDifference): difference is RelationshipConstraintDifference {\n return difference.schemaType === SchemaOtherTypes.RelationshipConstraint;\n }\n\n /**\n * Indicates whether the given difference is type of RelationshipConstraintClassDifference.\n * @alpha\n */\n export function isRelationshipConstraintClassDifference(difference: AnySchemaDifference): difference is RelationshipConstraintClassDifference {\n return difference.schemaType === SchemaOtherTypes.RelationshipConstraintClass;\n }\n\n}\n\n/**\n * Definition of the differences between two Schemas.\n * @alpha\n */\nexport interface SchemaDifferences {\n /** Full name of the source schema */\n readonly sourceSchemaName: string;\n /** Full name of the target schema */\n readonly targetSchemaName: string;\n\n /** List of differences between the compared schemas. */\n readonly changes?: AnySchemaDifference[];\n /** List of conflicts found while comparing the schemas. */\n readonly conflicts?: SchemaDifferenceConflict[];\n}\n\n/**\n * Union of all supported schema differencing types.\n * @alpha\n */\nexport type AnySchemaDifference =\n SchemaDifference |\n SchemaReferenceDifference |\n AnySchemaItemDifference |\n AnySchemaItemPathDifference |\n CustomAttributeDifference;\n\n/**\n * Differencing entry for changes on a Schema.\n * @alpha\n */\nexport interface SchemaDifference {\n readonly changeType: \"modify\";\n readonly schemaType: SchemaOtherTypes.Schema;\n readonly difference: {\n label?: string;\n description?: string;\n };\n}\n\n/**\n * Differencing entry for added or changed Schema References of a Schema.\n * @alpha\n */\nexport interface SchemaReferenceDifference {\n readonly changeType: \"add\" | \"modify\";\n readonly schemaType: SchemaOtherTypes.SchemaReference;\n readonly difference: SchemaReferenceProps;\n}\n\n/**\n * Union of all supported schema item differencing types.\n * @alpha\n */\nexport type AnySchemaItemDifference =\n ClassItemDifference |\n ConstantDifference |\n EnumerationDifference |\n EntityClassMixinDifference |\n FormatDifference |\n KindOfQuantityDifference |\n InvertedUnitDifference |\n PhenomenonDifference |\n PropertyCategoryDifference |\n UnitDifference |\n UnitSystemDifference;\n\n/**\n * Union for supported class Schema Items.\n * @internal\n */\nexport type ClassItemDifference =\n EntityClassDifference |\n MixinClassDifference |\n StructClassDifference |\n CustomAttributeClassDifference |\n RelationshipClassDifference;\n\n/**\n * Union of all differences that have a path pointing inside a schema item.\n * @alpha\n */\nexport type AnySchemaItemPathDifference =\n RelationshipConstraintDifference |\n RelationshipConstraintClassDifference |\n CustomAttributePropertyDifference |\n EnumeratorDifference |\n ClassPropertyDifference;\n\n/**\n * Internal base class for all Schema Item differencing entries.\n * @alpha\n */\ninterface SchemaItemDifference<T extends SchemaItemProps> {\n readonly changeType: \"add\" | \"modify\";\n readonly itemName: string;\n readonly difference: SchemaItemProperties<T>;\n}\n\n/**\n * Differencing entry for Constant Schema Items.\n * @alpha\n */\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\n readonly schemaType: SchemaItemType.Constant;\n}\n\n/**\n * Differencing entry for Custom Attribute Class Schema Items.\n * @alpha\n */\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\n readonly schemaType: SchemaItemType.CustomAttributeClass;\n}\n\n/**\n * Differencing entry for Entity Class Schema Items.\n * @alpha\n */\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\n readonly schemaType: SchemaItemType.EntityClass;\n}\n\n/**\n * Differencing entry for Enumerator Schema Items.\n * @alpha\n */\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\n readonly schemaType: SchemaItemType.Enumeration;\n}\n\n/**\n * Differencing entry for Kind-Of-Quantities Schema Items.\n * @alpha\n */\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\n readonly schemaType: SchemaItemType.KindOfQuantity;\n}\n\n/**\n * Differencing entry for Mixin Class Schema Items.\n * @alpha\n */\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\n readonly schemaType: SchemaItemType.Mixin;\n}\n\n/**\n * Differencing entry for Phenomenon Schema Items.\n * @alpha\n */\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\n readonly schemaType: SchemaItemType.Phenomenon;\n}\n\n/**\n * Differencing entry for Property Category Schema Items.\n * @alpha\n */\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\n readonly schemaType: SchemaItemType.PropertyCategory;\n}\n\n/**\n * Differencing entry for Relationship Class Schema Items.\n * @alpha\n */\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\n readonly schemaType: SchemaItemType.RelationshipClass;\n}\n\n/**\n * Differencing entry for Struct Class Schema Items.\n * @alpha\n */\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\n readonly schemaType: SchemaItemType.StructClass;\n}\n\n/**\n * Differencing entry for Unit System Schema Items.\n * @alpha\n */\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\n readonly schemaType: SchemaItemType.UnitSystem;\n}\n\n/**\n * Differencing entry for Unit Schema Items.\n * @alpha\n */\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\n readonly schemaType: SchemaItemType.Unit;\n}\n\n/**\n * Differencing entry for Inverted Unit Schema Items.\n * @alpha\n */\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\n readonly schemaType: SchemaItemType.InvertedUnit;\n}\n/**\n * Differencing entry for Format Schema Items.\n * @alpha\n */\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\n readonly schemaType: SchemaItemType.Format;\n}\n\n/**\n * Differencing entry for added or changed Properties.\n * @alpha\n */\nexport interface ClassPropertyDifference {\n readonly changeType: \"add\" | \"modify\";\n readonly schemaType: SchemaOtherTypes.Property;\n readonly itemName: string;\n readonly path: string;\n readonly difference: PartialEditable<AnyPropertyProps>;\n}\n\n/**\n * Union of supported Custom Attribute Differences.\n * @alpha\n */\nexport type CustomAttributeDifference =\n CustomAttributeSchemaDifference |\n CustomAttributeSchemaItemDifference |\n CustomAttributePropertyDifference |\n CustomAttributeRelationshipConstraintDifference;\n\n/**\n * Differencing entry for Custom Attributes on Schema.\n * @alpha\n */\nexport interface CustomAttributeSchemaDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"Schema\";\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for Custom Attributes on Schema Items.\n * @alpha\n */\nexport interface CustomAttributeSchemaItemDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"SchemaItem\";\n readonly itemName: string;\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for Custom Attributes on Properties.\n * @alpha\n */\nexport interface CustomAttributePropertyDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"Property\";\n readonly itemName: string;\n readonly path: string;\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for Custom Attributes on Relationship Constraints.\n * @alpha\n */\nexport interface CustomAttributeRelationshipConstraintDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"RelationshipConstraint\";\n readonly itemName: string;\n readonly path: \"$source\" | \"$target\";\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for changed mixins on EntityClasses.\n * @alpha\n */\nexport interface EntityClassMixinDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\n readonly itemName: string;\n readonly difference: string[];\n}\n\n/**\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\n * @alpha\n */\nexport interface EnumeratorDifference {\n readonly changeType: \"add\" | \"modify\";\n readonly schemaType: SchemaOtherTypes.Enumerator;\n readonly itemName: string;\n readonly path: string;\n readonly difference: PartialEditable<AnyEnumerator>;\n}\n\n/**\n * Differencing entry for Relationship Constraints.\n * @alpha\n */\nexport interface RelationshipConstraintDifference {\n readonly changeType: \"modify\";\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\n readonly itemName: string;\n readonly path: \"$source\" | \"$target\";\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\n}\n\n/**\n * Differencing entry for constraint classes added to Relationship Constrains.\n * @alpha\n */\nexport interface RelationshipConstraintClassDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\n readonly itemName: string;\n readonly path: \"$source\" | \"$target\";\n readonly difference: string[];\n}\n"]}
1
+ {"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iEAA8D;AAE9D,uEAAoE;AACpE,gEAKkC;AAsBlC;;;GAGG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;AACvC,CAAC,EATW,gBAAgB,gCAAhB,gBAAgB,QAS3B;AAQD;;GAEG;AACH,IAAiB,gBAAgB,CAmMhC;AAnMD,WAAiB,gBAAgB;IAC/B;;;;;;OAMG;IACI,KAAK,UAAU,WAAW,CAAC,YAAoB,EAAE,YAAoB;QAC1E,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC1F,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAEhE,OAAO,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,CAA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AgB,QAmMhC","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 { SchemaChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\nimport {\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\n} from \"@itwin/ecschema-metadata\";\n\n/** Utility-Type to remove possible readonly flags on the given type. */\ntype PartialEditable<T> = {\n -readonly [P in keyof T]?: T[P];\n};\n\n/**\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\n * that are not needed for the schema differencing. Also all properties are made mutable\n * by removing the readonly flag if present.\n */\ntype SchemaItemProperties<T extends SchemaItemProps> = {\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\n};\n\n/**\n * Defines the type of the difference operation.\n * @alpha\n */\nexport type DifferenceType = \"add\" | \"modify\";\n\n/**\n * Defines the SchemaTypes that are not SchemaItems.\n * @alpha\n */\nexport enum SchemaOtherTypes {\n Schema = \"Schema\",\n SchemaReference = \"SchemaReference\",\n Property = \"Property\",\n Enumerator = \"Enumerator\",\n CustomAttributeInstance = \"CustomAttributeInstance\",\n RelationshipConstraint = \"RelationshipConstraint\",\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\n EntityClassMixin = \"EntityClassMixin\",\n}\n\n/**\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\n * @alpha\n */\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\n\n/**\n * @alpha\n */\nexport namespace SchemaDifference {\n /**\n * Creates a [[SchemaDifference]] for two given schemas.\n * @param targetSchema The schema the differences gets merged into.\n * @param sourceSchema The schema to get merged in the target.\n * @returns An [[SchemaDifference]] object.\n * @alpha\n */\n export async function fromSchemas(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferences> {\n const changesList: SchemaChanges[] = [];\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\n\n return fromSchemaChanges(targetSchema, changesList[0]);\n }\n\n /**\n * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.\n * @param targetSchema\n * @param schemaChanges A changes report of two schemas.\n * @returns An [[SchemaDifference]] object.\n * @internal\n */\n export async function fromSchemaChanges(targetSchema: Schema, schemaChanges: SchemaChanges): Promise<SchemaDifferences> {\n const visitor = new SchemaDiagnosticVisitor();\n for (const diagnostic of schemaChanges.allDiagnostics) {\n visitor.visit(diagnostic);\n }\n\n const changes: AnySchemaDifference[] = [\n ...visitor.schemaChanges,\n ...visitor.schemaItemChanges,\n ...visitor.schemaItemPathChanges,\n ...visitor.customAttributeChanges,\n ];\n\n return {\n sourceSchemaName: schemaChanges.schema.schemaKey.toString(),\n targetSchemaName: targetSchema.schemaKey.toString(),\n conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,\n changes,\n };\n }\n\n /**\n * Indicates whether the given difference is type of ConstantDifference.\n * @alpha\n */\n export function isConstantDifference(difference: AnySchemaDifference): difference is ConstantDifference {\n return difference.schemaType === SchemaItemType.Constant;\n }\n\n /**\n * Indicates whether the given difference is type of ClassPropertyDifference.\n * @alpha\n */\n export function isClassPropertyDifference(difference: AnySchemaDifference): difference is ClassPropertyDifference {\n return difference.schemaType === SchemaOtherTypes.Property;\n }\n\n /**\n * Indicates whether the given difference is type of CustomAttributeClassDifference.\n * @alpha\n */\n export function isCustomAttributeClassDifference(difference: AnySchemaDifference): difference is CustomAttributeClassDifference {\n return difference.schemaType === SchemaItemType.CustomAttributeClass;\n }\n\n /**\n * Indicates whether the given difference is type of CustomAttributeDifference.\n * @alpha\n */\n export function isCustomAttributeDifference(difference: AnySchemaDifference): difference is CustomAttributeDifference {\n return difference.schemaType === SchemaOtherTypes.CustomAttributeInstance;\n }\n\n /**\n * Indicates whether the given difference is type of EntityClassDifference.\n * @alpha\n */\n export function isEntityClassDifference(difference: AnySchemaDifference): difference is EntityClassDifference {\n return difference.schemaType === SchemaItemType.EntityClass;\n }\n\n /**\n * Indicates whether the given difference is type of EntityClassMixinDifference.\n * @alpha\n */\n export function isEntityClassMixinDifference(difference: AnySchemaDifference): difference is EntityClassMixinDifference {\n return difference.schemaType === SchemaOtherTypes.EntityClassMixin;\n }\n\n /**\n * Indicates whether the given difference is type of EnumerationDifference.\n * @alpha\n */\n export function isEnumerationDifference(difference: AnySchemaDifference): difference is EnumerationDifference {\n return difference.schemaType === SchemaItemType.Enumeration;\n }\n\n /**\n * Indicates whether the given difference is type of EnumeratorDifference.\n * @alpha\n */\n export function isEnumeratorDifference(difference: AnySchemaDifference): difference is EnumeratorDifference {\n return difference.schemaType === SchemaOtherTypes.Enumerator;\n }\n\n /**\n * Indicates whether the given difference is type of KindOfQuantityDifference.\n * @alpha\n */\n export function isKindOfQuantityDifference(difference: AnySchemaDifference): difference is KindOfQuantityDifference {\n return difference.schemaType === SchemaItemType.KindOfQuantity;\n }\n\n /**\n * Indicates whether the given difference is type of MixinClassDifference.\n * @alpha\n */\n export function isMixinClassDifference(difference: AnySchemaDifference): difference is MixinClassDifference {\n return difference.schemaType === SchemaItemType.Mixin;\n }\n\n /**\n * Indicates whether the given difference is type of PhenomenonDifference.\n * @alpha\n */\n export function isPhenomenonDifference(difference: AnySchemaDifference): difference is PhenomenonDifference {\n return difference.schemaType === SchemaItemType.Phenomenon;\n }\n\n /**\n * Indicates whether the given difference is type of PropertyCategoryDifference.\n * @alpha\n */\n export function isPropertyCategoryDifference(difference: AnySchemaDifference): difference is PropertyCategoryDifference {\n return difference.schemaType === SchemaItemType.PropertyCategory;\n }\n\n /**\n * Indicates whether the given difference is type of SchemaDifference.\n * @alpha\n */\n export function isSchemaDifference(difference: AnySchemaDifference): difference is SchemaDifference {\n return difference.schemaType === SchemaOtherTypes.Schema;\n }\n\n /**\n * Indicates whether the given difference is type of SchemaReferenceDifference.\n * @alpha\n */\n export function isSchemaReferenceDifference(difference: AnySchemaDifference): difference is SchemaReferenceDifference {\n return difference.schemaType === SchemaOtherTypes.SchemaReference;\n }\n\n /**\n * Indicates whether the given difference is type of CustomAttributeDifference.\n * @alpha\n */\n export function isStructClassDifference(difference: AnySchemaDifference): difference is StructClassDifference {\n return difference.schemaType === SchemaItemType.StructClass;\n }\n\n /**\n * Indicates whether the given difference is type of UnitSystemDifference.\n * @alpha\n */\n export function isUnitSystemDifference(difference: AnySchemaDifference): difference is UnitSystemDifference {\n return difference.schemaType === SchemaItemType.UnitSystem;\n }\n\n /**\n * Indicates whether the given difference is type of RelationshipClassDifference.\n * @alpha\n */\n export function isRelationshipClassDifference(difference: AnySchemaDifference): difference is RelationshipClassDifference {\n return difference.schemaType === SchemaItemType.RelationshipClass;\n }\n\n /**\n * Indicates whether the given difference is type of RelationshipConstraintDifference.\n * @alpha\n */\n export function isRelationshipConstraintDifference(difference: AnySchemaDifference): difference is RelationshipConstraintDifference {\n return difference.schemaType === SchemaOtherTypes.RelationshipConstraint;\n }\n\n /**\n * Indicates whether the given difference is type of RelationshipConstraintClassDifference.\n * @alpha\n */\n export function isRelationshipConstraintClassDifference(difference: AnySchemaDifference): difference is RelationshipConstraintClassDifference {\n return difference.schemaType === SchemaOtherTypes.RelationshipConstraintClass;\n }\n}\n\n/**\n * Definition of the differences between two Schemas.\n * @alpha\n */\nexport interface SchemaDifferences {\n /** Full name of the source schema */\n readonly sourceSchemaName: string;\n /** Full name of the target schema */\n readonly targetSchemaName: string;\n\n /** List of differences between the compared schemas. */\n readonly changes: AnySchemaDifference[];\n\n /** List of conflicts found while comparing the schemas. */\n readonly conflicts?: SchemaDifferenceConflict[];\n}\n\n/**\n * Union of all supported schema differencing types.\n * @alpha\n */\nexport type AnySchemaDifference =\n SchemaDifference |\n SchemaReferenceDifference |\n AnySchemaItemDifference |\n AnySchemaItemPathDifference |\n CustomAttributeDifference;\n\n/**\n * Differencing entry for changes on a Schema.\n * @alpha\n */\nexport interface SchemaDifference {\n readonly changeType: \"modify\";\n readonly schemaType: SchemaOtherTypes.Schema;\n readonly difference: {\n label?: string;\n description?: string;\n };\n}\n\n/**\n * Differencing entry for added or changed Schema References of a Schema.\n * @alpha\n */\nexport interface SchemaReferenceDifference {\n readonly changeType: \"add\" | \"modify\";\n readonly schemaType: SchemaOtherTypes.SchemaReference;\n readonly difference: SchemaReferenceProps;\n}\n\n/**\n * Union of all supported schema item differencing types.\n * @alpha\n */\nexport type AnySchemaItemDifference =\n ClassItemDifference |\n ConstantDifference |\n EnumerationDifference |\n EntityClassMixinDifference |\n FormatDifference |\n KindOfQuantityDifference |\n InvertedUnitDifference |\n PhenomenonDifference |\n PropertyCategoryDifference |\n UnitDifference |\n UnitSystemDifference;\n\n/**\n * Union for supported class Schema Items.\n * @alpha\n */\nexport type ClassItemDifference =\n EntityClassDifference |\n MixinClassDifference |\n StructClassDifference |\n CustomAttributeClassDifference |\n RelationshipClassDifference;\n\n/**\n * Union of all differences that have a path pointing inside a schema item.\n * @alpha\n */\nexport type AnySchemaItemPathDifference =\n RelationshipConstraintDifference |\n RelationshipConstraintClassDifference |\n CustomAttributePropertyDifference |\n EnumeratorDifference |\n ClassPropertyDifference;\n\n/**\n * Internal base class for all Schema Item differencing entries.\n * @alpha\n */\ninterface SchemaItemDifference<T extends SchemaItemProps> {\n readonly changeType: \"add\" | \"modify\";\n readonly itemName: string;\n readonly difference: SchemaItemProperties<T>;\n}\n\n/**\n * Differencing entry for Constant Schema Items.\n * @alpha\n */\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\n readonly schemaType: SchemaItemType.Constant;\n}\n\n/**\n * Differencing entry for Custom Attribute Class Schema Items.\n * @alpha\n */\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\n readonly schemaType: SchemaItemType.CustomAttributeClass;\n}\n\n/**\n * Differencing entry for Entity Class Schema Items.\n * @alpha\n */\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\n readonly schemaType: SchemaItemType.EntityClass;\n}\n\n/**\n * Differencing entry for Enumerator Schema Items.\n * @alpha\n */\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\n readonly schemaType: SchemaItemType.Enumeration;\n}\n\n/**\n * Differencing entry for Kind-Of-Quantities Schema Items.\n * @alpha\n */\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\n readonly schemaType: SchemaItemType.KindOfQuantity;\n}\n\n/**\n * Differencing entry for Mixin Class Schema Items.\n * @alpha\n */\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\n readonly schemaType: SchemaItemType.Mixin;\n}\n\n/**\n * Differencing entry for Phenomenon Schema Items.\n * @alpha\n */\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\n readonly schemaType: SchemaItemType.Phenomenon;\n}\n\n/**\n * Differencing entry for Property Category Schema Items.\n * @alpha\n */\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\n readonly schemaType: SchemaItemType.PropertyCategory;\n}\n\n/**\n * Differencing entry for Relationship Class Schema Items.\n * @alpha\n */\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\n readonly schemaType: SchemaItemType.RelationshipClass;\n}\n\n/**\n * Differencing entry for Struct Class Schema Items.\n * @alpha\n */\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\n readonly schemaType: SchemaItemType.StructClass;\n}\n\n/**\n * Differencing entry for Unit System Schema Items.\n * @alpha\n */\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\n readonly schemaType: SchemaItemType.UnitSystem;\n}\n\n/**\n * Differencing entry for Unit Schema Items.\n * @alpha\n */\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\n readonly schemaType: SchemaItemType.Unit;\n}\n\n/**\n * Differencing entry for Inverted Unit Schema Items.\n * @alpha\n */\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\n readonly schemaType: SchemaItemType.InvertedUnit;\n}\n/**\n * Differencing entry for Format Schema Items.\n * @alpha\n */\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\n readonly schemaType: SchemaItemType.Format;\n}\n\n/**\n * Differencing entry for added or changed Properties.\n * @alpha\n */\nexport interface ClassPropertyDifference {\n readonly changeType: \"add\" | \"modify\";\n readonly schemaType: SchemaOtherTypes.Property;\n readonly itemName: string;\n readonly path: string;\n readonly difference: PartialEditable<AnyPropertyProps>;\n}\n\n/**\n * Union of supported Custom Attribute Differences.\n * @alpha\n */\nexport type CustomAttributeDifference =\n CustomAttributeSchemaDifference |\n CustomAttributeSchemaItemDifference |\n CustomAttributePropertyDifference |\n CustomAttributeRelationshipConstraintDifference;\n\n/**\n * Differencing entry for Custom Attributes on Schema.\n * @alpha\n */\nexport interface CustomAttributeSchemaDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"Schema\";\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for Custom Attributes on Schema Items.\n * @alpha\n */\nexport interface CustomAttributeSchemaItemDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"SchemaItem\";\n readonly itemName: string;\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for Custom Attributes on Properties.\n * @alpha\n */\nexport interface CustomAttributePropertyDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"Property\";\n readonly itemName: string;\n readonly path: string;\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for Custom Attributes on Relationship Constraints.\n * @alpha\n */\nexport interface CustomAttributeRelationshipConstraintDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\n readonly appliedTo: \"RelationshipConstraint\";\n readonly itemName: string;\n readonly path: \"$source\" | \"$target\";\n readonly difference: PartialEditable<CustomAttribute>;\n}\n\n/**\n * Differencing entry for changed mixins on EntityClasses.\n * @alpha\n */\nexport interface EntityClassMixinDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\n readonly itemName: string;\n readonly difference: string[];\n}\n\n/**\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\n * @alpha\n */\nexport interface EnumeratorDifference {\n readonly changeType: \"add\" | \"modify\";\n readonly schemaType: SchemaOtherTypes.Enumerator;\n readonly itemName: string;\n readonly path: string;\n readonly difference: PartialEditable<AnyEnumerator>;\n}\n\n/**\n * Differencing entry for Relationship Constraints.\n * @alpha\n */\nexport interface RelationshipConstraintDifference {\n readonly changeType: \"modify\";\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\n readonly itemName: string;\n readonly path: \"$source\" | \"$target\";\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\n}\n\n/**\n * Differencing entry for constraint classes added to Relationship Constrains.\n * @alpha\n */\nexport interface RelationshipConstraintClassDifference {\n readonly changeType: \"add\";\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\n readonly itemName: string;\n readonly path: \"$source\" | \"$target\";\n readonly difference: string[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/Editing/Constants.ts"],"names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;QAEtC,IAAI,WAAW;YACb,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,YAAY;YACd,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,aAA4B;QAC7E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS;YAClC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,IAAI,WAAW,KAAK,SAAS;YAC3B,OAAO,EAAE,YAAY,EAAE,0BAA0B,aAAa,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEjH,MAAM,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC1C,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;CACF;AApDD,8BAoDC","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 Editing\n */\n\nimport { ConstantProps, DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableConstant } from \"./Mutable/MutableConstant\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Constant.\n */\nexport class Constants {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newConstant = (await schema.createConstant(name)) as MutableConstant;\n if (newConstant === undefined) {\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n }\n\n const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem<Phenomenon>(phenomenon));\n if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== SchemaItemType.Phenomenon) {\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };\n }\n newConstant.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(newPhenomenon.key, async () => newPhenomenon));\n newConstant.setDefinition(definition);\n\n if (numerator)\n newConstant.setNumerator(numerator);\n\n if (denominator)\n newConstant.setDenominator(denominator);\n\n if (displayLabel)\n newConstant.setDisplayLabel(displayLabel);\n\n return { itemKey: newConstant.key };\n }\n\n /**\n * Creates a Constant through a ConstantProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, constantProps: ConstantProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (constantProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newConstant = (await schema.createConstant(constantProps.name));\n if (newConstant === undefined)\n return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newConstant.fromJSON(constantProps);\n return { itemKey: newConstant.key };\n }\n}\n"]}
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/Editing/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwI;AAIxI;;;GAGG;AACH,MAAa,SAAS;IACpB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAyB,EAAE,UAAkB,EAAE,YAAqB,EAAE,SAAkB,EAAE,WAAoB;QACpK,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAoB,CAAC;QAC3E,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACnG,CAAC;QAED,MAAM,aAAa,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAa,UAAU,CAAC,CAAC,CAAC;QACrG,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,CAAC,cAAc,KAAK,kCAAc,CAAC,UAAU,EAAE,CAAC;YAC9F,OAAO,EAAE,YAAY,EAAE,+BAA+B,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5E,CAAC;QACD,WAAW,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,aAAa,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;QAChI,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAEtC,IAAI,SAAS;YACX,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEtC,IAAI,WAAW;YACb,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,YAAY;YACd,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,aAA4B;QAC7E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS;YAClC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,IAAI,WAAW,KAAK,SAAS;YAC3B,OAAO,EAAE,YAAY,EAAE,0BAA0B,aAAa,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEjH,MAAM,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC1C,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;CACF;AApDD,8BAoDC","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 Editing\n */\n\nimport { ConstantProps, DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableConstant } from \"./Mutable/MutableConstant\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Constant.\n */\nexport class Constants {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newConstant = (await schema.createConstant(name)) as MutableConstant;\n if (newConstant === undefined) {\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n }\n\n const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem<Phenomenon>(phenomenon));\n if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== SchemaItemType.Phenomenon) {\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };\n }\n newConstant.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(newPhenomenon.key, async () => newPhenomenon));\n newConstant.setDefinition(definition);\n\n if (numerator)\n newConstant.setNumerator(numerator);\n\n if (denominator)\n newConstant.setDenominator(denominator);\n\n if (displayLabel)\n newConstant.setDisplayLabel(displayLabel);\n\n return { itemKey: newConstant.key };\n }\n\n /**\n * Creates a Constant through a ConstantProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, constantProps: ConstantProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (constantProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newConstant = (await schema.createConstant(constantProps.name));\n if (newConstant === undefined)\n return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newConstant.fromJSON(constantProps);\n return { itemKey: newConstant.key };\n }\n}\n"]}
@@ -9,7 +9,7 @@ import { ECClasses } from "./ECClasses";
9
9
  * A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.
10
10
  */
11
11
  export declare class CustomAttributes extends ECClasses {
12
- constructor(_schemaEditor: SchemaContextEditor);
12
+ constructor(schemaEditor: SchemaContextEditor);
13
13
  create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
14
14
  /**
15
15
  * Creates a CustomAttributeClass through a CustomAttributeClassProps.
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributes.d.ts","sourceRoot":"","sources":["../../../src/Editing/CustomAttributes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,yBAAyB,EAAE,4BAA4B,EACvD,aAAa,EAAkB,SAAS,EACzC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBAC1B,aAAa,EAAE,mBAAmB;IAIxC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,4BAA4B,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA4BtL;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgBvH"}
1
+ {"version":3,"file":"CustomAttributes.d.ts","sourceRoot":"","sources":["../../../src/Editing/CustomAttributes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,yBAAyB,EAAE,4BAA4B,EACvD,aAAa,EAAkB,SAAS,EACzC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBAC1B,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,4BAA4B,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA4BtL;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgBvH"}
@@ -15,8 +15,8 @@ const ECClasses_1 = require("./ECClasses");
15
15
  * A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.
16
16
  */
17
17
  class CustomAttributes extends ECClasses_1.ECClasses {
18
- constructor(_schemaEditor) {
19
- super(_schemaEditor);
18
+ constructor(schemaEditor) {
19
+ super(ecschema_metadata_1.SchemaItemType.CustomAttributeClass, schemaEditor);
20
20
  }
21
21
  async create(schemaKey, name, containerType, displayLabel, baseClass) {
22
22
  const schema = await this._schemaEditor.getSchema(schemaKey);
@@ -1 +1 @@
1
- {"version":3,"file":"CustomAttributes.js","sourceRoot":"","sources":["../../../src/Editing/CustomAttributes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2C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gBAAgB,CAAC,aAAa,CAAC,CAAC;QAEzC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,OAAkC;QACnF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAC5B,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,0BAA0B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAmB,CAAC;QAC3F,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,OAAO,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE3G,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAtDD,4CAsDC","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 Editing\n */\n\nimport {\n CustomAttributeClassProps, CustomAttributeContainerType, DelayedPromiseWithProps, ECClass,\n SchemaItemKey, SchemaItemType, SchemaKey,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableCAClass } from \"./Mutable/MutableCAClass\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.\n */\nexport class CustomAttributes extends ECClasses {\n public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newClass = (await schema.createCustomAttributeClass(name)) as MutableCAClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (baseClass !== undefined) {\n const baseClassItem = await schema.lookupItem<ECClass>(baseClass);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.CustomAttributeClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type CustomAttribute Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\n }\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n newClass.setContainerType(containerType);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Creates a CustomAttributeClass through a CustomAttributeClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (caProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createCustomAttributeClass(caProps.name)) as MutableCAClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newClass.fromJSON(caProps);\n\n return { itemKey: newClass.key };\n }\n}\n"]}
1
+ {"version":3,"file":"CustomAttributes.js","sourceRoot":"","sources":["../../../src/Editing/CustomAttributes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAGxC;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,qBAAS;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,aAA2C,EAAE,YAAqB,EAAE,SAAyB;QACnJ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAmB,CAAC;QACnF,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAEnG,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,UAAU,CAAU,SAAS,CAAC,CAAC;YAClE,IAAI,aAAa,KAAK,SAAS;gBAC7B,OAAO,EAAE,YAAY,EAAE,+BAA+B,SAAS,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;YAE7G,IAAI,aAAa,CAAC,cAAc,KAAK,kCAAc,CAAC,oBAAoB;gBACtE,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC,QAAQ,wCAAwC,EAAE,CAAC;YAE7F,QAAQ,CAAC,SAAS,GAAG,IAAI,2CAAuB,CAAyB,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC,CAAC;QACjH,CAAC;QAED,IAAI,YAAY;YACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEzC,QAAQ,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAEzC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,OAAkC;QACnF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAC5B,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,0BAA0B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAmB,CAAC;QAC3F,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,EAAE,YAAY,EAAE,0BAA0B,OAAO,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE3G,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AAtDD,4CAsDC","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 Editing\n */\n\nimport {\n CustomAttributeClassProps, CustomAttributeContainerType, DelayedPromiseWithProps, ECClass,\n SchemaItemKey, SchemaItemType, SchemaKey,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableCAClass } from \"./Mutable/MutableCAClass\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.\n */\nexport class CustomAttributes extends ECClasses {\n public constructor(schemaEditor: SchemaContextEditor) {\n super(SchemaItemType.CustomAttributeClass, schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newClass = (await schema.createCustomAttributeClass(name)) as MutableCAClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (baseClass !== undefined) {\n const baseClassItem = await schema.lookupItem<ECClass>(baseClass);\n if (baseClassItem === undefined)\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\n\n if (baseClassItem.schemaItemType !== SchemaItemType.CustomAttributeClass)\n return { errorMessage: `${baseClassItem.fullName} is not of type CustomAttribute Class.` };\n\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\n }\n\n if (displayLabel)\n newClass.setDisplayLabel(displayLabel);\n\n newClass.setContainerType(containerType);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Creates a CustomAttributeClass through a CustomAttributeClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (caProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newClass = (await schema.createCustomAttributeClass(caProps.name)) as MutableCAClass;\n if (newClass === undefined)\n return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newClass.fromJSON(caProps);\n\n return { itemKey: newClass.key };\n }\n}\n"]}
@@ -1,15 +1,38 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { CustomAttribute, CustomAttributeContainerProps, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
4
+ import { CustomAttribute, CustomAttributeContainerProps, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
5
5
  import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
+ import { ArrayProperties, EnumerationProperties, PrimitiveProperties, Properties, StructProperties } from "./Properties";
7
+ export type ECClassSchemaItems = SchemaItemType.EntityClass | SchemaItemType.StructClass | SchemaItemType.RelationshipClass | SchemaItemType.Mixin | SchemaItemType.CustomAttributeClass;
6
8
  /**
7
9
  * @alpha
8
10
  * Acts as a base class for schema class creation. Enables property creation.
9
11
  */
10
12
  export declare class ECClasses {
13
+ protected schemaItemType: ECClassSchemaItems;
11
14
  protected _schemaEditor: SchemaContextEditor;
12
- protected constructor(_schemaEditor: SchemaContextEditor);
15
+ protected constructor(schemaItemType: ECClassSchemaItems, _schemaEditor: SchemaContextEditor);
16
+ /**
17
+ * Allows access for editing of base Property attributes.
18
+ */
19
+ readonly properties: Properties;
20
+ /**
21
+ * Allows access for editing of ArrayProperty attributes.
22
+ */
23
+ readonly arrayProperties: ArrayProperties;
24
+ /**
25
+ * Allows access for editing of PrimitiveProperty attributes.
26
+ */
27
+ readonly primitiveProperties: PrimitiveProperties;
28
+ /**
29
+ * Allows access for editing of EnumerationProperty attributes.
30
+ */
31
+ readonly enumerationProperties: EnumerationProperties;
32
+ /**
33
+ * Allows access for editing of StructProperty attributes.
34
+ */
35
+ readonly structProperties: StructProperties;
13
36
  /**
14
37
  * Creates a property on class identified by the given SchemaItemKey. This method restricts the
15
38
  * property type to primitives of type Double, String, DateTime and Integer.
@@ -44,22 +67,6 @@ export declare class ECClasses {
44
67
  * @param customAttribute The CustomAttribute instance to add.
45
68
  */
46
69
  addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults>;
47
- /**
48
- * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.
49
- * @param classKey The SchemaItemKey identifying the class.
50
- * @param propertyName The name of the property.
51
- * @param customAttribute The CustomAttribute instance to add.
52
- */
53
- addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults>;
54
- /**
55
- * Renames the property on the specified class. The rename will fail if the new
56
- * name causes a conflict with a base or derived property. All derived classes
57
- * containing a property override will be renamed, as well.
58
- * @param classKey The SchemaItemKey identifying the class.
59
- * @param existingPropertyName The name of the property.
60
- * @param newPropertyName The new property name.
61
- */
62
- setPropertyName(classKey: SchemaItemKey, existingPropertyName: string, newPropertyName: string): Promise<PropertyEditResults>;
63
70
  /**
64
71
  * Sets the name of the ECClass.
65
72
  * @param classKey The SchemaItemKey of the class.
@@ -68,12 +75,11 @@ export declare class ECClasses {
68
75
  */
69
76
  setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults>;
70
77
  /**
71
- * Sets the Category to the Property.
72
- * @param classKey The SchemaItemKey of the class.
73
- * @param propertyName The name of the property.
74
- * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.
78
+ * Sets the base class of a SchemaItem.
79
+ * @param itemKey The SchemaItemKey of the Item.
80
+ * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.
75
81
  */
76
- setPropertyCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey): Promise<PropertyEditResults>;
82
+ setBaseClass(itemKey: SchemaItemKey, baseClassKey?: SchemaItemKey): Promise<SchemaItemEditResults>;
77
83
  private getClass;
78
84
  protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): void;
79
85
  private findDerivedClasses;
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.d.ts","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,6BAA6B,EAEqB,WAAW,EAAE,wBAAwB,EAAE,2BAA2B,EACpH,sBAAsB,EAAE,aAAa,EAAoB,aAAa,EAAkB,wBAAwB,EAChH,WAAW,EAAE,mBAAmB,EACjC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAK3F;;;GAGG;AACH,qBAAa,SAAS;IAEE,SAAS,CAAC,aAAa,EAAE,mBAAmB;IAAlE,SAAS,aAAuB,aAAa,EAAE,mBAAmB;IAElE;;;;;;OAMG;IACU,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAsBrI;;;;;OAKG;IACU,uBAAuB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,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AAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAavJ,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAYjH,kCAAkC,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAajK,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAYnF,MAAM,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAc5E;;;;OAIG;IACU,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyB1H;;;;;OAKG;IACU,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA4B3F;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;YA8BjG,QAAQ;IAuBtB,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe;YAM5F,kBAAkB;CAejC"}
@@ -11,13 +11,35 @@ exports.ECClasses = void 0;
11
11
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
12
  const core_bentley_1 = require("@itwin/core-bentley");
13
13
  const Rules = require("../Validation/ECRules");
14
+ const Properties_1 = require("./Properties");
14
15
  /**
15
16
  * @alpha
16
17
  * Acts as a base class for schema class creation. Enables property creation.
17
18
  */
18
19
  class ECClasses {
19
- constructor(_schemaEditor) {
20
+ constructor(schemaItemType, _schemaEditor) {
21
+ this.schemaItemType = schemaItemType;
20
22
  this._schemaEditor = _schemaEditor;
23
+ /**
24
+ * Allows access for editing of base Property attributes.
25
+ */
26
+ this.properties = new Properties_1.Properties(this.schemaItemType, this._schemaEditor);
27
+ /**
28
+ * Allows access for editing of ArrayProperty attributes.
29
+ */
30
+ this.arrayProperties = new Properties_1.ArrayProperties(this.schemaItemType, this._schemaEditor);
31
+ /**
32
+ * Allows access for editing of PrimitiveProperty attributes.
33
+ */
34
+ this.primitiveProperties = new Properties_1.PrimitiveProperties(this.schemaItemType, this._schemaEditor);
35
+ /**
36
+ * Allows access for editing of EnumerationProperty attributes.
37
+ */
38
+ this.enumerationProperties = new Properties_1.EnumerationProperties(this.schemaItemType, this._schemaEditor);
39
+ /**
40
+ * Allows access for editing of StructProperty attributes.
41
+ */
42
+ this.structProperties = new Properties_1.StructProperties(this.schemaItemType, this._schemaEditor);
21
43
  }
22
44
  /**
23
45
  * Creates a property on class identified by the given SchemaItemKey. This method restricts the
@@ -236,78 +258,6 @@ class ECClasses {
236
258
  }
237
259
  return {};
238
260
  }
239
- /**
240
- * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.
241
- * @param classKey The SchemaItemKey identifying the class.
242
- * @param propertyName The name of the property.
243
- * @param customAttribute The CustomAttribute instance to add.
244
- */
245
- async addCustomAttributeToProperty(classKey, propertyName, customAttribute) {
246
- let mutableClass;
247
- try {
248
- mutableClass = await this.getClass(classKey);
249
- }
250
- catch (e) {
251
- return { errorMessage: e.message };
252
- }
253
- const property = await mutableClass.getProperty(propertyName);
254
- if (!property) {
255
- return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };
256
- }
257
- property.addCustomAttribute(customAttribute);
258
- const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);
259
- const result = { errorMessage: "" };
260
- for await (const diagnostic of diagnostics) {
261
- result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\r\n`;
262
- }
263
- if (result.errorMessage) {
264
- this.removeCustomAttribute(property, customAttribute);
265
- return result;
266
- }
267
- return {};
268
- }
269
- /**
270
- * Renames the property on the specified class. The rename will fail if the new
271
- * name causes a conflict with a base or derived property. All derived classes
272
- * containing a property override will be renamed, as well.
273
- * @param classKey The SchemaItemKey identifying the class.
274
- * @param existingPropertyName The name of the property.
275
- * @param newPropertyName The new property name.
276
- */
277
- async setPropertyName(classKey, existingPropertyName, newPropertyName) {
278
- const newName = new ecschema_metadata_1.ECName(newPropertyName);
279
- let mutableClass;
280
- try {
281
- mutableClass = await this.getClass(classKey);
282
- }
283
- catch (e) {
284
- return { errorMessage: e.message };
285
- }
286
- const existingProperty = await mutableClass.getProperty(existingPropertyName);
287
- if (!existingProperty) {
288
- return { errorMessage: `An ECProperty with the name ${existingPropertyName} could not be found in the class ${classKey.fullName}.` };
289
- }
290
- const baseProperty = await mutableClass.getProperty(newPropertyName, true);
291
- if (baseProperty)
292
- return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.` };
293
- // Handle derived classes
294
- const derivedProperties = [];
295
- const derivedClasses = await this.findDerivedClasses(mutableClass);
296
- for (const derivedClass of derivedClasses) {
297
- if (await derivedClass.getProperty(newPropertyName))
298
- return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.` };
299
- const propertyOverride = await derivedClass.getProperty(existingPropertyName);
300
- // If found the property is overridden in the derived class.
301
- if (propertyOverride)
302
- derivedProperties.push(propertyOverride);
303
- }
304
- // Re-name the overridden property in all derived classes
305
- derivedProperties.forEach((prop) => {
306
- prop.setName(newName);
307
- });
308
- existingProperty.setName(newName);
309
- return { itemKey: classKey, propertyName: newName.name };
310
- }
311
261
  /**
312
262
  * Sets the name of the ECClass.
313
263
  * @param classKey The SchemaItemKey of the class.
@@ -329,33 +279,39 @@ class ECClasses {
329
279
  catch (e) {
330
280
  return { errorMessage: e.message };
331
281
  }
282
+ const existingName = classKey.name;
332
283
  mutableClass.setName(name);
284
+ // Must reset in schema item map
285
+ await schema.deleteClass(existingName);
286
+ schema.addItem(mutableClass);
333
287
  return {};
334
288
  }
335
289
  /**
336
- * Sets the Category to the Property.
337
- * @param classKey The SchemaItemKey of the class.
338
- * @param propertyName The name of the property.
339
- * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.
290
+ * Sets the base class of a SchemaItem.
291
+ * @param itemKey The SchemaItemKey of the Item.
292
+ * @param baseClassKey The SchemaItemKey of the base class. Specifying 'undefined' removes the base class.
340
293
  */
341
- async setPropertyCategory(classKey, propertyName, categoryKey) {
342
- let mutableClass;
343
- try {
344
- mutableClass = await this.getClass(classKey);
345
- }
346
- catch (e) {
347
- return { errorMessage: e.message };
348
- }
349
- const property = await mutableClass.getProperty(propertyName);
350
- if (property === undefined) {
351
- return { errorMessage: `An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };
352
- }
353
- const category = await mutableClass.schema.lookupItem(categoryKey);
354
- if (category === undefined) {
355
- return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${mutableClass.schema.fullName}.` };
356
- }
357
- property.setCategory(new ecschema_metadata_1.DelayedPromiseWithProps(categoryKey, async () => category));
358
- return { itemKey: classKey, propertyName };
294
+ async setBaseClass(itemKey, baseClassKey) {
295
+ const classItem = await this._schemaEditor.schemaContext.getSchemaItem(itemKey);
296
+ if (classItem === undefined)
297
+ return { itemKey, errorMessage: `Class ${itemKey.fullName} not found in schema context.` };
298
+ if (baseClassKey === undefined) {
299
+ classItem.baseClass = undefined;
300
+ return { itemKey };
301
+ }
302
+ const baseClassSchema = !baseClassKey.schemaKey.matches(itemKey.schemaKey) ? await this._schemaEditor.getSchema(baseClassKey.schemaKey) : classItem.schema;
303
+ if (baseClassSchema === undefined) {
304
+ return { itemKey, errorMessage: `Schema Key ${baseClassKey.schemaKey.toString(true)} not found in context` };
305
+ }
306
+ const baseClassItem = await baseClassSchema.lookupItem(baseClassKey);
307
+ if (baseClassItem === undefined)
308
+ return { itemKey, errorMessage: `Unable to locate base class ${baseClassKey.fullName} in schema ${baseClassSchema.fullName}.` };
309
+ if (baseClassItem.schemaItemType !== classItem.schemaItemType)
310
+ return { itemKey, errorMessage: `${baseClassItem.fullName} is not of type ${classItem.schemaItemType}.` };
311
+ if (classItem.baseClass !== undefined && !await baseClassItem.is(await classItem.baseClass))
312
+ return { itemKey, errorMessage: `Baseclass ${baseClassItem.fullName} must derive from ${classItem.baseClass.fullName}.` };
313
+ classItem.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClassKey, async () => baseClassItem);
314
+ return { itemKey };
359
315
  }
360
316
  async getClass(classKey) {
361
317
  const schema = await this._schemaEditor.getSchema(classKey.schemaKey);