@itwin/ecschema-editing 4.6.0-dev.5 → 4.6.0-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  3. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  5. package/lib/cjs/Editing/Constants.js.map +1 -1
  6. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  7. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  8. package/lib/cjs/Editing/Editor.js.map +1 -1
  9. package/lib/cjs/Editing/Entities.js.map +1 -1
  10. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  11. package/lib/cjs/Editing/Formats.js.map +1 -1
  12. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  13. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  14. package/lib/cjs/Editing/Mixins.js.map +1 -1
  15. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  16. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  17. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  18. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  19. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  20. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  21. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  28. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  33. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  34. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  35. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  36. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  37. package/lib/cjs/Editing/Structs.js.map +1 -1
  38. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  39. package/lib/cjs/Editing/Units.js.map +1 -1
  40. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  41. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  42. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  43. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  44. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  45. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  46. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  47. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  48. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  49. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  50. package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
  51. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  52. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  53. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  54. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  55. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  56. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  57. package/lib/cjs/Validation/ECRules.js.map +1 -1
  58. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  59. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  60. package/lib/cjs/Validation/Rules.js.map +1 -1
  61. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  62. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  63. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  64. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  65. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  66. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  67. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  68. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  69. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  70. package/lib/cjs/ecschema-editing.js.map +1 -1
  71. package/package.json +9 -9
  72. package/public/locales/en/ECSchemaEditing.json +26 -26
package/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Change Log - @itwin/ecschema-editing
2
2
 
3
- This log was last generated on Mon, 25 Mar 2024 22:24:35 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 03 Apr 2024 18:28:10 GMT and should not be manually modified.
4
+
5
+ ## 4.5.1
6
+ Wed, 03 Apr 2024 18:26:58 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 4.5.0
11
+ Tue, 02 Apr 2024 19:06:00 GMT
12
+
13
+ ### Updates
14
+
15
+ - Units v1.0.8 schema is released which introduces a new unit - Decanewton (daN)
16
+ - Added navigation property merging
17
+ - Added Schema Differencing API
18
+ - Added multi-pass to class changes in SchemaMerger
19
+ - Adjusted EC-001 supplemental test to add custom attribute after the reference was added
20
+ - Added RelationshipClass merging
4
21
 
5
22
  ## 4.4.8
6
23
  Mon, 25 Mar 2024 22:22:26 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaConflicts.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,IAAY,YAmBX;AAnBD,WAAY,YAAY;IAEtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IAEnC,8CAA8B,CAAA;IAC9B,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;IAEzB,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IAEpC,+DAA+C,CAAA;IAE/C,kDAAkC,CAAA;IAElC,sEAAsD,CAAA;IACtD,sEAAsD,CAAA;IACtD,wEAAwD,CAAA;AAC1D,CAAC,EAnBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAmBvB","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 { 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 * @internal\n */\nexport enum ConflictCode {\n\n ConflictingItemName = \"C-001\",\n ConflictingReferenceAlias = \"C-002\",\n\n ConflictingBaseClass = \"C-100\",\n RemovingBaseClass = \"C-101\",\n SealedBaseClass = \"C-102\",\n\n ConflictingEnumerationType = \"C-700\",\n ConflictingEnumeratorValue = \"C-701\",\n\n MixinAppliedMustDeriveFromConstraint = \"C-1100\",\n\n ConflictingPropertyName = \"C-1300\",\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 *\n * @internal\n */\nexport interface SchemaDifferenceConflict {\n /**\n * The name of the schema type which is \"Schema\" for a conflict on the schema, on schema items\n * or objects that are related to schema items (properties, relationship constraints) it is the\n * name of the related schema item.\n */\n readonly schemaType: SchemaType;\n\n /** The name of the schema item the conflict appears on. */\n readonly itemName?: string;\n\n /** Optional path what on the item was conflicting. */\n readonly path?: string;\n\n /** The unique conflicting code. */\n readonly code: ConflictCode;\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"]}
