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

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 (112) hide show
  1. package/lib/cjs/Differencing/SchemaConflicts.d.ts +2 -2
  2. package/lib/cjs/Differencing/SchemaConflicts.js +1 -1
  3. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  4. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +9 -6
  5. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +213 -161
  7. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  8. package/lib/cjs/Differencing/SchemaDifference.d.ts +354 -78
  9. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  10. package/lib/cjs/Differencing/SchemaDifference.js +184 -11
  11. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  12. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +1 -0
  13. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts.map +1 -1
  14. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  15. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +1 -0
  16. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts.map +1 -1
  17. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  18. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +2 -0
  19. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
  20. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  21. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +1 -0
  22. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +1 -0
  25. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +2 -0
  28. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +1 -0
  31. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  33. package/lib/cjs/Merging/CAClassMerger.d.ts +4 -7
  34. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  35. package/lib/cjs/Merging/CAClassMerger.js +26 -23
  36. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  37. package/lib/cjs/Merging/ClassMerger.d.ts +10 -18
  38. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  39. package/lib/cjs/Merging/ClassMerger.js +148 -155
  40. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  41. package/lib/cjs/Merging/ConstantMerger.d.ts +4 -8
  42. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  43. package/lib/cjs/Merging/ConstantMerger.js +59 -40
  44. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  45. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +16 -13
  46. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  47. package/lib/cjs/Merging/CustomAttributeMerger.js +66 -34
  48. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  49. package/lib/cjs/Merging/EntityClassMerger.d.ts +10 -7
  50. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  51. package/lib/cjs/Merging/EntityClassMerger.js +41 -29
  52. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  53. package/lib/cjs/Merging/EnumerationMerger.d.ts +9 -9
  54. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  55. package/lib/cjs/Merging/EnumerationMerger.js +77 -48
  56. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  57. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +4 -11
  58. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  59. package/lib/cjs/Merging/KindOfQuantityMerger.js +57 -53
  60. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  61. package/lib/cjs/Merging/MixinMerger.d.ts +4 -7
  62. package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
  63. package/lib/cjs/Merging/MixinMerger.js +24 -25
  64. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  65. package/lib/cjs/Merging/PhenomenonMerger.d.ts +8 -0
  66. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -0
  67. package/lib/cjs/Merging/PhenomenonMerger.js +37 -0
  68. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -0
  69. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +8 -0
  70. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -0
  71. package/lib/cjs/Merging/PropertyCategoryMerger.js +34 -0
  72. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -0
  73. package/lib/cjs/Merging/PropertyMerger.d.ts +6 -14
  74. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  75. package/lib/cjs/Merging/PropertyMerger.js +212 -287
  76. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  77. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +16 -10
  78. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  79. package/lib/cjs/Merging/RelationshipClassMerger.js +121 -112
  80. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  81. package/lib/cjs/Merging/SchemaItemMerger.d.ts +26 -51
  82. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  83. package/lib/cjs/Merging/SchemaItemMerger.js +106 -88
  84. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  85. package/lib/cjs/Merging/SchemaMerger.d.ts +21 -9
  86. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  87. package/lib/cjs/Merging/SchemaMerger.js +74 -88
  88. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  89. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +5 -5
  90. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
  91. package/lib/cjs/Merging/SchemaReferenceMerger.js +33 -15
  92. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  93. package/lib/cjs/Merging/UnitSystemMerger.d.ts +8 -0
  94. package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -0
  95. package/lib/cjs/Merging/UnitSystemMerger.js +26 -0
  96. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -0
  97. package/lib/cjs/Validation/ECRules.js +1 -1
  98. package/lib/cjs/Validation/ECRules.js.map +1 -1
  99. package/lib/cjs/Validation/SchemaChanges.js +1 -1
  100. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  101. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  102. package/lib/cjs/Validation/SchemaComparer.js +3 -3
  103. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  104. package/package.json +9 -9
  105. package/lib/cjs/Merging/SchemaItemFactory.d.ts +0 -15
  106. package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +0 -1
  107. package/lib/cjs/Merging/SchemaItemFactory.js +0 -82
  108. package/lib/cjs/Merging/SchemaItemFactory.js.map +0 -1
  109. package/lib/cjs/Merging/StructClassMerger.d.ts +0 -10
  110. package/lib/cjs/Merging/StructClassMerger.d.ts.map +0 -1
  111. package/lib/cjs/Merging/StructClassMerger.js +0 -13
  112. package/lib/cjs/Merging/StructClassMerger.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4EAA4E;YAC5E,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAEzE,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC5B,MAAM,KAAK,CAAC,eAAe,gBAAgB,CAAC,UAAU,wBAAwB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAClG;gBAED,4EAA4E;gBAC5E,+DAA+D;gBAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAEtD,8EAA8E;gBAC9E,gFAAgF;gBAChF,SAAS;aACV;YAED,6EAA6E;YAC7E,4EAA4E;YAC5E,8EAA8E;YAC9E,KAAI,MAAM,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;gBAC9D,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,WAAmC,CAAC,CAAC;aAC5G;SACF;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,OAAsB,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAsB;QACjH,8EAA8E;QAC9E,oEAAoE;QACpE,IAAG,YAAY,KAAK,OAAO,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\r\n\r\n /** Shorthand property to the enumerations editor. */\r\n private get _editor() {\r\n return this.context.editor.enumerations;\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\r\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\r\n // In case the enumerator entry does not exist in the target enumeration the\r\n // enumeratorMissing property is set and\r\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\r\n\r\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\r\n if (enumerator === undefined) {\r\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\r\n }\r\n\r\n // Enumerators are plain javascript objects with out any references to other\r\n // instances or a schema. That allows to simply copy them over.\r\n await this._editor.addEnumerator(itemKey, enumerator);\r\n\r\n // Since every missing enumerator has delta changes for ech property, the loop\r\n // must call continue here to avoid having all properties checked and set again.\r\n continue;\r\n }\r\n\r\n // For changes where the enumerators differ, the enumeratorDeltas property is\r\n // filled. This allows to change individual enumerator entries. This is only\r\n // allowed for labels and descriptions, all other deltas would throw an error.\r\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\r\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\r\n }\r\n }\r\n }\r\n\r\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\r\n // In case an enumerator has the same name but different value, the enumerator\r\n // cannot be merged to keep integrity for the existing schema users.\r\n if(propertyName === \"value\") {\r\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\r\n }\r\n\r\n // For the other two properties they shall only be merged if the source value is\r\n // set. In case they'd be undefined, the current enumerators value shall be kept.\r\n if(propertyName === \"label\" && value !== undefined) {\r\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\r\n }\r\n if(propertyName === \"description\" && value !== undefined) {\r\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAgF;AAKhF;;;GAGG;AACU,QAAA,iBAAiB,GAAmD;IAC/E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AAM,CAAC,IAAI,yBAAyB,EAAE,CAAC;SACpH;QAED,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE;YAC9C,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SACjH;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACrG;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { primitiveTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport type { EnumerationDifference, EnumeratorDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaItemMergerHandler } from \"./SchemaItemMerger\";\r\nimport type { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\r\n\r\n/**\r\n * Defines a merge handler to merge Enumeration schema items.\r\n * @internal\r\n */\r\nexport const enumerationMerger: SchemaItemMergerHandler<EnumerationDifference> = {\r\n async add(context, change: EnumerationDifference) {\r\n if (change.difference.type === undefined) {\r\n return { errorMessage: \"Enumerations must define a type property\" };\r\n }\r\n if (change.difference.isStrict === undefined) {\r\n return { errorMessage: \"Enumerations must define whether enumeration is strict.\" };\r\n }\r\n if (change.difference.enumerators === undefined) {\r\n return { errorMessage: \"Enumerations must define at least ine enumerator.\" };\r\n }\r\n\r\n return context.editor.enumerations.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n type: change.difference.type,\r\n isStrict: change.difference.isStrict,\r\n enumerators: change.difference.enumerators,\r\n });\r\n },\r\n async modify(_context, change, itemKey, item: MutableEnumeration) {\r\n if(change.difference.type !== undefined) {\r\n return { errorMessage: `The Enumeration ${itemKey.name} has an incompatible type. It must be \"${primitiveTypeToString(item.type!)}\", not \"${change.difference.type}\".` };\r\n }\r\n if(change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n if(change.difference.isStrict !== undefined) {\r\n item.setIsStrict(change.difference.isStrict);\r\n }\r\n return { itemKey};\r\n },\r\n};\r\n\r\n/**\r\n * Defines a merge handler to merge Enumeration schema items.\r\n * @internal\r\n */\r\nexport const enumeratorMerger: SchemaItemMergerHandler<EnumeratorDifference> = {\r\n async add(context, change) {\r\n if (change.difference.name === undefined) {\r\n return { errorMessage: \"Enumerators must define a name\" };\r\n }\r\n if (change.difference.value === undefined) {\r\n return { errorMessage: \"Enumerators must define a value\" };\r\n }\r\n\r\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n await context.editor.enumerations.addEnumerator(itemKey, {\r\n name: change.difference.name,\r\n value: change.difference.value,\r\n label: change.difference.label,\r\n description: change.difference.description,\r\n });\r\n\r\n return { itemKey };\r\n },\r\n async modify(context, change, itemKey) {\r\n if(change.difference.value !== undefined) {\r\n return { errorMessage: `Failed to merge enumerator attribute, Enumerator \"${change.path}\" has different values.` };\r\n }\r\n\r\n if(change.difference.description !== undefined) {\r\n await context.editor.enumerations.setEnumeratorDescription(itemKey, change.path, change.difference.description);\r\n }\r\n if(change.difference.label !== undefined) {\r\n await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);\r\n }\r\n return { itemKey };\r\n },\r\n};\r\n"]}
@@ -1,15 +1,8 @@
1
- import { KindOfQuantity, SchemaItemKey } from "@itwin/ecschema-metadata";
2
- import { PropertyValueResolver, SchemaItemMerger } from "./SchemaItemMerger";
3
- import { KindOfQuantityChanges } from "../Validation/SchemaChanges";
1
+ import { type KindOfQuantityDifference } from "../Differencing/SchemaDifference";
2
+ import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
4
3
  /**
4
+ * Defines a merge handler to merge KindOfQuantity schema items.
5
5
  * @internal
6
6
  */
7
- export default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {
8
- protected merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges): Promise<void>;
9
- /**
10
- *
11
- * Creates the property value resolver for [[KindOfQuantity]] items.
12
- */
13
- protected createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>>;
14
- }
7
+ export declare const kindOfQuantityMerger: SchemaItemMergerHandler<KindOfQuantityDifference>;
15
8
  //# sourceMappingURL=KindOfQuantityMerger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,cAAc,EAA8B,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AACjI,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,gBAAgB,CAAC,cAAc,CAAC;cAEvD,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB;IAmC7G;;;OAGG;cACsB,2BAA2B,IAAI,OAAO,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;CAcvG"}
1
+ {"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,KAAK,uBAAuB,EAA4B,MAAM,oBAAoB,CAAC;AAI5F;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,uBAAuB,CAAC,wBAAwB,CA4ClF,CAAC"}
@@ -1,66 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
- * See LICENSE.md in the project root for license terms and full copyright notice.
6
- *--------------------------------------------------------------------------------------------*/
7
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
3
+ exports.kindOfQuantityMerger = void 0;
8
4
  const SchemaItemMerger_1 = require("./SchemaItemMerger");
9
5
  /**
6
+ * Defines a merge handler to merge KindOfQuantity schema items.
10
7
  * @internal
11
8
  */
12
- class KindOfQuantityMerger extends SchemaItemMerger_1.SchemaItemMerger {
13
- async merge(itemKey, source, changes) {
14
- for (const presentationUnitChange of changes.presentationUnitChanges.values()) {
15
- for (const change of presentationUnitChange.presentationUnitChange) {
16
- const format = change.diagnostic.messageArgs[0];
17
- const isDefault = source.defaultPresentationFormat === format;
18
- if (ecschema_metadata_1.OverrideFormat.isOverrideFormat(format)) {
19
- const parentFormat = await this.lookup(format.parent);
20
- if (parentFormat === undefined) {
21
- throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);
22
- }
23
- const unitAndLabels = [];
24
- if (format.units !== undefined) {
25
- for (const [unit, label] of format.units) {
26
- const targetUnit = await this.lookup(unit);
27
- if (targetUnit === undefined) {
28
- throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);
29
- }
30
- unitAndLabels.push([targetUnit, label]);
31
- }
32
- }
33
- const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);
34
- await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);
35
- }
36
- else {
37
- const targetFormat = await this.lookup(format);
38
- if (targetFormat === undefined) {
39
- throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);
40
- }
41
- await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);
9
+ exports.kindOfQuantityMerger = {
10
+ async add(context, change) {
11
+ if (change.difference.persistenceUnit === undefined) {
12
+ return { errorMessage: "KindOfQuantity must define persistenceUnit" };
13
+ }
14
+ if (change.difference.relativeError === undefined) {
15
+ return { errorMessage: "KindOfQuantity must define relativeError" };
16
+ }
17
+ change.difference.persistenceUnit = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, change.difference.persistenceUnit);
18
+ if (change.difference.presentationUnits) {
19
+ if (Array.isArray(change.difference.presentationUnits)) {
20
+ for (let index = 0; index < change.difference.presentationUnits.length; index++) {
21
+ change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);
42
22
  }
43
23
  }
24
+ else {
25
+ change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);
26
+ }
27
+ }
28
+ return context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {
29
+ ...change.difference,
30
+ name: change.itemName,
31
+ schemaItemType: change.schemaType,
32
+ persistenceUnit: change.difference.persistenceUnit,
33
+ presentationUnits: change.difference.presentationUnits,
34
+ relativeError: change.difference.relativeError,
35
+ });
36
+ },
37
+ async modify(_context, change, itemKey, item) {
38
+ if (change.difference.label !== undefined) {
39
+ item.setDisplayLabel(change.difference.label);
44
40
  }
41
+ if (change.difference.description !== undefined) {
42
+ item.setDescription(change.difference.description);
43
+ }
44
+ if (change.difference.relativeError !== undefined) {
45
+ item.setRelativeError(change.difference.relativeError);
46
+ }
47
+ if (change.difference.persistenceUnit !== undefined) {
48
+ // TODO: It should be checked if the unit is the same, but referring to the source schema.
49
+ throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);
50
+ }
51
+ return { itemKey };
52
+ },
53
+ };
54
+ async function updateOverrideFormat(context, formatString) {
55
+ // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string
56
+ const match = formatString.match(/^([^(]+)\((\d+)\)\[(.*)\]$/);
57
+ if (match === null) {
58
+ return formatString;
45
59
  }
46
- /**
47
- *
48
- * Creates the property value resolver for [[KindOfQuantity]] items.
49
- */
50
- async createPropertyValueResolver() {
51
- return {
52
- persistenceUnit: (newValue, targetItemKey, oldValue) => {
53
- if (oldValue !== undefined && oldValue !== newValue) {
54
- throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);
55
- }
56
- const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(newValue);
57
- if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {
58
- return `${targetItemKey.schemaName}.${itemName}`;
59
- }
60
- return newValue;
61
- },
62
- };
60
+ const originalFormat = match[1];
61
+ const updatedFormat = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, originalFormat);
62
+ const unitOverrides = match[3].split("][");
63
+ for (let index = 0; index < unitOverrides.length; index++) {
64
+ const [unit, label] = unitOverrides[index].split("|");
65
+ const updatedUnit = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, unit);
66
+ unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : ""}`;
63
67
  }
68
+ return `${updatedFormat}(${match[2]})[${unitOverrides.join("][")}]`;
64
69
  }
65
- exports.default = KindOfQuantityMerger;
66
70
  //# sourceMappingURL=KindOfQuantityMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiI;AACjI,yDAA6E;AAG7E;;GAEG;AACH,MAAqB,oBAAqB,SAAQ,mCAAgC;IAE7D,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAsB,EAAE,OAA8B;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M,CAAC,gBAAgB,CAAC,6BAA6B,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;iBAC9G;qBAAM;oBACL,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,CAAC;oBACvD,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAC3F;oBACD,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;iBACxG;aACF;SACF;IACH,CAAC;IAED;;;OAGG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE;gBACrD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,EAAE;oBACnD,MAAM,IAAI,KAAK,CAAC,kCAAkC,aAAa,CAAC,IAAI,qCAAqC,CAAC,CAAC;iBAC5G;gBACD,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACxE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;iBAClD;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,uCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Format, InvertedUnit, KindOfQuantity, OverrideFormat, SchemaItem, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\r\nimport { KindOfQuantityChanges } from \"../Validation/SchemaChanges\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class KindOfQuantityMerger extends SchemaItemMerger<KindOfQuantity> {\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: KindOfQuantity, changes: KindOfQuantityChanges) {\r\n for (const presentationUnitChange of changes.presentationUnitChanges.values()) {\r\n for (const change of presentationUnitChange.presentationUnitChange) {\r\n const format = change.diagnostic.messageArgs![0];\r\n const isDefault = source.defaultPresentationFormat === format;\r\n\r\n if (OverrideFormat.isOverrideFormat(format)) {\r\n const parentFormat = await this.lookup<Format>(format.parent);\r\n if (parentFormat === undefined) {\r\n throw new Error(`Unable to locate the format class ${format.parent.name} in the merged schema.`);\r\n }\r\n\r\n const unitAndLabels: Array<[Unit | InvertedUnit, string | undefined]> | undefined = [];\r\n if (format.units !== undefined) {\r\n for (const [unit, label] of format.units) {\r\n const targetUnit = await this.lookup<Unit | InvertedUnit>(unit);\r\n if (targetUnit === undefined) {\r\n throw new Error(`Unable to locate the unit class ${unit.name} in the merged schema.`);\r\n }\r\n unitAndLabels.push([targetUnit, label]);\r\n }\r\n }\r\n const overrideFormat = await this.context.editor.kindOfQuantities.createFormatOverride(itemKey, parentFormat.key, format.precision, unitAndLabels);\r\n await this.context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, overrideFormat, isDefault);\r\n } else {\r\n const targetFormat = await this.lookup<Format>(format);\r\n if (targetFormat === undefined) {\r\n throw new Error(`Unable to locate the format class ${format.name} in the merged schema.`);\r\n }\r\n await this.context.editor.kindOfQuantities.addPresentationFormat(itemKey, targetFormat.key, isDefault);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * Creates the property value resolver for [[KindOfQuantity]] items.\r\n */\r\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<KindOfQuantity>> {\r\n return {\r\n persistenceUnit: (newValue, targetItemKey, oldValue) => {\r\n if (oldValue !== undefined && oldValue !== newValue) {\r\n throw new Error(`Changing the kind of quantity '${targetItemKey.name}' persistenceUnit is not supported.`);\r\n }\r\n const [schemaName, itemName] = SchemaItem.parseFullName(newValue);\r\n if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\r\n return `${targetItemKey.schemaName}.${itemName}`;\r\n }\r\n return newValue;\r\n },\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;;AAKA,yDAA4F;AAI5F;;;GAGG;AACU,QAAA,oBAAoB,GAAsD;IACrF,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,OAAO,EAAE,YAAY,EAAE,4CAA4C,EAAE,CAAC;SACvE;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,aAAa,KAAK,SAAS,EAAE;YACjD,OAAO,EAAE,YAAY,EAAE,0CAA0C,EAAE,CAAC;SACrE;QACD,MAAM,CAAC,UAAU,CAAC,eAAe,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAC/G,IAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE;YACtC,IAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;gBACrD,KAAI,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;oBAC9E,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,MAA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D,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC;AAEF,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,YAAoB;IACnF,kEAAkE;IAClE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC/D,IAAG,KAAK,KAAK,IAAI,EAAE;QACjB,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,aAAa,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAE9E,MAAM,aAAa,GAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,KAAI,IAAI,KAAK,GAAC,CAAC,EAAE,KAAK,GAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACrD,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClE,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;KACpE;IAED,OAAO,GAAG,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,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\nimport { type KindOfQuantityDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName } from \"./SchemaItemMerger\";\r\nimport { type MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge KindOfQuantity schema items.\r\n * @internal\r\n */\r\nexport const kindOfQuantityMerger: SchemaItemMergerHandler<KindOfQuantityDifference> = {\r\n async add(context, change) {\r\n if (change.difference.persistenceUnit === undefined) {\r\n return { errorMessage: \"KindOfQuantity must define persistenceUnit\" };\r\n }\r\n if (change.difference.relativeError === undefined) {\r\n return { errorMessage: \"KindOfQuantity must define relativeError\" };\r\n }\r\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\r\n if(change.difference.presentationUnits) {\r\n if(Array.isArray(change.difference.presentationUnits)) {\r\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\r\n change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\r\n }\r\n } else {\r\n change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);\r\n }\r\n }\r\n\r\n return context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n persistenceUnit: change.difference.persistenceUnit,\r\n presentationUnits: change.difference.presentationUnits,\r\n relativeError: change.difference.relativeError,\r\n });\r\n },\r\n async modify(_context, change, itemKey, item: MutableKindOfQuantity) {\r\n if(change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n if(change.difference.relativeError !== undefined) {\r\n item.setRelativeError(change.difference.relativeError);\r\n }\r\n if(change.difference.persistenceUnit !== undefined) {\r\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\r\n throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);\r\n }\r\n return { itemKey };\r\n },\r\n};\r\n\r\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string) {\r\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\r\n const match = formatString.match(/^([^(]+)\\((\\d+)\\)\\[(.*)\\]$/);\r\n if(match === null) {\r\n return formatString;\r\n }\r\n\r\n const originalFormat = match[1];\r\n const updatedFormat = await updateSchemaItemFullName(context, originalFormat);\r\n\r\n const unitOverrides = match[3].split(\"][\");\r\n for(let index=0; index< unitOverrides.length; index++) {\r\n const [unit, label] = unitOverrides[index].split(\"|\");\r\n const updatedUnit = await updateSchemaItemFullName(context, unit);\r\n unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : \"\"}`;\r\n }\r\n\r\n return `${updatedFormat}(${match[2]})[${unitOverrides.join(\"][\")}]`;\r\n}\r\n"]}