1
+ {"version":3,"file":"SchemaConflicts.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaConflicts.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,IAAY,YAmBX;AAnBD,WAAY,YAAY;IAEtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IAEnC,8CAA8B,CAAA;IAC9B,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;IAEzB,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IAEpC,+DAA+C,CAAA;IAE/C,kDAAkC,CAAA;IAElC,sEAAsD,CAAA;IACtD,sEAAsD,CAAA;IACtD,wEAAwD,CAAA;AAC1D,CAAC,EAnBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAmBvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport type { SchemaType } from \"./SchemaDifference\";\r\n\r\n/**\r\n * The unique conflicts codes for Schema differencing.\r\n *\r\n * To provide meaning to code values, with anticipation\r\n * of future rules for all current EC Types, the following\r\n * value ranges should be used:\r\n *\r\n * - Schema: 000-099\r\n * - Class: 100-199\r\n * - Constant: 200-299\r\n * - CustomAttribute 300-399\r\n * - CustomAttributeClass: 400-499\r\n * - CustomAttributeContainer: 500-599\r\n * - EntityClass: 600-699\r\n * - Enumeration: 700-799\r\n * - Format: 800-899\r\n * - InvertedUnit: 900-999\r\n * - KindOfQuantity: 1000-1099\r\n * - Mixin: 1100-1199\r\n * - Phenomenon: 1200-1299\r\n * - Property: 1300-1399\r\n * - PropertyCategory: 1400-1499\r\n * - RelationshipClass: 1500-1599\r\n * - RelationshipConstraint: 1600-1699\r\n * - StructClass: 1700-1799\r\n * - Unit: 1800-1899\r\n * - UnitSystem: 1900-1999\r\n *\r\n * @internal\r\n */\r\nexport enum ConflictCode {\r\n\r\n ConflictingItemName = \"C-001\",\r\n ConflictingReferenceAlias = \"C-002\",\r\n\r\n ConflictingBaseClass = \"C-100\",\r\n RemovingBaseClass = \"C-101\",\r\n SealedBaseClass = \"C-102\",\r\n\r\n ConflictingEnumerationType = \"C-700\",\r\n ConflictingEnumeratorValue = \"C-701\",\r\n\r\n MixinAppliedMustDeriveFromConstraint = \"C-1100\",\r\n\r\n ConflictingPropertyName = \"C-1300\",\r\n\r\n AbstractConstraintMustNarrowBaseConstraints = \"C-1500\",\r\n DerivedConstraintsMustNarrowBaseConstraints = \"C-1501\",\r\n ConstraintClassesDeriveFromAbstractConstraint = \"C-1502\",\r\n}\r\n\r\n/**\r\n * Defines the interface for a conflict during Schema Differencing. Conflicts were discovered\r\n * while comparing the changed elements. Conflicts in the whole schema context are not found\r\n * on that level.\r\n *\r\n * @internal\r\n */\r\nexport interface SchemaDifferenceConflict {\r\n /**\r\n * The name of the schema type which is \"Schema\" for a conflict on the schema, on schema items\r\n * or objects that are related to schema items (properties, relationship constraints) it is the\r\n * name of the related schema item.\r\n */\r\n readonly schemaType: SchemaType;\r\n\r\n /** The name of the schema item the conflict appears on. */\r\n readonly itemName?: string;\r\n\r\n /** Optional path what on the item was conflicting. */\r\n readonly path?: string;\r\n\r\n /** The unique conflicting code. */\r\n readonly code: ConflictCode;\r\n\r\n /** A description of the conflict. */\r\n readonly description: string;\r\n\r\n /** The value in the source schema. */\r\n readonly source: unknown;\r\n\r\n /** The value in the target schema. */\r\n readonly target: unknown;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaDiagnosticVisitor.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDiagnosticVisitor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qFAA4E;AAC5E,gEAGkC;AAelC,uDAA2E;AAE3E;;;GAGG;AACH,SAAS,WAAW,CAAC,OAA0B,EAAE,aAAqB;IACpE,IAAG,OAAO,KAAK,SAAS,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,IAAG,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IACD,OAAO,WAAW,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,aAAa,CAAC,CAAC;AAChE,CAAC;AAWD;;;;;GAKG;AACH,MAAa,uBAAuB;IAIlC,YAAY,gBAAmC;QAC7C,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,CAAC;IAEO,QAAQ,CAAgC,KAAQ;QACtD,IAAI,CAAC,iB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B,EAAC,cAAc,CAAuB,CAAC;AACtE,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 type { AnyDiagnostic } from \"../Validation/Diagnostic\";\nimport { SchemaCompareCodes } from \"../Validation/SchemaCompareDiagnostics\";\nimport {\n AnyECType, AnyEnumerator, AnySchemaItemProps, CustomAttribute, ECClass, ECClassModifier, Enumeration, Mixin, Property, PropertyProps,\n RelationshipConstraint, RelationshipConstraintProps, Schema, SchemaItem, SchemaItemType, schemaItemTypeToString,\n} from \"@itwin/ecschema-metadata\";\nimport {\n AnySchemaDifference,\n DifferenceType,\n SchemaClassMixinDifference,\n SchemaDifference,\n SchemaDifferences,\n SchemaEnumeratorDifference,\n SchemaItemDifference,\n SchemaItemTypeName,\n SchemaPropertyDifference,\n SchemaRelationshipConstraintClassDifference,\n SchemaRelationshipConstraintDifference,\n SchemaType,\n} from \"./SchemaDifference\";\nimport { ConflictCode, SchemaDifferenceConflict } from \"./SchemaConflicts\";\n\n/**\n * Recursive syncronous function to figure whether a given class derived from\n * a class with the given baseClassName.\n */\nfunction derivedFrom(ecClass: ECClass|undefined, baseClassName: string): boolean {\n if(ecClass === undefined) {\n return false;\n }\n if(ecClass && ecClass.name === baseClassName) {\n return true;\n }\n return derivedFrom(ecClass.getBaseClassSync(), baseClassName);\n}\n\n/**\n * Definition of lookup args to locate certain elements in the existing differences.\n */\ninterface LookupArgs {\n schemaType?: string;\n itemName?: string;\n path?: string;\n}\n\n/**\n * The SchemaDiagnosticVisitor is a visitor implementation for diagnostic entries\n * from the schema comparer api. Depending on the diagnostic code, the difference\n * result is build together.\n * @internal\n */\nexport class SchemaDiagnosticVisitor {\n\n private readonly _differenceReport: SchemaDifferences;\n\n constructor(differenceReport: SchemaDifferences) {\n this._differenceReport = differenceReport;\n }\n\n private addEntry<T extends AnySchemaDifference>(entry: T): T {\n this._differenceReport.changes.push(entry);\n return entry;\n }\n\n private lookupEntry(changeType: DifferenceType, args: LookupArgs) {\n return this._differenceReport.changes && this._differenceReport.changes.find((change) => {\n return (change.changeType === changeType)\n && (!args.schemaType || change.schemaType === args.schemaType)\n && (!args.itemName || change.itemName === args.itemName)\n && change.path === args.path;\n });\n }\n\n private addConflict(conflict: SchemaDifferenceConflict) {\n this._differenceReport.conflicts.push(conflict);\n }\n\n /**\n * Visitor function to process the schema change diagnostic object.\n * @internal\n */\n public visit(diagnostic: AnyDiagnostic) {\n switch(diagnostic.code) {\n case SchemaCompareCodes.SchemaDelta:\n return this.visitChangedSchemaProperties(diagnostic);\n\n case SchemaCompareCodes.SchemaReferenceMissing:\n return this.visitSchemaReference(diagnostic, \"add\");\n case SchemaCompareCodes.SchemaReferenceDelta:\n return this.visitSchemaReference(diagnostic, \"modify\");\n\n case SchemaCompareCodes.SchemaItemMissing:\n return this.visitMissingSchemaItem(diagnostic);\n\n case SchemaCompareCodes.SchemaItemDelta:\n case SchemaCompareCodes.ClassDelta:\n case SchemaCompareCodes.ConstantDelta:\n case SchemaCompareCodes.CustomAttributeClassDelta:\n case SchemaCompareCodes.FormatDelta:\n case SchemaCompareCodes.InvertedUnitDelta:\n case SchemaCompareCodes.KoqDelta:\n case SchemaCompareCodes.MixinDelta:\n case SchemaCompareCodes.PhenomenonDelta:\n case SchemaCompareCodes.PropertyCategoryDelta:\n case SchemaCompareCodes.RelationshipDelta:\n case SchemaCompareCodes.UnitDelta:\n return this.visitChangedSchemaItem(diagnostic);\n\n case SchemaCompareCodes.EnumerationDelta:\n return this.visitChangedEnumeration(diagnostic);\n\n case SchemaCompareCodes.EnumeratorDelta:\n return this.visitChangedEnumerator(diagnostic);\n case SchemaCompareCodes.EnumeratorMissing:\n return this.visitMissingEnumerator(diagnostic);\n\n case SchemaCompareCodes.BaseClassDelta:\n return this.visitMissingBaseClass(diagnostic);\n case SchemaCompareCodes.EntityMixinMissing:\n return this.visitMissingMixinOnClass(diagnostic);\n case SchemaCompareCodes.PropertyDelta:\n return this.visitChangedProperty(diagnostic);\n case SchemaCompareCodes.PropertyMissing:\n return this.visitMissingProperty(diagnostic);\n\n case SchemaCompareCodes.RelationshipConstraintClassMissing:\n return this.visitMissingRelationshipConstraintClass(diagnostic);\n case SchemaCompareCodes.RelationshipConstraintDelta:\n return this.visitChangedRelationshipConstraint(diagnostic);\n\n case SchemaCompareCodes.CustomAttributeInstanceClassMissing:\n return this.visitMissingCustomAttributeInstance(diagnostic);\n\n // Currently not handled...\n case SchemaCompareCodes.FormatUnitMissing:\n case SchemaCompareCodes.PresentationUnitMissing:\n case SchemaCompareCodes.UnitLabelOverrideDelta:\n break;\n }\n return;\n }\n\n private visitChangedSchemaProperties(diagnostic: AnyDiagnostic) {\n let modifyEntry = this.lookupEntry(\"modify\", { schemaType: \"Schema\" }) as SchemaDifference;\n let hasChanges = false;\n const existsAlready = modifyEntry !== undefined;\n if(!existsAlready) {\n modifyEntry = {\n changeType: \"modify\",\n schemaType: \"Schema\",\n json: {},\n };\n }\n\n // Only label and description are taken from the source schema. If the schema name or alias\n // differs, those are ignored for now.\n const [propertyName, propertyValue] = diagnostic.messageArgs as [string, any];\n switch(propertyName) {\n case \"label\":\n modifyEntry.json.label = propertyValue;\n hasChanges = true;\n break;\n case \"description\":\n modifyEntry.json.description = propertyValue;\n hasChanges = true;\n break;\n }\n\n if(!existsAlready && hasChanges) {\n this.addEntry(modifyEntry);\n }\n }\n\n private visitMissingSchemaItem(diagnostic: AnyDiagnostic) {\n const schemaItem = diagnostic.ecDefinition as SchemaItem;\n this.addEntry({\n changeType: \"add\",\n schemaType: getSchemaItemName(schemaItem.schemaItemType),\n itemName: schemaItem.name,\n json: schemaItem.toJSON(),\n });\n }\n\n private visitChangedSchemaItem(diagnostic: AnyDiagnostic) {\n const schemaItem = diagnostic.ecDefinition as SchemaItem;\n if(this.lookupEntry(\"add\", { itemName: schemaItem.name })) {\n return;\n }\n\n const [propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [keyof AnySchemaItemProps, any, any];\n if(propertyName === \"schemaItemType\") {\n return this.addConflict({\n code: ConflictCode.ConflictingItemName,\n schemaType: getSchemaItemName(schemaItem.schemaItemType),\n itemName: schemaItem.name,\n source: sourceValue,\n target: targetValue,\n description: \"Target schema already contains a schema item with the name but different type.\",\n });\n }\n\n if(sourceValue === undefined) {\n return;\n }\n\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: schemaItem.name }) as SchemaItemDifference;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: getSchemaItemName(schemaItem.schemaItemType),\n itemName: schemaItem.name,\n json: {},\n });\n }\n\n modifyEntry.json[propertyName] = sourceValue;\n }\n\n private visitChangedEnumeration(diagnostic: AnyDiagnostic) {\n const enumeration = diagnostic.ecDefinition as Enumeration;\n if(this.lookupEntry(\"add\", { itemName: enumeration.name })) {\n return;\n }\n\n const [propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [string, string, string];\n if(propertyName === \"type\") {\n return this.addConflict({\n code: ConflictCode.ConflictingEnumerationType,\n schemaType: getSchemaItemName(SchemaItemType.Enumeration),\n itemName: enumeration.name,\n source: sourceValue,\n target: targetValue,\n description: \"Enumeration has a different primitive type.\",\n });\n }\n\n return this.visitChangedSchemaItem(diagnostic);\n }\n\n private visitMissingEnumerator(diagnostic: AnyDiagnostic) {\n const enumeration = diagnostic.ecDefinition as SchemaItem;\n if(this.lookupEntry(\"add\", { itemName: enumeration.name })) {\n return;\n }\n\n const [enumerator] = diagnostic.messageArgs as [AnyEnumerator];\n this.addEntry({\n changeType: \"add\",\n schemaType: \"Enumeration\",\n itemName: enumeration.name,\n path: \"$enumerators\",\n json: enumerator,\n });\n }\n\n private lookupEnumeratorEntry(changeType: DifferenceType, item: string, enumeratorName: string) {\n return this._differenceReport.changes && this._differenceReport.changes.find((change) => {\n return change.changeType === changeType\n && change.schemaType === \"Enumeration\"\n && change.itemName === item\n && change.path === \"$enumerators\"\n && (change.json as AnyEnumerator).name === enumeratorName;\n });\n }\n\n private visitChangedEnumerator(diagnostic: AnyDiagnostic) {\n const enumeration = diagnostic.ecDefinition as Enumeration;\n if(this.lookupEntry(\"add\", { itemName: enumeration.name })) {\n return;\n }\n\n const [enumerator, propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [AnyEnumerator, keyof AnyEnumerator, any, any];\n if(this.lookupEnumeratorEntry(\"add\", enumeration.name, enumerator.name)) {\n return;\n }\n\n if(!this.validateEnumerator(enumeration, enumerator, propertyName, sourceValue, targetValue)) {\n return;\n }\n\n const enumeratorPath = `$enumerators.${enumerator.name}`;\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: enumeration.name, path: enumeratorPath}) as SchemaEnumeratorDifference;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: \"Enumeration\",\n itemName: enumeration.name,\n path: enumeratorPath,\n json: {},\n });\n }\n\n if(sourceValue !== undefined) {\n modifyEntry.json[propertyName] = sourceValue;\n }\n }\n\n private validateEnumerator(enumeration: Enumeration, enumerator: AnyEnumerator, propertyName: string, sourceValue: unknown, targetValue: unknown) {\n if(propertyName === \"value\") {\n this.addConflict({\n code: ConflictCode.ConflictingEnumeratorValue,\n schemaType: getSchemaItemName(SchemaItemType.Enumeration),\n itemName: enumeration.name,\n path: enumerator.name,\n source: sourceValue,\n target: targetValue,\n description: \"Enumerator values must not differ.\",\n });\n return false;\n }\n\n return true;\n }\n\n private visitMissingProperty(diagnostic: AnyDiagnostic) {\n const property = diagnostic.ecDefinition as Property;\n if(this.lookupEntry(\"add\", { itemName: property.class.name })) {\n return;\n }\n\n this.addEntry({\n changeType: \"add\",\n schemaType: \"Property\",\n itemName: property.class.name,\n path: property.name,\n json: property.toJSON(),\n });\n }\n\n private visitChangedProperty(diagnostic: AnyDiagnostic) {\n const property = diagnostic.ecDefinition as Property;\n if(this.lookupEntry(\"add\", { itemName: property.class.name})\n || this.lookupEntry(\"add\", { itemName: property.class.name, path: property.name })) {\n return;\n }\n const [propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [keyof PropertyProps, any, any];\n if(!this.validatePropertyChange(property, propertyName, sourceValue, targetValue)) {\n return;\n }\n\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: property.class.name, path: property.name}) as SchemaPropertyDifference;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: \"Property\",\n itemName: property.class.name,\n path: property.name,\n json: {},\n });\n }\n\n if(propertyName !== \"name\" && sourceValue !== undefined) {\n modifyEntry.json[propertyName] = sourceValue;\n }\n }\n\n private validatePropertyChange(ecProperty: Property, propertyName: string, sourceValue: unknown, targetValue: unknown): boolean {\n if(propertyName === \"primitiveType\") {\n this.addConflict({\n code: ConflictCode.ConflictingPropertyName,\n schemaType: getSchemaItemName(ecProperty.class.schemaItemType),\n itemName: ecProperty.class.name,\n path: ecProperty.name,\n source: sourceValue,\n target: targetValue,\n description: \"Target class already contains a property with a different type.\",\n });\n return false;\n }\n return true;\n }\n\n private visitMissingBaseClass(diagnostic: AnyDiagnostic) {\n const ecClass = diagnostic.ecDefinition as ECClass;\n if(this.lookupEntry(\"add\", { itemName: ecClass.name })) {\n return;\n }\n\n const [sourceBaseClass, targetBaseClass] = diagnostic.messageArgs as [ECClass, ECClass];\n if(!this.validateBaseClassChange(ecClass, sourceBaseClass, targetBaseClass)) {\n return;\n }\n\n let modifyEntry = this.lookupEntry(\"modify\",{ itemName: ecClass.name }) as SchemaItemDifference<{ baseClass: string }>;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: getSchemaItemName(ecClass.schemaItemType),\n itemName: ecClass.name,\n json: {},\n });\n }\n\n modifyEntry.json.baseClass = sourceBaseClass.fullName;\n }\n\n private validateBaseClassChange(targetClass: ECClass, sourceBaseClass?: ECClass, targetBaseClass?: ECClass): boolean {\n if(sourceBaseClass === undefined) {\n this.addConflict({\n code: ConflictCode.RemovingBaseClass,\n schemaType: getSchemaItemName(targetClass.schemaItemType),\n itemName: targetClass.name,\n path: \"$baseClass\",\n source: undefined,\n target: targetBaseClass?.fullName,\n description: \"BaseClass cannot be set unset if there has been a baseClass before.\",\n });\n return false;\n }\n\n if(sourceBaseClass.modifier === ECClassModifier.Sealed) {\n this.addConflict({\n code: ConflictCode.SealedBaseClass,\n schemaType: getSchemaItemName(targetClass.schemaItemType),\n itemName: targetClass.name,\n path: \"$baseClass\",\n source: sourceBaseClass.fullName,\n target: targetBaseClass?.fullName,\n description: \"BaseClass is sealed.\",\n });\n return false;\n }\n\n if(targetBaseClass && !derivedFrom(sourceBaseClass, targetBaseClass.name)) {\n this.addConflict({\n code: ConflictCode.ConflictingBaseClass,\n schemaType: getSchemaItemName(targetClass.schemaItemType),\n itemName: targetClass.name,\n path: \"$baseClass\",\n source: sourceBaseClass.fullName,\n target: targetBaseClass.fullName,\n description: \"BaseClass is not valid, source class must derive from target.\",\n });\n return false;\n }\n return true;\n }\n\n private visitMissingMixinOnClass(diagnostic: AnyDiagnostic) {\n const ecClass = diagnostic.ecDefinition as ECClass;\n if(this.lookupEntry(\"add\", { itemName: ecClass.name })) {\n return;\n }\n\n const [mixin] = diagnostic.messageArgs as [Mixin];\n if(!this.validateMixin(ecClass, mixin)) {\n return;\n }\n\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: ecClass.name, path: \"$mixins\" }) as SchemaClassMixinDifference;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: \"EntityClass\",\n itemName: ecClass.name,\n path: \"$mixins\",\n json: [],\n });\n }\n\n modifyEntry.json.push(mixin.fullName);\n }\n\n private validateMixin(targetClass: ECClass, mixin: Mixin): boolean {\n if(mixin.appliesTo && !derivedFrom(targetClass, mixin.appliesTo.name)) {\n this.addConflict({\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\n schemaType: getSchemaItemName(targetClass.schemaItemType),\n itemName: targetClass.name,\n path: \"$mixins\",\n source: mixin.fullName,\n target: undefined,\n description: \"Mixin cannot applied to this class.\",\n });\n return false;\n }\n\n return true;\n }\n\n private visitMissingRelationshipConstraintClass(diagnostic: AnyDiagnostic) {\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\n const className = constraint.relationshipClass.name;\n const constraintPath = `$${constraint.isSource ? \"source\" : \"target\"}.constraintClasses`;\n if(this.lookupEntry(\"add\", { itemName: className })) {\n return;\n }\n\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: className, path: constraintPath}) as SchemaRelationshipConstraintClassDifference;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: \"RelationshipClass\",\n itemName: className,\n path: constraintPath,\n json: [],\n });\n }\n\n const [constraintClass] = diagnostic.messageArgs as [ECClass];\n modifyEntry.json.push(constraintClass.fullName);\n }\n\n private visitChangedRelationshipConstraint(diagnostic: AnyDiagnostic) {\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\n const className = constraint.relationshipClass.name;\n const constraintPath = `$${constraint.isSource ? \"source\" : \"target\"}`;\n if(this.lookupEntry(\"add\", { itemName: className })) {\n return;\n }\n\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: className, path: constraintPath }) as SchemaRelationshipConstraintDifference;\n if(!modifyEntry) {\n modifyEntry = this.addEntry({\n changeType: \"modify\",\n schemaType: \"RelationshipConstraint\",\n itemName: className,\n path: constraintPath,\n json: {},\n });\n }\n\n const [propertyName, propertyValue] = diagnostic.messageArgs as [keyof RelationshipConstraintProps, any];\n if(propertyValue !== undefined) {\n modifyEntry.json[propertyName] = propertyValue;\n }\n }\n\n private visitSchemaReference(diagnostic: AnyDiagnostic, changeType: DifferenceType) {\n const [referencedSchema] = diagnostic.messageArgs as [Schema];\n this.addEntry({\n changeType,\n schemaType: \"Schema\",\n path: \"$references\",\n json: {\n name: referencedSchema.name,\n version: referencedSchema.schemaKey.version.toString(),\n },\n });\n }\n\n private visitMissingCustomAttributeInstance(diagnostic: AnyDiagnostic) {\n const { schemaType, itemName, path } = getItemNameAndPath(diagnostic.ecDefinition);\n if(itemName && (this.lookupEntry(\"add\", { itemName }) || this.lookupEntry(\"add\", { itemName, path }))) {\n return;\n }\n\n const [customAttribute] = diagnostic.messageArgs as [CustomAttribute];\n this.addEntry({\n changeType: \"add\",\n schemaType,\n itemName: itemName!,\n path: `${path ? `${path}.` : \"\"}$customAttributes`,\n json: customAttribute as any,\n });\n }\n}\n\nfunction getItemNameAndPath(type: AnyECType): { schemaType: SchemaType, itemName?: string, path?: string } {\n if(Schema.isSchema(type))\n return {\n schemaType: \"Schema\",\n };\n if(SchemaItem.isSchemaItem(type))\n return {\n schemaType: getSchemaItemName(type.schemaItemType),\n itemName: type.name,\n };\n if(type instanceof Property)\n return {\n schemaType: \"Property\",\n itemName: type.class.name,\n path: type.name,\n };\n if(type instanceof RelationshipConstraint)\n return {\n schemaType: \"RelationshipClass\",\n itemName: type.relationshipClass.name,\n path: type.isSource ? \"$source\" : \"$target\",\n };\n throw Error(\"Unhandled Type\");\n}\n\nfunction getSchemaItemName(schemaItemType: SchemaItemType) {\n return schemaItemTypeToString(schemaItemType) as SchemaItemTypeName;\n}\n"]}
1
+ {"version":3,"file":"SchemaDiagnosticVisitor.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDiagnosticVisitor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,qFAA4E;AAC5E,gEAGkC;AAelC,uDAA2E;AAE3E;;;GAGG;AACH,SAAS,WAAW,CAAC,OAA0B,EAAE,aAAqB;IACpE,IAAG,OAAO,KAAK,SAAS,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,IAAG,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IACD,OAAO,WAAW,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,aAAa,CAAC,CA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,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SAC5C,CAAC;IACJ,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,iBAAiB,CAAC,cAA8B;IACvD,OAAO,IAAA,0CAAsB,EAAC,cAAc,CAAuB,CAAC;AACtE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport type { AnyDiagnostic } from \"../Validation/Diagnostic\";\r\nimport { SchemaCompareCodes } from \"../Validation/SchemaCompareDiagnostics\";\r\nimport {\r\n AnyECType, AnyEnumerator, AnySchemaItemProps, CustomAttribute, ECClass, ECClassModifier, Enumeration, Mixin, Property, PropertyProps,\r\n RelationshipConstraint, RelationshipConstraintProps, Schema, SchemaItem, SchemaItemType, schemaItemTypeToString,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport {\r\n AnySchemaDifference,\r\n DifferenceType,\r\n SchemaClassMixinDifference,\r\n SchemaDifference,\r\n SchemaDifferences,\r\n SchemaEnumeratorDifference,\r\n SchemaItemDifference,\r\n SchemaItemTypeName,\r\n SchemaPropertyDifference,\r\n SchemaRelationshipConstraintClassDifference,\r\n SchemaRelationshipConstraintDifference,\r\n SchemaType,\r\n} from \"./SchemaDifference\";\r\nimport { ConflictCode, SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\n\r\n/**\r\n * Recursive syncronous function to figure whether a given class derived from\r\n * a class with the given baseClassName.\r\n */\r\nfunction derivedFrom(ecClass: ECClass|undefined, baseClassName: string): boolean {\r\n if(ecClass === undefined) {\r\n return false;\r\n }\r\n if(ecClass && ecClass.name === baseClassName) {\r\n return true;\r\n }\r\n return derivedFrom(ecClass.getBaseClassSync(), baseClassName);\r\n}\r\n\r\n/**\r\n * Definition of lookup args to locate certain elements in the existing differences.\r\n */\r\ninterface LookupArgs {\r\n schemaType?: string;\r\n itemName?: string;\r\n path?: string;\r\n}\r\n\r\n/**\r\n * The SchemaDiagnosticVisitor is a visitor implementation for diagnostic entries\r\n * from the schema comparer api. Depending on the diagnostic code, the difference\r\n * result is build together.\r\n * @internal\r\n */\r\nexport class SchemaDiagnosticVisitor {\r\n\r\n private readonly _differenceReport: SchemaDifferences;\r\n\r\n constructor(differenceReport: SchemaDifferences) {\r\n this._differenceReport = differenceReport;\r\n }\r\n\r\n private addEntry<T extends AnySchemaDifference>(entry: T): T {\r\n this._differenceReport.changes.push(entry);\r\n return entry;\r\n }\r\n\r\n private lookupEntry(changeType: DifferenceType, args: LookupArgs) {\r\n return this._differenceReport.changes && this._differenceReport.changes.find((change) => {\r\n return (change.changeType === changeType)\r\n && (!args.schemaType || change.schemaType === args.schemaType)\r\n && (!args.itemName || change.itemName === args.itemName)\r\n && change.path === args.path;\r\n });\r\n }\r\n\r\n private addConflict(conflict: SchemaDifferenceConflict) {\r\n this._differenceReport.conflicts.push(conflict);\r\n }\r\n\r\n /**\r\n * Visitor function to process the schema change diagnostic object.\r\n * @internal\r\n */\r\n public visit(diagnostic: AnyDiagnostic) {\r\n switch(diagnostic.code) {\r\n case SchemaCompareCodes.SchemaDelta:\r\n return this.visitChangedSchemaProperties(diagnostic);\r\n\r\n case SchemaCompareCodes.SchemaReferenceMissing:\r\n return this.visitSchemaReference(diagnostic, \"add\");\r\n case SchemaCompareCodes.SchemaReferenceDelta:\r\n return this.visitSchemaReference(diagnostic, \"modify\");\r\n\r\n case SchemaCompareCodes.SchemaItemMissing:\r\n return this.visitMissingSchemaItem(diagnostic);\r\n\r\n case SchemaCompareCodes.SchemaItemDelta:\r\n case SchemaCompareCodes.ClassDelta:\r\n case SchemaCompareCodes.ConstantDelta:\r\n case SchemaCompareCodes.CustomAttributeClassDelta:\r\n case SchemaCompareCodes.FormatDelta:\r\n case SchemaCompareCodes.InvertedUnitDelta:\r\n case SchemaCompareCodes.KoqDelta:\r\n case SchemaCompareCodes.MixinDelta:\r\n case SchemaCompareCodes.PhenomenonDelta:\r\n case SchemaCompareCodes.PropertyCategoryDelta:\r\n case SchemaCompareCodes.RelationshipDelta:\r\n case SchemaCompareCodes.UnitDelta:\r\n return this.visitChangedSchemaItem(diagnostic);\r\n\r\n case SchemaCompareCodes.EnumerationDelta:\r\n return this.visitChangedEnumeration(diagnostic);\r\n\r\n case SchemaCompareCodes.EnumeratorDelta:\r\n return this.visitChangedEnumerator(diagnostic);\r\n case SchemaCompareCodes.EnumeratorMissing:\r\n return this.visitMissingEnumerator(diagnostic);\r\n\r\n case SchemaCompareCodes.BaseClassDelta:\r\n return this.visitMissingBaseClass(diagnostic);\r\n case SchemaCompareCodes.EntityMixinMissing:\r\n return this.visitMissingMixinOnClass(diagnostic);\r\n case SchemaCompareCodes.PropertyDelta:\r\n return this.visitChangedProperty(diagnostic);\r\n case SchemaCompareCodes.PropertyMissing:\r\n return this.visitMissingProperty(diagnostic);\r\n\r\n case SchemaCompareCodes.RelationshipConstraintClassMissing:\r\n return this.visitMissingRelationshipConstraintClass(diagnostic);\r\n case SchemaCompareCodes.RelationshipConstraintDelta:\r\n return this.visitChangedRelationshipConstraint(diagnostic);\r\n\r\n case SchemaCompareCodes.CustomAttributeInstanceClassMissing:\r\n return this.visitMissingCustomAttributeInstance(diagnostic);\r\n\r\n // Currently not handled...\r\n case SchemaCompareCodes.FormatUnitMissing:\r\n case SchemaCompareCodes.PresentationUnitMissing:\r\n case SchemaCompareCodes.UnitLabelOverrideDelta:\r\n break;\r\n }\r\n return;\r\n }\r\n\r\n private visitChangedSchemaProperties(diagnostic: AnyDiagnostic) {\r\n let modifyEntry = this.lookupEntry(\"modify\", { schemaType: \"Schema\" }) as SchemaDifference;\r\n let hasChanges = false;\r\n const existsAlready = modifyEntry !== undefined;\r\n if(!existsAlready) {\r\n modifyEntry = {\r\n changeType: \"modify\",\r\n schemaType: \"Schema\",\r\n json: {},\r\n };\r\n }\r\n\r\n // Only label and description are taken from the source schema. If the schema name or alias\r\n // differs, those are ignored for now.\r\n const [propertyName, propertyValue] = diagnostic.messageArgs as [string, any];\r\n switch(propertyName) {\r\n case \"label\":\r\n modifyEntry.json.label = propertyValue;\r\n hasChanges = true;\r\n break;\r\n case \"description\":\r\n modifyEntry.json.description = propertyValue;\r\n hasChanges = true;\r\n break;\r\n }\r\n\r\n if(!existsAlready && hasChanges) {\r\n this.addEntry(modifyEntry);\r\n }\r\n }\r\n\r\n private visitMissingSchemaItem(diagnostic: AnyDiagnostic) {\r\n const schemaItem = diagnostic.ecDefinition as SchemaItem;\r\n this.addEntry({\r\n changeType: \"add\",\r\n schemaType: getSchemaItemName(schemaItem.schemaItemType),\r\n itemName: schemaItem.name,\r\n json: schemaItem.toJSON(),\r\n });\r\n }\r\n\r\n private visitChangedSchemaItem(diagnostic: AnyDiagnostic) {\r\n const schemaItem = diagnostic.ecDefinition as SchemaItem;\r\n if(this.lookupEntry(\"add\", { itemName: schemaItem.name })) {\r\n return;\r\n }\r\n\r\n const [propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [keyof AnySchemaItemProps, any, any];\r\n if(propertyName === \"schemaItemType\") {\r\n return this.addConflict({\r\n code: ConflictCode.ConflictingItemName,\r\n schemaType: getSchemaItemName(schemaItem.schemaItemType),\r\n itemName: schemaItem.name,\r\n source: sourceValue,\r\n target: targetValue,\r\n description: \"Target schema already contains a schema item with the name but different type.\",\r\n });\r\n }\r\n\r\n if(sourceValue === undefined) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: schemaItem.name }) as SchemaItemDifference;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: getSchemaItemName(schemaItem.schemaItemType),\r\n itemName: schemaItem.name,\r\n json: {},\r\n });\r\n }\r\n\r\n modifyEntry.json[propertyName] = sourceValue;\r\n }\r\n\r\n private visitChangedEnumeration(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as Enumeration;\r\n if(this.lookupEntry(\"add\", { itemName: enumeration.name })) {\r\n return;\r\n }\r\n\r\n const [propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [string, string, string];\r\n if(propertyName === \"type\") {\r\n return this.addConflict({\r\n code: ConflictCode.ConflictingEnumerationType,\r\n schemaType: getSchemaItemName(SchemaItemType.Enumeration),\r\n itemName: enumeration.name,\r\n source: sourceValue,\r\n target: targetValue,\r\n description: \"Enumeration has a different primitive type.\",\r\n });\r\n }\r\n\r\n return this.visitChangedSchemaItem(diagnostic);\r\n }\r\n\r\n private visitMissingEnumerator(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as SchemaItem;\r\n if(this.lookupEntry(\"add\", { itemName: enumeration.name })) {\r\n return;\r\n }\r\n\r\n const [enumerator] = diagnostic.messageArgs as [AnyEnumerator];\r\n this.addEntry({\r\n changeType: \"add\",\r\n schemaType: \"Enumeration\",\r\n itemName: enumeration.name,\r\n path: \"$enumerators\",\r\n json: enumerator,\r\n });\r\n }\r\n\r\n private lookupEnumeratorEntry(changeType: DifferenceType, item: string, enumeratorName: string) {\r\n return this._differenceReport.changes && this._differenceReport.changes.find((change) => {\r\n return change.changeType === changeType\r\n && change.schemaType === \"Enumeration\"\r\n && change.itemName === item\r\n && change.path === \"$enumerators\"\r\n && (change.json as AnyEnumerator).name === enumeratorName;\r\n });\r\n }\r\n\r\n private visitChangedEnumerator(diagnostic: AnyDiagnostic) {\r\n const enumeration = diagnostic.ecDefinition as Enumeration;\r\n if(this.lookupEntry(\"add\", { itemName: enumeration.name })) {\r\n return;\r\n }\r\n\r\n const [enumerator, propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [AnyEnumerator, keyof AnyEnumerator, any, any];\r\n if(this.lookupEnumeratorEntry(\"add\", enumeration.name, enumerator.name)) {\r\n return;\r\n }\r\n\r\n if(!this.validateEnumerator(enumeration, enumerator, propertyName, sourceValue, targetValue)) {\r\n return;\r\n }\r\n\r\n const enumeratorPath = `$enumerators.${enumerator.name}`;\r\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: enumeration.name, path: enumeratorPath}) as SchemaEnumeratorDifference;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: \"Enumeration\",\r\n itemName: enumeration.name,\r\n path: enumeratorPath,\r\n json: {},\r\n });\r\n }\r\n\r\n if(sourceValue !== undefined) {\r\n modifyEntry.json[propertyName] = sourceValue;\r\n }\r\n }\r\n\r\n private validateEnumerator(enumeration: Enumeration, enumerator: AnyEnumerator, propertyName: string, sourceValue: unknown, targetValue: unknown) {\r\n if(propertyName === \"value\") {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingEnumeratorValue,\r\n schemaType: getSchemaItemName(SchemaItemType.Enumeration),\r\n itemName: enumeration.name,\r\n path: enumerator.name,\r\n source: sourceValue,\r\n target: targetValue,\r\n description: \"Enumerator values must not differ.\",\r\n });\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private visitMissingProperty(diagnostic: AnyDiagnostic) {\r\n const property = diagnostic.ecDefinition as Property;\r\n if(this.lookupEntry(\"add\", { itemName: property.class.name })) {\r\n return;\r\n }\r\n\r\n this.addEntry({\r\n changeType: \"add\",\r\n schemaType: \"Property\",\r\n itemName: property.class.name,\r\n path: property.name,\r\n json: property.toJSON(),\r\n });\r\n }\r\n\r\n private visitChangedProperty(diagnostic: AnyDiagnostic) {\r\n const property = diagnostic.ecDefinition as Property;\r\n if(this.lookupEntry(\"add\", { itemName: property.class.name})\r\n || this.lookupEntry(\"add\", { itemName: property.class.name, path: property.name })) {\r\n return;\r\n }\r\n const [propertyName, sourceValue, targetValue] = diagnostic.messageArgs as [keyof PropertyProps, any, any];\r\n if(!this.validatePropertyChange(property, propertyName, sourceValue, targetValue)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: property.class.name, path: property.name}) as SchemaPropertyDifference;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: \"Property\",\r\n itemName: property.class.name,\r\n path: property.name,\r\n json: {},\r\n });\r\n }\r\n\r\n if(propertyName !== \"name\" && sourceValue !== undefined) {\r\n modifyEntry.json[propertyName] = sourceValue;\r\n }\r\n }\r\n\r\n private validatePropertyChange(ecProperty: Property, propertyName: string, sourceValue: unknown, targetValue: unknown): boolean {\r\n if(propertyName === \"primitiveType\") {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingPropertyName,\r\n schemaType: getSchemaItemName(ecProperty.class.schemaItemType),\r\n itemName: ecProperty.class.name,\r\n path: ecProperty.name,\r\n source: sourceValue,\r\n target: targetValue,\r\n description: \"Target class already contains a property with a different type.\",\r\n });\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n private visitMissingBaseClass(diagnostic: AnyDiagnostic) {\r\n const ecClass = diagnostic.ecDefinition as ECClass;\r\n if(this.lookupEntry(\"add\", { itemName: ecClass.name })) {\r\n return;\r\n }\r\n\r\n const [sourceBaseClass, targetBaseClass] = diagnostic.messageArgs as [ECClass, ECClass];\r\n if(!this.validateBaseClassChange(ecClass, sourceBaseClass, targetBaseClass)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.lookupEntry(\"modify\",{ itemName: ecClass.name }) as SchemaItemDifference<{ baseClass: string }>;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: getSchemaItemName(ecClass.schemaItemType),\r\n itemName: ecClass.name,\r\n json: {},\r\n });\r\n }\r\n\r\n modifyEntry.json.baseClass = sourceBaseClass.fullName;\r\n }\r\n\r\n private validateBaseClassChange(targetClass: ECClass, sourceBaseClass?: ECClass, targetBaseClass?: ECClass): boolean {\r\n if(sourceBaseClass === undefined) {\r\n this.addConflict({\r\n code: ConflictCode.RemovingBaseClass,\r\n schemaType: getSchemaItemName(targetClass.schemaItemType),\r\n itemName: targetClass.name,\r\n path: \"$baseClass\",\r\n source: undefined,\r\n target: targetBaseClass?.fullName,\r\n description: \"BaseClass cannot be set unset if there has been a baseClass before.\",\r\n });\r\n return false;\r\n }\r\n\r\n if(sourceBaseClass.modifier === ECClassModifier.Sealed) {\r\n this.addConflict({\r\n code: ConflictCode.SealedBaseClass,\r\n schemaType: getSchemaItemName(targetClass.schemaItemType),\r\n itemName: targetClass.name,\r\n path: \"$baseClass\",\r\n source: sourceBaseClass.fullName,\r\n target: targetBaseClass?.fullName,\r\n description: \"BaseClass is sealed.\",\r\n });\r\n return false;\r\n }\r\n\r\n if(targetBaseClass && !derivedFrom(sourceBaseClass, targetBaseClass.name)) {\r\n this.addConflict({\r\n code: ConflictCode.ConflictingBaseClass,\r\n schemaType: getSchemaItemName(targetClass.schemaItemType),\r\n itemName: targetClass.name,\r\n path: \"$baseClass\",\r\n source: sourceBaseClass.fullName,\r\n target: targetBaseClass.fullName,\r\n description: \"BaseClass is not valid, source class must derive from target.\",\r\n });\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n private visitMissingMixinOnClass(diagnostic: AnyDiagnostic) {\r\n const ecClass = diagnostic.ecDefinition as ECClass;\r\n if(this.lookupEntry(\"add\", { itemName: ecClass.name })) {\r\n return;\r\n }\r\n\r\n const [mixin] = diagnostic.messageArgs as [Mixin];\r\n if(!this.validateMixin(ecClass, mixin)) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: ecClass.name, path: \"$mixins\" }) as SchemaClassMixinDifference;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: \"EntityClass\",\r\n itemName: ecClass.name,\r\n path: \"$mixins\",\r\n json: [],\r\n });\r\n }\r\n\r\n modifyEntry.json.push(mixin.fullName);\r\n }\r\n\r\n private validateMixin(targetClass: ECClass, mixin: Mixin): boolean {\r\n if(mixin.appliesTo && !derivedFrom(targetClass, mixin.appliesTo.name)) {\r\n this.addConflict({\r\n code: ConflictCode.MixinAppliedMustDeriveFromConstraint,\r\n schemaType: getSchemaItemName(targetClass.schemaItemType),\r\n itemName: targetClass.name,\r\n path: \"$mixins\",\r\n source: mixin.fullName,\r\n target: undefined,\r\n description: \"Mixin cannot applied to this class.\",\r\n });\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private visitMissingRelationshipConstraintClass(diagnostic: AnyDiagnostic) {\r\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\r\n const className = constraint.relationshipClass.name;\r\n const constraintPath = `$${constraint.isSource ? \"source\" : \"target\"}.constraintClasses`;\r\n if(this.lookupEntry(\"add\", { itemName: className })) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: className, path: constraintPath}) as SchemaRelationshipConstraintClassDifference;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: \"RelationshipClass\",\r\n itemName: className,\r\n path: constraintPath,\r\n json: [],\r\n });\r\n }\r\n\r\n const [constraintClass] = diagnostic.messageArgs as [ECClass];\r\n modifyEntry.json.push(constraintClass.fullName);\r\n }\r\n\r\n private visitChangedRelationshipConstraint(diagnostic: AnyDiagnostic) {\r\n const constraint = diagnostic.ecDefinition as RelationshipConstraint;\r\n const className = constraint.relationshipClass.name;\r\n const constraintPath = `$${constraint.isSource ? \"source\" : \"target\"}`;\r\n if(this.lookupEntry(\"add\", { itemName: className })) {\r\n return;\r\n }\r\n\r\n let modifyEntry = this.lookupEntry(\"modify\", { itemName: className, path: constraintPath }) as SchemaRelationshipConstraintDifference;\r\n if(!modifyEntry) {\r\n modifyEntry = this.addEntry({\r\n changeType: \"modify\",\r\n schemaType: \"RelationshipConstraint\",\r\n itemName: className,\r\n path: constraintPath,\r\n json: {},\r\n });\r\n }\r\n\r\n const [propertyName, propertyValue] = diagnostic.messageArgs as [keyof RelationshipConstraintProps, any];\r\n if(propertyValue !== undefined) {\r\n modifyEntry.json[propertyName] = propertyValue;\r\n }\r\n }\r\n\r\n private visitSchemaReference(diagnostic: AnyDiagnostic, changeType: DifferenceType) {\r\n const [referencedSchema] = diagnostic.messageArgs as [Schema];\r\n this.addEntry({\r\n changeType,\r\n schemaType: \"Schema\",\r\n path: \"$references\",\r\n json: {\r\n name: referencedSchema.name,\r\n version: referencedSchema.schemaKey.version.toString(),\r\n },\r\n });\r\n }\r\n\r\n private visitMissingCustomAttributeInstance(diagnostic: AnyDiagnostic) {\r\n const { schemaType, itemName, path } = getItemNameAndPath(diagnostic.ecDefinition);\r\n if(itemName && (this.lookupEntry(\"add\", { itemName }) || this.lookupEntry(\"add\", { itemName, path }))) {\r\n return;\r\n }\r\n\r\n const [customAttribute] = diagnostic.messageArgs as [CustomAttribute];\r\n this.addEntry({\r\n changeType: \"add\",\r\n schemaType,\r\n itemName: itemName!,\r\n path: `${path ? `${path}.` : \"\"}$customAttributes`,\r\n json: customAttribute as any,\r\n });\r\n }\r\n}\r\n\r\nfunction getItemNameAndPath(type: AnyECType): { schemaType: SchemaType, itemName?: string, path?: string } {\r\n if(Schema.isSchema(type))\r\n return {\r\n schemaType: \"Schema\",\r\n };\r\n if(SchemaItem.isSchemaItem(type))\r\n return {\r\n schemaType: getSchemaItemName(type.schemaItemType),\r\n itemName: type.name,\r\n };\r\n if(type instanceof Property)\r\n return {\r\n schemaType: \"Property\",\r\n itemName: type.class.name,\r\n path: type.name,\r\n };\r\n if(type instanceof RelationshipConstraint)\r\n return {\r\n schemaType: \"RelationshipClass\",\r\n itemName: type.relationshipClass.name,\r\n path: type.isSource ? \"$source\" : \"$target\",\r\n };\r\n throw Error(\"Unhandled Type\");\r\n}\r\n\r\nfunction getSchemaItemName(schemaItemType: SchemaItemType) {\r\n return schemaItemTypeToString(schemaItemType) as SchemaItemTypeName;\r\n}\r\n"]}
@@ -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;AAsCpE;;GAEG;AACH,IAAiB,gBAAgB,CAsChC;AAtCD,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,CAAC,CAAC;IACzD,CAAC;IANqB,4BAAW,cAMhC,CAAA;IAED;;;;;;OAMG;IACI,KAAK,UAAU,iBAAiB,CAAC,YAAoB,EAAE,aAA4B;QACxF,MAAM,gBAAgB,GAAsB;YAC1C,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3D,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;YACnD,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,iDAAuB,CAAC,gBAAgB,CAAC,CAAC;QAC9D,KAAI,MAAM,UAAU,IAAI,aAAa,CAAC,cAAc,EAAE;YACpD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SAC3B;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAdqB,kCAAiB,oBActC,CAAA;AACH,CAAC,EAtCgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAsChC","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 type {\n AnyEnumerator, AnyPropertyProps, AnySchemaItemProps, CustomAttribute, RelationshipConstraintProps, Schema,\n SchemaProps, SchemaReferenceProps,\n} from \"@itwin/ecschema-metadata\";\n\n/**\n * Defines the type of the difference operation.\n * @internal\n */\nexport type DifferenceType = \"add\" | \"modify\";\n\n/**\n * Defines a set of SchemaItem names.\n * @internal\n */\nexport type SchemaItemTypeName =\n \"EntityClass\" |\n \"Mixin\" |\n \"StructClass\" |\n \"CustomAttributeClass\" |\n \"RelationshipClass\" |\n \"Enumeration\" |\n \"KindOfQuantity\" |\n \"PropertyCategory\" |\n \"Unit\" |\n \"InvertedUnit\" |\n \"Constant\" |\n \"Phenomenon\" |\n \"UnitSystem\" |\n \"Format\";\n\n/**\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\n * @internal\n */\nexport type SchemaType = \"Schema\" | SchemaItemTypeName | \"Property\" | \"RelationshipConstraint\";\n\n/**\n * @internal\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 * @internal\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 schemaDifference: SchemaDifferences = {\n sourceSchemaName: schemaChanges.schema.schemaKey.toString(),\n targetSchemaName: targetSchema.schemaKey.toString(),\n changes: [],\n conflicts: [],\n };\n\n const visitor = new SchemaDiagnosticVisitor(schemaDifference);\n for(const diagnostic of schemaChanges.allDiagnostics) {\n visitor.visit(diagnostic);\n }\n\n return schemaDifference;\n }\n}\n\ntype MutualPartial<T> = {\n -readonly [P in keyof T]?: T[P];\n};\n\n/**\n * @internal\n */\nexport interface SchemaDifferences {\n\n readonly sourceSchemaName: string;\n readonly targetSchemaName: string;\n\n readonly changes: AnySchemaDifference[];\n readonly conflicts: SchemaDifferenceConflict[];\n}\n\n/**\n * @internal\n */\nexport type AnySchemaDifference =\n SchemaDifference |\n SchemaItemDifference |\n SchemaPropertyDifference |\n SchemaReferenceDifference |\n SchemaEnumeratorDifference |\n SchemaClassMixinDifference |\n SchemaRelationshipConstraintDifference |\n SchemaRelationshipConstraintClassDifference |\n SchemaCustomAttributeDifference;\n\n/**\n * @internal\n */\nexport interface SchemaDifference {\n changeType: \"modify\";\n schemaType: \"Schema\";\n itemName?: undefined;\n path?: undefined;\n json: MutualPartial<SchemaProps>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaItemDifference<T extends AnySchemaItemProps = AnySchemaItemProps> {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: SchemaItemTypeName;\n itemName: string;\n path?: string;\n json: MutualPartial<T>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaPropertyDifference<T extends AnyPropertyProps = AnyPropertyProps> {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: \"Property\";\n itemName: string;\n path: string;\n json: MutualPartial<T>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaReferenceDifference {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: \"Schema\";\n itemName?: undefined;\n path: \"$references\";\n json: MutualPartial<SchemaReferenceProps>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaEnumeratorDifference {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: \"Enumeration\";\n itemName: string;\n path: string;\n json: MutualPartial<AnyEnumerator>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaClassMixinDifference {\n changeType: \"modify\";\n schemaType: \"EntityClass\";\n itemName: string;\n path: \"$mixins\";\n json: string[];\n}\n\n/**\n * @internal\n */\nexport interface SchemaRelationshipConstraintDifference {\n changeType: \"modify\";\n schemaType: \"RelationshipConstraint\";\n itemName: string;\n path: string;\n json: MutualPartial<RelationshipConstraintProps>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaRelationshipConstraintClassDifference {\n changeType: \"modify\";\n schemaType: \"RelationshipClass\";\n itemName: string;\n path: string;\n json: string[];\n}\n\n/**\n * @internal\n */\nexport interface SchemaCustomAttributeDifference {\n changeType: \"add\" | \"modify\";\n schemaType: \"Schema\" | \"EnitityClass\" | \"Properties\" | \"RelationshipConstraint\";\n itemName?: string;\n path?: string;\n json: MutualPartial<CustomAttribute>;\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;AAsCpE;;GAEG;AACH,IAAiB,gBAAgB,CAsChC;AAtCD,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,CAAC,CAAC;IACzD,CAAC;IANqB,4BAAW,cAMhC,CAAA;IAED;;;;;;OAMG;IACI,KAAK,UAAU,iBAAiB,CAAC,YAAoB,EAAE,aAA4B;QACxF,MAAM,gBAAgB,GAAsB;YAC1C,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3D,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;YACnD,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,iDAAuB,CAAC,gBAAgB,CAAC,CAAC;QAC9D,KAAI,MAAM,UAAU,IAAI,aAAa,CAAC,cAAc,EAAE;YACpD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SAC3B;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAdqB,kCAAiB,oBActC,CAAA;AACH,CAAC,EAtCgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAsChC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport type {\r\n AnyEnumerator, AnyPropertyProps, AnySchemaItemProps, CustomAttribute, RelationshipConstraintProps, Schema,\r\n SchemaProps, SchemaReferenceProps,\r\n} from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @internal\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines a set of SchemaItem names.\r\n * @internal\r\n */\r\nexport type SchemaItemTypeName =\r\n \"EntityClass\" |\r\n \"Mixin\" |\r\n \"StructClass\" |\r\n \"CustomAttributeClass\" |\r\n \"RelationshipClass\" |\r\n \"Enumeration\" |\r\n \"KindOfQuantity\" |\r\n \"PropertyCategory\" |\r\n \"Unit\" |\r\n \"InvertedUnit\" |\r\n \"Constant\" |\r\n \"Phenomenon\" |\r\n \"UnitSystem\" |\r\n \"Format\";\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @internal\r\n */\r\nexport type SchemaType = \"Schema\" | SchemaItemTypeName | \"Property\" | \"RelationshipConstraint\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport namespace SchemaDifference {\r\n /**\r\n * Creates a [[SchemaDifference]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifference]] object.\r\n * @internal\r\n */\r\n export async function fromSchemas(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferences> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n return fromSchemaChanges(targetSchema, changesList[0]);\r\n }\r\n\r\n /**\r\n * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.\r\n * @param targetSchema\r\n * @param schemaChanges A changes report of two schemas.\r\n * @returns An [[SchemaDifference]] object.\r\n * @internal\r\n */\r\n export async function fromSchemaChanges(targetSchema: Schema, schemaChanges: SchemaChanges): Promise<SchemaDifferences> {\r\n const schemaDifference: SchemaDifferences = {\r\n sourceSchemaName: schemaChanges.schema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n changes: [],\r\n conflicts: [],\r\n };\r\n\r\n const visitor = new SchemaDiagnosticVisitor(schemaDifference);\r\n for(const diagnostic of schemaChanges.allDiagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n return schemaDifference;\r\n }\r\n}\r\n\r\ntype MutualPartial<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaDifferences {\r\n\r\n readonly sourceSchemaName: string;\r\n readonly targetSchemaName: string;\r\n\r\n readonly changes: AnySchemaDifference[];\r\n readonly conflicts: SchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaItemDifference |\r\n SchemaPropertyDifference |\r\n SchemaReferenceDifference |\r\n SchemaEnumeratorDifference |\r\n SchemaClassMixinDifference |\r\n SchemaRelationshipConstraintDifference |\r\n SchemaRelationshipConstraintClassDifference |\r\n SchemaCustomAttributeDifference;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaDifference {\r\n changeType: \"modify\";\r\n schemaType: \"Schema\";\r\n itemName?: undefined;\r\n path?: undefined;\r\n json: MutualPartial<SchemaProps>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaItemDifference<T extends AnySchemaItemProps = AnySchemaItemProps> {\r\n changeType: \"add\" | \"modify\" | \"remove\";\r\n schemaType: SchemaItemTypeName;\r\n itemName: string;\r\n path?: string;\r\n json: MutualPartial<T>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaPropertyDifference<T extends AnyPropertyProps = AnyPropertyProps> {\r\n changeType: \"add\" | \"modify\" | \"remove\";\r\n schemaType: \"Property\";\r\n itemName: string;\r\n path: string;\r\n json: MutualPartial<T>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaReferenceDifference {\r\n changeType: \"add\" | \"modify\" | \"remove\";\r\n schemaType: \"Schema\";\r\n itemName?: undefined;\r\n path: \"$references\";\r\n json: MutualPartial<SchemaReferenceProps>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaEnumeratorDifference {\r\n changeType: \"add\" | \"modify\" | \"remove\";\r\n schemaType: \"Enumeration\";\r\n itemName: string;\r\n path: string;\r\n json: MutualPartial<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaClassMixinDifference {\r\n changeType: \"modify\";\r\n schemaType: \"EntityClass\";\r\n itemName: string;\r\n path: \"$mixins\";\r\n json: string[];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaRelationshipConstraintDifference {\r\n changeType: \"modify\";\r\n schemaType: \"RelationshipConstraint\";\r\n itemName: string;\r\n path: string;\r\n json: MutualPartial<RelationshipConstraintProps>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaRelationshipConstraintClassDifference {\r\n changeType: \"modify\";\r\n schemaType: \"RelationshipClass\";\r\n itemName: string;\r\n path: string;\r\n json: string[];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface SchemaCustomAttributeDifference {\r\n changeType: \"add\" | \"modify\";\r\n schemaType: \"Schema\" | \"EnitityClass\" | \"Properties\" | \"RelationshipConstraint\";\r\n itemName?: string;\r\n path?: string;\r\n json: MutualPartial<CustomAttribute>;\r\n}\r\n"]}
@@ -1 +1 @@
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,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AM,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;I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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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { ConstantProps, DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableConstant } from \"./Mutable/MutableConstant\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Constant.\r\n */\r\nexport class Constants {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n const newConstant = (await schema.createConstant(name)) as MutableConstant;\r\n if (newConstant === undefined) {\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n }\r\n\r\n const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem<Phenomenon>(phenomenon));\r\n if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== SchemaItemType.Phenomenon) {\r\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };\r\n }\r\n newConstant.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(newPhenomenon.key, async () => newPhenomenon));\r\n newConstant.setDefinition(definition);\r\n\r\n if (numerator)\r\n newConstant.setNumerator(numerator);\r\n\r\n if (denominator)\r\n newConstant.setDenominator(denominator);\r\n\r\n if (displayLabel)\r\n newConstant.setDisplayLabel(displayLabel);\r\n\r\n return { itemKey: newConstant.key };\r\n }\r\n\r\n /**\r\n * Creates a Constant through a ConstantProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, constantProps: ConstantProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (constantProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newConstant = (await schema.createConstant(constantProps.name));\r\n if (newConstant === undefined)\r\n return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newConstant.fromJSON(constantProps);\r\n return { itemKey: newConstant.key };\r\n }\r\n}\r\n"]}
@@ -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,2CAAwC;AAGxC;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,qBAAS;IAC7C,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,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;YAC3B,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;SAChH;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(_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,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,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;YAC3B,MAAM,aAAa,GAAG,MAAM,M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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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n CustomAttributeClassProps, CustomAttributeContainerType, DelayedPromiseWithProps, ECClass,\r\n SchemaItemKey, SchemaItemType, SchemaKey,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableCAClass } from \"./Mutable/MutableCAClass\";\r\n\r\n/**\r\n * @alpha\r\n * A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.\r\n */\r\nexport class CustomAttributes extends ECClasses {\r\n public constructor(_schemaEditor: SchemaContextEditor) {\r\n super(_schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n const newClass = (await schema.createCustomAttributeClass(name)) as MutableCAClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n if (baseClass !== undefined) {\r\n const baseClassItem = await schema.lookupItem<ECClass>(baseClass);\r\n if (baseClassItem === undefined)\r\n return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };\r\n\r\n if (baseClassItem.schemaItemType !== SchemaItemType.CustomAttributeClass)\r\n return { errorMessage: `${baseClassItem.fullName} is not of type CustomAttribute Class.` };\r\n\r\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\r\n }\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n newClass.setContainerType(containerType);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n\r\n /**\r\n * Creates a CustomAttributeClass through a CustomAttributeClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (caProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newClass = (await schema.createCustomAttributeClass(caProps.name)) as MutableCAClass;\r\n if (newClass === undefined)\r\n return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newClass.fromJSON(caProps);\r\n\r\n return { itemKey: newClass.key };\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,SAAS;IAEpB,YAAgC,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAEvE;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,QAAuB,EAAE,IAAY,EAAE,IAAmB,EAAE,MAAc;QACpG,IAAI,YAA0B,CAAC;QAE/B,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,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AM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,YAA0B;QACzD,MAAM,cAAc,GAAwB,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QACtE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,EAAE;YACZ,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE;gBAChC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACxC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;aACF;YACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;SACxC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAnbD,8BAmbC","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 CustomAttribute,\n CustomAttributeContainerProps,\n DelayedPromiseWithProps,\n ECClass, ECName, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, PropertyCategory, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses {\n\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n return { itemKey: classKey, propertyName: prefixedName };\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(props);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.deleteProperty(name);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n return {};\n\n await schema.deleteClass(ecClass.name);\n\n return { itemKey: classKey };\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\n * @param classKey The SchemaItemKey identifying the class.\n * @param propertyName The name of the property.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\n if (!property) {\n return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n property.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(property, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Renames the property on the specified class. The rename will fail if the new\n * name causes a conflict with a base or derived property. All derived classes\n * containing a property override will be renamed, as well.\n * @param classKey The SchemaItemKey identifying the class.\n * @param existingPropertyName The name of the property.\n * @param newPropertyName The new property name.\n */\n public async setPropertyName(classKey: SchemaItemKey, existingPropertyName: string, newPropertyName: string): Promise<PropertyEditResults> {\n const newName = new ECName(newPropertyName);\n\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const existingProperty = await mutableClass.getProperty(existingPropertyName) as MutableProperty;\n if (!existingProperty) {\n return { errorMessage: `An ECProperty with the name ${existingPropertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n const baseProperty = await mutableClass.getProperty(newPropertyName, true) as MutableProperty;\n if (baseProperty)\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.` };\n\n // Handle derived classes\n const derivedProperties: Array<MutableProperty> = [];\n const derivedClasses = await this.findDerivedClasses(mutableClass);\n for (const derivedClass of derivedClasses) {\n if (await derivedClass.getProperty(newPropertyName))\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.` };\n\n const propertyOverride = await derivedClass.getProperty(existingPropertyName) as MutableProperty;\n // If found the property is overridden in the derived class.\n if (propertyOverride)\n derivedProperties.push(propertyOverride);\n }\n\n // Re-name the overridden property in all derived classes\n derivedProperties.forEach((prop: MutableProperty) => {\n prop.setName(newName);\n });\n\n existingProperty.setName(newName);\n\n return { itemKey: classKey, propertyName: newName.name };\n }\n\n /**\n * Sets the name of the ECClass.\n * @param classKey The SchemaItemKey of the class.\n * @param name The new name of the class.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined) {\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n }\n\n const ecClass = await schema.getItem<MutableClass>(name);\n if (ecClass !== undefined)\n return { errorMessage: `An EC Class with the name ${name} already exists within the schema ${schema.name}` };\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n mutableClass.setName(name);\n\n return {};\n }\n\n /**\n * Sets the Category to the Property.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.\n */\n public async setPropertyCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\n if (property === undefined) {\n return { errorMessage: `An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n const category = await mutableClass.schema.lookupItem<PropertyCategory>(categoryKey);\n if (category === undefined) {\n return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${mutableClass.schema.fullName}.` };\n }\n\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\n return { itemKey: classKey, propertyName };\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\n\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\n if (ecClass === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\n\n switch (ecClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n case SchemaItemType.CustomAttributeClass:\n case SchemaItemType.RelationshipClass:\n break;\n default:\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\n }\n\n return ecClass;\n }\n\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\n const derivedClasses: Array<MutableClass> = [];\n const schemaItems = this._schemaEditor.schemaContext.getSchemaItems();\n let { value, done } = schemaItems.next();\n while (!done) {\n if (await value.is(mutableClass)) {\n if (!mutableClass.key.matches(value.key)) {\n derivedClasses.push(value);\n }\n }\n ({ value, done } = schemaItems.next());\n }\n\n return derivedClasses;\n }\n}\n\n"]}
1
+ {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,SAAS;IAEpB,YAAgC,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAEvE;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,QAAuB,EAAE,IAAY,EAA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K,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgD,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,YAA0B;QACzD,MAAM,cAAc,GAAwB,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QACtE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,EAAE;YACZ,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE;gBAChC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACxC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;aACF;YACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;SACxC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAnbD,8BAmbC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport {\r\n CustomAttribute,\r\n CustomAttributeContainerProps,\r\n DelayedPromiseWithProps,\r\n ECClass, ECName, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\r\n PrimitivePropertyProps, PrimitiveType, PropertyCategory, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\r\n StructClass, StructPropertyProps,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableClass } from \"./Mutable/MutableClass\";\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\r\n\r\n/**\r\n * @alpha\r\n * Acts as a base class for schema class creation. Enables property creation.\r\n */\r\nexport class ECClasses {\r\n\r\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n\r\n /**\r\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\r\n * property type to primitives of type Double, String, DateTime and Integer.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The name of the new property.\r\n * @param type The PrimitiveType assigned to the new property.\r\n */\r\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n\r\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\r\n && type !== PrimitiveType.Integer)\r\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\r\n\r\n if (\"\" === prefix)\r\n throw new Error(\"The specified property name prefix is invalid\");\r\n\r\n const prefixedName = `${prefix}_${name}`;\r\n\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveProperty(prefixedName, type);\r\n return { itemKey: classKey, propertyName: prefixedName };\r\n }\r\n\r\n /**\r\n * Create a primitive property on class identified by the given SchemaItemKey.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The name of the new property.\r\n * @param type The PrimitiveType assigned to the new property.\r\n */\r\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\r\n if (enumSchemaItemKey === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\r\n\r\n await mutableClass.createPrimitiveProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\r\n await newProperty.fromJSON(enumProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(primitiveProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createPrimitiveArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\r\n await newProperty.fromJSON(props);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createStructProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createStructProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.createStructArrayProperty(name, type);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\r\n await newProperty.fromJSON(structProps);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n await mutableClass.deleteProperty(name);\r\n return { itemKey: classKey, propertyName: name };\r\n }\r\n\r\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\r\n\r\n const ecClass = await schema.getItem<ECClass>(classKey.name);\r\n if (ecClass === undefined)\r\n return {};\r\n\r\n await schema.deleteClass(ecClass.name);\r\n\r\n return { itemKey: classKey };\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\r\n * @param classKey The SchemaItemKey identifying the schema.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n mutableClass.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\r\n\r\n const result: SchemaItemEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(mutableClass, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param propertyName The name of the property.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\r\n if (!property) {\r\n return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\r\n }\r\n\r\n property.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\r\n\r\n const result: SchemaItemEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(property, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Renames the property on the specified class. The rename will fail if the new\r\n * name causes a conflict with a base or derived property. All derived classes\r\n * containing a property override will be renamed, as well.\r\n * @param classKey The SchemaItemKey identifying the class.\r\n * @param existingPropertyName The name of the property.\r\n * @param newPropertyName The new property name.\r\n */\r\n public async setPropertyName(classKey: SchemaItemKey, existingPropertyName: string, newPropertyName: string): Promise<PropertyEditResults> {\r\n const newName = new ECName(newPropertyName);\r\n\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const existingProperty = await mutableClass.getProperty(existingPropertyName) as MutableProperty;\r\n if (!existingProperty) {\r\n return { errorMessage: `An ECProperty with the name ${existingPropertyName} could not be found in the class ${classKey.fullName}.` };\r\n }\r\n\r\n const baseProperty = await mutableClass.getProperty(newPropertyName, true) as MutableProperty;\r\n if (baseProperty)\r\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.` };\r\n\r\n // Handle derived classes\r\n const derivedProperties: Array<MutableProperty> = [];\r\n const derivedClasses = await this.findDerivedClasses(mutableClass);\r\n for (const derivedClass of derivedClasses) {\r\n if (await derivedClass.getProperty(newPropertyName))\r\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.` };\r\n\r\n const propertyOverride = await derivedClass.getProperty(existingPropertyName) as MutableProperty;\r\n // If found the property is overridden in the derived class.\r\n if (propertyOverride)\r\n derivedProperties.push(propertyOverride);\r\n }\r\n\r\n // Re-name the overridden property in all derived classes\r\n derivedProperties.forEach((prop: MutableProperty) => {\r\n prop.setName(newName);\r\n });\r\n\r\n existingProperty.setName(newName);\r\n\r\n return { itemKey: classKey, propertyName: newName.name };\r\n }\r\n\r\n /**\r\n * Sets the name of the ECClass.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param name The new name of the class.\r\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\r\n */\r\n public async setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults> {\r\n let mutableClass: MutableClass;\r\n\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined) {\r\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\r\n }\r\n\r\n const ecClass = await schema.getItem<MutableClass>(name);\r\n if (ecClass !== undefined)\r\n return { errorMessage: `An EC Class with the name ${name} already exists within the schema ${schema.name}` };\r\n\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n mutableClass.setName(name);\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Sets the Category to the Property.\r\n * @param classKey The SchemaItemKey of the class.\r\n * @param propertyName The name of the property.\r\n * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.\r\n */\r\n public async setPropertyCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey): Promise<PropertyEditResults> {\r\n let mutableClass: MutableClass;\r\n try {\r\n mutableClass = await this.getClass(classKey);\r\n } catch (e: any) {\r\n return { errorMessage: e.message };\r\n }\r\n\r\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\r\n if (property === undefined) {\r\n return { errorMessage: `An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\r\n }\r\n\r\n const category = await mutableClass.schema.lookupItem<PropertyCategory>(categoryKey);\r\n if (category === undefined) {\r\n return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${mutableClass.schema.fullName}.` };\r\n }\r\n\r\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\r\n return { itemKey: classKey, propertyName };\r\n }\r\n\r\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\r\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\r\n if (schema === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\r\n\r\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\r\n if (ecClass === undefined)\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\r\n\r\n switch (ecClass.schemaItemType) {\r\n case SchemaItemType.EntityClass:\r\n case SchemaItemType.Mixin:\r\n case SchemaItemType.StructClass:\r\n case SchemaItemType.CustomAttributeClass:\r\n case SchemaItemType.RelationshipClass:\r\n break;\r\n default:\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\r\n }\r\n\r\n return ecClass;\r\n }\r\n\r\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\r\n assert(container.customAttributes !== undefined);\r\n const map = container.customAttributes as Map<string, CustomAttribute>;\r\n map.delete(customAttribute.className);\r\n }\r\n\r\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\r\n const derivedClasses: Array<MutableClass> = [];\r\n const schemaItems = this._schemaEditor.schemaContext.getSchemaItems();\r\n let { value, done } = schemaItems.next();\r\n while (!done) {\r\n if (await value.is(mutableClass)) {\r\n if (!mutableClass.key.matches(value.key)) {\r\n derivedClasses.push(value);\r\n }\r\n }\r\n ({ value, done } = schemaItems.next());\r\n }\r\n\r\n return derivedClasses;\r\n }\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+CAA+C;AAC/C,gEAA6H;AAE7H,sDAA6C;AAC7C,2CAAwC;AACxC,yDAAsD;AACtD,yCAAsC;AACtC,iDAA8C;AAC9C,uCAAoC;AACpC,mDAAgD;AAChD,yDAAsD;AACtD,qCAAkC;AAClC,2CAAwC;AACxC,6DAA0D;AAC1D,+DAA4D;AAC5D,uCAAoC;AACpC,mCA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BAAM,EAAC,MAAM,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgD,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAhKD,kDAgKC","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 * as Rules from \"../Validation/ECRules\";\nimport { CustomAttribute, Schema, SchemaContext, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Constants } from \"./Constants\";\nimport { CustomAttributes } from \"./CustomAttributes\";\nimport { Entities } from \"./Entities\";\nimport { Enumerations } from \"./Enumerations\";\nimport { Formats } from \"./Formats\";\nimport { InvertedUnits } from \"./InvertedUnits\";\nimport { KindOfQuantities } from \"./KindOfQuantities\";\nimport { Mixins } from \"./Mixins\";\nimport { Phenomena } from \"./Phenomena\";\nimport { PropertyCategories } from \"./PropertyCategories\";\nimport { RelationshipClasses } from \"./RelationshipClasses\";\nimport { Structs } from \"./Structs\";\nimport { Units } from \"./Units\";\nimport { UnitSystems } from \"./UnitSystems\";\nimport { SchemaItems } from \"./SchemaItems\";\n\n// We can either add validation in Editor, or in the protected methods of Schema.\n// TODO: Add an error code so we can do something programmatic with the error.\n/**\n * @alpha\n */\nexport interface SchemaEditResults {\n schemaKey?: SchemaKey;\n errorMessage?: string;\n}\n\n/**\n * @alpha\n */\nexport interface SchemaItemEditResults {\n itemKey?: SchemaItemKey;\n errorMessage?: string;\n}\n\n/**\n * @alpha\n */\nexport interface PropertyEditResults {\n itemKey?: SchemaItemKey;\n propertyName?: string;\n errorMessage?: string;\n}\n\n/**\n * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.\n * @alpha\n */\nexport class SchemaContextEditor {\n private _schemaContext: SchemaContext;\n public readonly entities = new Entities(this);\n public readonly mixins = new Mixins(this);\n public readonly structs = new Structs(this);\n public readonly customAttributes = new CustomAttributes(this);\n public readonly relationships = new RelationshipClasses(this);\n public readonly constants = new Constants(this);\n public readonly enumerations = new Enumerations(this);\n public readonly formats = new Formats(this);\n public readonly kindOfQuantities = new KindOfQuantities(this);\n public readonly units = new Units(this);\n public readonly phenomenons = new Phenomena(this);\n public readonly unitSystems = new UnitSystems(this);\n public readonly propertyCategories = new PropertyCategories(this);\n public readonly invertedUnits = new InvertedUnits(this);\n\n /** @internal */\n public readonly schemaItems = new SchemaItems(this);\n\n /**\n * Creates a new SchemaContextEditor instance.\n * @param schemaContext The SchemaContext the Editor will use to edit in.\n */\n constructor(schemaContext: SchemaContext) {\n // TODO: Make copy\n this._schemaContext = schemaContext;\n }\n\n /** Allows you to get schema classes and items through regular SchemaContext methods. */\n public get schemaContext(): SchemaContext { return this._schemaContext; }\n\n public async finish(): Promise<SchemaContext> {\n return this._schemaContext;\n }\n\n /**\n * Helper method for retrieving a schema, previously added, from the SchemaContext.\n * @param schemaKey The SchemaKey identifying the schema.\n */\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema | undefined> {\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest));\n if (schema === undefined)\n return undefined;\n\n return schema;\n }\n /**\n * Creates a Schema with the given properties and adds it to the current schema context.\n * @param name The name given to the new schema.\n * @param alias The alias of the new schema.\n * @param readVersion The read version number of the schema.\n * @param writeVersion The write version number of the schema.\n * @param minorVersion The minor version number of the schema.\n * @returns Resolves to a SchemaEditResults object.\n */\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaEditResults> {\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\n await this._schemaContext.addSchema(newSchema);\n return { schemaKey: newSchema.schemaKey };\n }\n\n /**\n * Adds a referenced schema to the schema identified by the given SchemaKey.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param refSchema The referenced schema to add.\n */\n public async addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<SchemaEditResults> {\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Exact));\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n await schema.addReference(refSchema);\n const diagnostics = Rules.validateSchemaReferences(schema);\n\n const result: SchemaEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeReference(schema, refSchema);\n return result;\n }\n\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\n await this.schemaContext.addSchema(refSchema);\n }\n\n return {};\n }\n\n /**\n * Adds a CustomAttribute instance to the schema identified by the given SchemaKey\n * @param schemaKey The SchemaKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<SchemaEditResults> {\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest));\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n schema.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(schema, customAttribute);\n\n const result: SchemaEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(schema, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Sets the schema version.\n * @param schemaKey The SchemaKey identifying the schema.\n * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.\n * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.\n * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.\n */\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaEditResults> {\n const schema = (await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest));\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\n return {};\n }\n\n /**\n * Increments the minor version of a schema.\n * @param schemaKey The SchemaKey identifying the schema.\n */\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaEditResults> {\n const schema = (await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest));\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\n return {};\n }\n\n private removeReference(schema: Schema, refSchema: Schema) {\n const index: number = schema.references.indexOf(refSchema);\n if (index !== -1) {\n schema.references.splice(index, 1);\n }\n }\n\n private removeCustomAttribute(schema: Schema, customAttribute: CustomAttribute) {\n assert(schema.customAttributes !== undefined);\n const map = schema.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n}\n\n"]}
1
+ {"version":3,"file":"Editor.js","sourceRoot":"","sources":["../../../src/Editing/Editor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+CAA+C;AAC/C,gEAA6H;AAE7H,sDAA6C;AAC7C,2CAAwC;AACxC,yDAAsD;AACtD,yCAAsC;AACtC,iDAA8C;AAC9C,uCAAoC;AACpC,mDAAgD;AAChD,yDAAsD;AACtD,qCAAkC;AAClC,2CAAwC;AACxC,6DAA0D;AAC1D,+DAA4D;AAC5D,uCAAoC;AACpC,mCAAgC;AAChC,+CAA4C;AAC5C,+CAA4C;AA6B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AAS,CAAC,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgD,CAAC;QACpE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAhKD,kDAgKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport * as Rules from \"../Validation/ECRules\";\r\nimport { CustomAttribute, Schema, SchemaContext, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Constants } from \"./Constants\";\r\nimport { CustomAttributes } from \"./CustomAttributes\";\r\nimport { Entities } from \"./Entities\";\r\nimport { Enumerations } from \"./Enumerations\";\r\nimport { Formats } from \"./Formats\";\r\nimport { InvertedUnits } from \"./InvertedUnits\";\r\nimport { KindOfQuantities } from \"./KindOfQuantities\";\r\nimport { Mixins } from \"./Mixins\";\r\nimport { Phenomena } from \"./Phenomena\";\r\nimport { PropertyCategories } from \"./PropertyCategories\";\r\nimport { RelationshipClasses } from \"./RelationshipClasses\";\r\nimport { Structs } from \"./Structs\";\r\nimport { Units } from \"./Units\";\r\nimport { UnitSystems } from \"./UnitSystems\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n// We can either add validation in Editor, or in the protected methods of Schema.\r\n// TODO: Add an error code so we can do something programmatic with the error.\r\n/**\r\n * @alpha\r\n */\r\nexport interface SchemaEditResults {\r\n schemaKey?: SchemaKey;\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport interface SchemaItemEditResults {\r\n itemKey?: SchemaItemKey;\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport interface PropertyEditResults {\r\n itemKey?: SchemaItemKey;\r\n propertyName?: string;\r\n errorMessage?: string;\r\n}\r\n\r\n/**\r\n * A class that allows you to edit and create schemas, classes, and items from the SchemaContext level.\r\n * @alpha\r\n */\r\nexport class SchemaContextEditor {\r\n private _schemaContext: SchemaContext;\r\n public readonly entities = new Entities(this);\r\n public readonly mixins = new Mixins(this);\r\n public readonly structs = new Structs(this);\r\n public readonly customAttributes = new CustomAttributes(this);\r\n public readonly relationships = new RelationshipClasses(this);\r\n public readonly constants = new Constants(this);\r\n public readonly enumerations = new Enumerations(this);\r\n public readonly formats = new Formats(this);\r\n public readonly kindOfQuantities = new KindOfQuantities(this);\r\n public readonly units = new Units(this);\r\n public readonly phenomenons = new Phenomena(this);\r\n public readonly unitSystems = new UnitSystems(this);\r\n public readonly propertyCategories = new PropertyCategories(this);\r\n public readonly invertedUnits = new InvertedUnits(this);\r\n\r\n /** @internal */\r\n public readonly schemaItems = new SchemaItems(this);\r\n\r\n /**\r\n * Creates a new SchemaContextEditor instance.\r\n * @param schemaContext The SchemaContext the Editor will use to edit in.\r\n */\r\n constructor(schemaContext: SchemaContext) {\r\n // TODO: Make copy\r\n this._schemaContext = schemaContext;\r\n }\r\n\r\n /** Allows you to get schema classes and items through regular SchemaContext methods. */\r\n public get schemaContext(): SchemaContext { return this._schemaContext; }\r\n\r\n public async finish(): Promise<SchemaContext> {\r\n return this._schemaContext;\r\n }\r\n\r\n /**\r\n * Helper method for retrieving a schema, previously added, from the SchemaContext.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n */\r\n public async getSchema(schemaKey: SchemaKey): Promise<MutableSchema | undefined> {\r\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return undefined;\r\n\r\n return schema;\r\n }\r\n /**\r\n * Creates a Schema with the given properties and adds it to the current schema context.\r\n * @param name The name given to the new schema.\r\n * @param alias The alias of the new schema.\r\n * @param readVersion The read version number of the schema.\r\n * @param writeVersion The write version number of the schema.\r\n * @param minorVersion The minor version number of the schema.\r\n * @returns Resolves to a SchemaEditResults object.\r\n */\r\n public async createSchema(name: string, alias: string, readVersion: number, writeVersion: number, minorVersion: number): Promise<SchemaEditResults> {\r\n const newSchema = new Schema(this._schemaContext, name, alias, readVersion, writeVersion, minorVersion);\r\n await this._schemaContext.addSchema(newSchema);\r\n return { schemaKey: newSchema.schemaKey };\r\n }\r\n\r\n /**\r\n * Adds a referenced schema to the schema identified by the given SchemaKey.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param refSchema The referenced schema to add.\r\n */\r\n public async addSchemaReference(schemaKey: SchemaKey, refSchema: Schema): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Exact));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n await schema.addReference(refSchema);\r\n const diagnostics = Rules.validateSchemaReferences(schema);\r\n\r\n const result: SchemaEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeReference(schema, refSchema);\r\n return result;\r\n }\r\n\r\n if (!await this.schemaContext.getCachedSchema(refSchema.schemaKey)) {\r\n await this.schemaContext.addSchema(refSchema);\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Adds a CustomAttribute instance to the schema identified by the given SchemaKey\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param customAttribute The CustomAttribute instance to add.\r\n */\r\n public async addCustomAttribute(schemaKey: SchemaKey, customAttribute: CustomAttribute): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema<MutableSchema>(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n schema.addCustomAttribute(customAttribute);\r\n\r\n const diagnostics = Rules.validateCustomAttributeInstance(schema, customAttribute);\r\n\r\n const result: SchemaEditResults = { errorMessage: \"\" };\r\n for await (const diagnostic of diagnostics) {\r\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\r\n }\r\n\r\n if (result.errorMessage) {\r\n this.removeCustomAttribute(schema, customAttribute);\r\n return result;\r\n }\r\n\r\n return {};\r\n }\r\n\r\n /**\r\n * Sets the schema version.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n * @param readVersion The read version of the schema. If not specified, the existing read version will be maintained.\r\n * @param writeVersion The write version of the schema. If not specified, the existing write version will be maintained.\r\n * @param minorVersion The minor version of the schema. If not specified, the existing minor version will be maintained.\r\n */\r\n public async setVersion(schemaKey: SchemaKey, readVersion?: number, writeVersion?: number, minorVersion?: number): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n schema.setVersion(readVersion || schema.readVersion, writeVersion || schema.writeVersion, minorVersion || schema.minorVersion);\r\n return {};\r\n }\r\n\r\n /**\r\n * Increments the minor version of a schema.\r\n * @param schemaKey The SchemaKey identifying the schema.\r\n */\r\n public async incrementMinorVersion(schemaKey: SchemaKey): Promise<SchemaEditResults> {\r\n const schema = (await this.schemaContext.getCachedSchema(schemaKey, SchemaMatchType.Latest));\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n schema.setVersion(schema.readVersion, schema.writeVersion, schema.minorVersion + 1);\r\n return {};\r\n }\r\n\r\n private removeReference(schema: Schema, refSchema: Schema) {\r\n const index: number = schema.references.indexOf(refSchema);\r\n if (index !== -1) {\r\n schema.references.splice(index, 1);\r\n }\r\n }\r\n\r\n private removeCustomAttribute(schema: Schema, customAttribute: CustomAttribute) {\r\n assert(schema.customAttributes !== undefined);\r\n const map = schema.customAttributes as Map<string, CustomAttribute>;\r\n map.delete(customAttribute.className);\r\n }\r\n}\r\n\r\n"]}