@@ -1,11 +1,8 @@
1
- import { Mixin, SchemaKey } from "@itwin/ecschema-metadata";
2
- import { SchemaItemEditResults } from "../Editing/Editor";
3
- import { ClassMerger } from "./ClassMerger";
1
+ import { type MixinClassDifference } from "../Differencing/SchemaDifference";
2
+ import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
4
3
  /**
4
+ * Defines a merge handler to merge Mixin schema items.
5
5
  * @internal
6
6
  */
7
- export default class MixinMerger extends ClassMerger<Mixin> {
8
- protected create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults>;
9
- protected mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean>;
10
- }
7
+ export declare const mixinClassMerger: SchemaItemMergerHandler<MixinClassDifference>;
11
8
  //# sourceMappingURL=MixinMerger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAiB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,KAAK,CAAC;cAEhC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAW5E,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC;CAU1K"}
1
+ {"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,KAAK,uBAAuB,EAAiD,MAAM,oBAAoB,CAAC;AAIjH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CAsB1E,CAAC"}
@@ -1,34 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
- * See LICENSE.md in the project root for license terms and full copyright notice.
6
- *--------------------------------------------------------------------------------------------*/
7
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
3
+ exports.mixinClassMerger = void 0;
4
+ const SchemaItemMerger_1 = require("./SchemaItemMerger");
8
5
  const ClassMerger_1 = require("./ClassMerger");
9
6
  /**
7
+ * Defines a merge handler to merge Mixin schema items.
10
8
  * @internal
11
9
  */
12
- class MixinMerger extends ClassMerger_1.ClassMerger {
13
- async create(schemaKey, ecClass) {
14
- if (ecClass.appliesTo === undefined) {
15
- return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };
10
+ exports.mixinClassMerger = {
11
+ async add(context, change) {
12
+ if (change.difference.appliesTo === undefined) {
13
+ return { errorMessage: "Mixin must define appliesTo" };
16
14
  }
17
- const appliesTo = new ecschema_metadata_1.SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)
18
- ? this.context.targetSchema.schemaKey
19
- : ecClass.appliesTo.schemaKey);
20
- return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);
21
- }
22
- async mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue) {
23
- switch (attributeName) {
24
- case "appliesTo":
25
- if (attributeOldValue !== undefined) {
26
- return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };
27
- }
28
- return true;
15
+ return context.editor.mixins.createFromProps(context.targetSchemaKey, {
16
+ ...change.difference,
17
+ name: change.itemName,
18
+ schemaItemType: change.schemaType,
19
+ appliesTo: await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, change.difference.appliesTo),
20
+ });
21
+ },
22
+ async modify(context, change, itemKey, item) {
23
+ if (change.difference.appliesTo !== undefined) {
24
+ const appliesTo = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, change.difference.appliesTo);
25
+ const currentValue = await item.appliesTo;
26
+ if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {
27
+ return { errorMessage: `Changing the mixin '${itemKey.name}' appliesTo is not supported.` };
28
+ }
29
29
  }
30
- return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
31
- }
32
- }
33
- exports.default = MixinMerger;
30
+ return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
31
+ },
32
+ };
34
33
  //# sourceMappingURL=MixinMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA2E;AAE3E,+CAA4C;AAE5C;;GAEG;AACH,MAAqB,WAAY,SAAQ,yBAAkB;IAEtC,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAc;QAClE,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;YACnC,OAAO,EAAE,YAAY,EAAE,aAAa,OAAO,CAAC,QAAQ,iDAAiD,EAAE,CAAC;SACzG;QAED,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC;YAClI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAEkB,KAAK,CAAC,eAAe,CAAC,OAAc,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QAC5H,QAAO,aAAa,EAAE;YACpB,KAAK,WAAW;gBACd,IAAI,iBAAiB,KAAK,SAAS,EAAE;oBACnC,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;iBAC7F;gBACD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,CAAC;CACF;AAvBD,8BAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { ClassMerger } from \"./ClassMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class MixinMerger extends ClassMerger<Mixin> {\r\n\r\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\r\n if (ecClass.appliesTo === undefined) {\r\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\r\n }\r\n\r\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : ecClass.appliesTo.schemaKey);\r\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\r\n }\r\n\r\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\r\n switch(attributeName) {\r\n case \"appliesTo\":\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\r\n }\r\n return true;\r\n }\r\n return super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAiH;AAEjH,+CAA4C;AAE5C;;;GAGG;AACU,QAAA,gBAAgB,GAAkD;IAC7E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE;YAC7C,OAAO,EAAE,YAAY,EAAE,6BAA6B,EAAE,CAAC;SACxD;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACpE,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,SAAS,EAAE,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;SAChF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAkB;QACvD,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE;YAC5C,MAAM,SAAS,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YAClF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC;YAC1C,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;gBACtE,OAAO,EAAE,YAAY,EAAE,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,EAAE,CAAC;aAC7F;SACF;QACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type MixinClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { type MutableMixin } from \"../Editing/Mutable/MutableMixin\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge Mixin schema items.\r\n * @internal\r\n */\r\nexport const mixinClassMerger: SchemaItemMergerHandler<MixinClassDifference> = {\r\n async add(context, change) {\r\n if (change.difference.appliesTo === undefined) {\r\n return { errorMessage: \"Mixin must define appliesTo\" };\r\n }\r\n return context.editor.mixins.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: await updateSchemaItemFullName(context, change.difference.appliesTo),\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableMixin) {\r\n if(change.difference.appliesTo !== undefined) {\r\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\r\n const currentValue = await item.appliesTo;\r\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\r\n return { errorMessage: `Changing the mixin '${itemKey.name}' appliesTo is not supported.` };\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n },\r\n};\r\n\r\n"]}
@@ -0,0 +1,8 @@
1
+ import { type PhenomenonDifference } from "../Differencing/SchemaDifference";
2
+ import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
3
+ /**
4
+ * Defines a merge handler to merge Phenomenon schema items.
5
+ * @internal
6
+ */
7
+ export declare const phenomenonMerger: SchemaItemMergerHandler<PhenomenonDifference>;
8
+ //# sourceMappingURL=PhenomenonMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,KAAK,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAGjE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CA6B1E,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.phenomenonMerger = void 0;
4
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
5
+ /**
6
+ * Defines a merge handler to merge Phenomenon schema items.
7
+ * @internal
8
+ */
9
+ exports.phenomenonMerger = {
10
+ add: async (context, change) => {
11
+ if (change.difference.definition === undefined) {
12
+ return { errorMessage: "Phenomenon must define definition" };
13
+ }
14
+ return context.editor.phenomenons.createFromProps(context.targetSchemaKey, {
15
+ ...change.difference,
16
+ name: change.itemName,
17
+ schemaItemType: change.schemaType,
18
+ definition: change.difference.definition,
19
+ });
20
+ },
21
+ modify: async (_context, change, itemKey, phenomenon) => {
22
+ if (change.difference.label !== undefined) {
23
+ phenomenon.setDisplayLabel(change.difference.label);
24
+ }
25
+ if (change.difference.description !== undefined) {
26
+ phenomenon.setDescription(change.difference.description);
27
+ }
28
+ if (change.difference.definition !== undefined) {
29
+ // It would be better if the validation would be part of phenomenon.setDefinition.
30
+ if (phenomenon.definition !== "" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())
31
+ throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);
32
+ await phenomenon.setDefinition(change.difference.definition);
33
+ }
34
+ return { itemKey };
35
+ },
36
+ };
37
+ //# sourceMappingURL=PhenomenonMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":";;;AAOA,gEAA2E;AAE3E;;;GAGG;AACU,QAAA,gBAAgB,GAAkD;IAC7E,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7B,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE;YAC9C,OAAO,EAAE,YAAY,EAAE,mCAAmC,EAAE,CAAC;SAC9D;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACzE,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU;SACzC,CAAC,CAAC;IACL,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAA6B,EAAE,EAAE;QACzE,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACxC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACrD;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE;YAC9C,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SAC1D;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,EAAE;YAC7C,kFAAkF;YAClF,IAAI,UAAU,CAAC,UAAU,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;gBACpH,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,kBAAkB,OAAO,CAAC,IAAI,yCAAyC,CAAC,CAAC;YAEnI,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type PhenomenonDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\r\nimport { type SchemaItemMergerHandler} from \"./SchemaItemMerger\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Defines a merge handler to merge Phenomenon schema items.\r\n * @internal\r\n */\r\nexport const phenomenonMerger: SchemaItemMergerHandler<PhenomenonDifference> = {\r\n add: async (context, change) => {\r\n if (change.difference.definition === undefined) {\r\n return { errorMessage: \"Phenomenon must define definition\" };\r\n }\r\n\r\n return context.editor.phenomenons.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n definition: change.difference.definition,\r\n });\r\n },\r\n modify: async (_context, change, itemKey, phenomenon: MutablePhenomenon) => {\r\n if(change.difference.label !== undefined) {\r\n phenomenon.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n phenomenon.setDescription(change.difference.description);\r\n }\r\n if(change.difference.definition !== undefined) {\r\n // It would be better if the validation would be part of phenomenon.setDefinition.\r\n if (phenomenon.definition !== \"\" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);\r\n\r\n await phenomenon.setDefinition(change.difference.definition);\r\n }\r\n return { itemKey };\r\n },\r\n};\r\n"]}
@@ -0,0 +1,8 @@
1
+ import { type PropertyCategoryDifference } from "../Differencing/SchemaDifference";
2
+ import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
3
+ /**
4
+ * Defines a merge handler to merge PropertyCategory schema items.
5
+ * @internal
6
+ */
7
+ export declare const propertyCategoryMerger: SchemaItemMergerHandler<PropertyCategoryDifference>;
8
+ //# sourceMappingURL=PropertyCategoryMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,uBAAuB,CAAC,0BAA0B,CA0BtF,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyCategoryMerger = void 0;
4
+ /**
5
+ * Defines a merge handler to merge PropertyCategory schema items.
6
+ * @internal
7
+ */
8
+ exports.propertyCategoryMerger = {
9
+ async add(context, change) {
10
+ if (change.difference.priority === undefined) {
11
+ return { errorMessage: "PropertyCategory must define priority" };
12
+ }
13
+ return context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {
14
+ ...change.difference,
15
+ name: change.itemName,
16
+ schemaItemType: change.schemaType,
17
+ priority: change.difference.priority,
18
+ });
19
+ },
20
+ async modify(context, change, itemKey, item) {
21
+ if (change.difference.label !== undefined) {
22
+ item.setDisplayLabel(change.difference.label);
23
+ }
24
+ if (change.difference.description !== undefined) {
25
+ item.setDescription(change.difference.description);
26
+ }
27
+ if (change.difference.priority !== undefined) {
28
+ // TODO: inconsistency: setPriority does not return a result whether the priority was set successfully.
29
+ await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);
30
+ }
31
+ return { itemKey };
32
+ },
33
+ };
34
+ //# sourceMappingURL=PropertyCategoryMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACU,QAAA,sBAAsB,GAAwD;IACzF,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC5C,OAAO,EAAE,YAAY,EAAE,uCAAuC,EAAE,CAAC;SAClE;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YAChF,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;SACrC,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAA6B;QAClE,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YACxC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SAC/C;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE;YAC9C,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SACpD;QACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC3C,uGAAuG;YACvG,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SAC1F;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type MutablePropertyCategory } from \"../Editing/Mutable/MutablePropertyCategory\";\r\nimport { type PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge PropertyCategory schema items.\r\n * @internal\r\n */\r\nexport const propertyCategoryMerger: SchemaItemMergerHandler<PropertyCategoryDifference> = {\r\n async add(context, change) {\r\n if (change.difference.priority === undefined) {\r\n return { errorMessage: \"PropertyCategory must define priority\" };\r\n }\r\n\r\n return context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n priority: change.difference.priority,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutablePropertyCategory) {\r\n if(change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n if(change.difference.priority !== undefined) {\r\n // TODO: inconsistency: setPriority does not return a result whether the priority was set successfully.\r\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\r\n }\r\n return { itemKey };\r\n },\r\n};\r\n"]}
@@ -1,21 +1,13 @@
1
- import { Property, SchemaItemKey } from "@itwin/ecschema-metadata";
2
- import { SchemaMergeContext } from "./SchemaMerger";
3
- import { PropertyEditResults } from "../Editing/Editor";
4
- import { PropertyValueChange } from "../Validation/SchemaChanges";
1
+ import type { SchemaEditResults } from "../ecschema-editing";
2
+ import type { SchemaMergeContext } from "./SchemaMerger";
3
+ import type { ClassItemDifference, ClassPropertyDifference } from "../Differencing/SchemaDifference";
4
+ import { SchemaItemKey } from "@itwin/ecschema-metadata";
5
5
  /**
6
- * Updates property with attribute value changes.
7
- * @param context The current merging context.
8
- * @param property The Property object to be changed.
9
- * @param propertyValueChanges The changes to be applied to the property.
10
6
  * @internal
11
7
  */
12
- export declare function mergePropertyAttributeValueChanges(context: SchemaMergeContext, property: Property, propertyValueChanges: PropertyValueChange[]): Promise<PropertyEditResults>;
8
+ export declare function mergePropertyDifference(context: SchemaMergeContext, change: ClassPropertyDifference): Promise<SchemaEditResults>;
13
9
  /**
14
- * Creates a Property through a PropertyProps.
15
- * @param context The current merging context.
16
- * @param classKey The SchemaItemKey of the class.
17
- * @param property The Property object to be cloned.
18
10
  * @internal
19
11
  */
20
- export declare function createPropertyFromProps(context: SchemaMergeContext, classKey: SchemaItemKey, property: Property): Promise<PropertyEditResults>;
12
+ export declare function mergeClassProperties(context: SchemaMergeContext, change: ClassItemDifference, itemKey: SchemaItemKey): Promise<SchemaEditResults>;
21
13
  //# sourceMappingURL=PropertyMerger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuI,QAAQ,EAAwF,aAAa,EAAkE,MAAM,0BAA0B,CAAC;AAC9V,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAkBlE;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAYnL;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsCpJ"}
1
+ {"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AACrH,OAAO,EAA8M,aAAa,EAAoD,MAAM,0BAA0B,CAAC;AAiBvT;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMtI;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQvJ"}