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

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 (156) 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/Constants.js.map +1 -1
  13. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  14. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  15. package/lib/cjs/Editing/Editor.js.map +1 -1
  16. package/lib/cjs/Editing/Entities.js.map +1 -1
  17. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  18. package/lib/cjs/Editing/Formats.js.map +1 -1
  19. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  20. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  21. package/lib/cjs/Editing/Mixins.js.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +1 -0
  26. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  28. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +1 -0
  30. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +2 -0
  35. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
  36. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +1 -0
  39. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts.map +1 -1
  40. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  41. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +1 -0
  44. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts.map +1 -1
  45. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  46. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  47. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +2 -0
  48. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +1 -0
  52. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  54. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  55. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  56. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  57. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  58. package/lib/cjs/Editing/Structs.js.map +1 -1
  59. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  60. package/lib/cjs/Editing/Units.js.map +1 -1
  61. package/lib/cjs/Merging/CAClassMerger.d.ts +4 -7
  62. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  63. package/lib/cjs/Merging/CAClassMerger.js +26 -23
  64. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  65. package/lib/cjs/Merging/ClassMerger.d.ts +10 -18
  66. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  67. package/lib/cjs/Merging/ClassMerger.js +148 -155
  68. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  69. package/lib/cjs/Merging/ConstantMerger.d.ts +4 -8
  70. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  71. package/lib/cjs/Merging/ConstantMerger.js +59 -40
  72. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  73. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +16 -13
  74. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  75. package/lib/cjs/Merging/CustomAttributeMerger.js +66 -34
  76. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  77. package/lib/cjs/Merging/EntityClassMerger.d.ts +10 -7
  78. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  79. package/lib/cjs/Merging/EntityClassMerger.js +41 -29
  80. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  81. package/lib/cjs/Merging/EnumerationMerger.d.ts +9 -9
  82. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  83. package/lib/cjs/Merging/EnumerationMerger.js +77 -48
  84. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  85. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +4 -11
  86. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  87. package/lib/cjs/Merging/KindOfQuantityMerger.js +57 -53
  88. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  89. package/lib/cjs/Merging/MixinMerger.d.ts +4 -7
  90. package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
  91. package/lib/cjs/Merging/MixinMerger.js +24 -25
  92. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  93. package/lib/cjs/Merging/PhenomenonMerger.d.ts +8 -0
  94. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -0
  95. package/lib/cjs/Merging/PhenomenonMerger.js +37 -0
  96. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -0
  97. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +8 -0
  98. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -0
  99. package/lib/cjs/Merging/PropertyCategoryMerger.js +34 -0
  100. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -0
  101. package/lib/cjs/Merging/PropertyMerger.d.ts +6 -14
  102. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  103. package/lib/cjs/Merging/PropertyMerger.js +212 -287
  104. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  105. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +16 -10
  106. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
  107. package/lib/cjs/Merging/RelationshipClassMerger.js +121 -112
  108. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  109. package/lib/cjs/Merging/SchemaItemMerger.d.ts +26 -51
  110. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  111. package/lib/cjs/Merging/SchemaItemMerger.js +106 -88
  112. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  113. package/lib/cjs/Merging/SchemaMerger.d.ts +21 -9
  114. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  115. package/lib/cjs/Merging/SchemaMerger.js +74 -88
  116. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  117. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +5 -5
  118. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
  119. package/lib/cjs/Merging/SchemaReferenceMerger.js +33 -15
  120. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  121. package/lib/cjs/Merging/UnitSystemMerger.d.ts +8 -0
  122. package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -0
  123. package/lib/cjs/Merging/UnitSystemMerger.js +26 -0
  124. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -0
  125. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  126. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  127. package/lib/cjs/Validation/ECRules.d.ts +23 -23
  128. package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
  129. package/lib/cjs/Validation/ECRules.js +1 -1
  130. package/lib/cjs/Validation/ECRules.js.map +1 -1
  131. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  132. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  133. package/lib/cjs/Validation/Rules.js.map +1 -1
  134. package/lib/cjs/Validation/SchemaChanges.js +1 -1
  135. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  136. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  137. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  138. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  139. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  140. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  141. package/lib/cjs/Validation/SchemaComparer.js +3 -3
  142. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  143. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  144. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  145. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  146. package/lib/cjs/ecschema-editing.js.map +1 -1
  147. package/package.json +9 -9
  148. package/public/locales/en/ECSchemaEditing.json +26 -26
  149. package/lib/cjs/Merging/SchemaItemFactory.d.ts +0 -15
  150. package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +0 -1
  151. package/lib/cjs/Merging/SchemaItemFactory.js +0 -82
  152. package/lib/cjs/Merging/SchemaItemFactory.js.map +0 -1
  153. package/lib/cjs/Merging/StructClassMerger.d.ts +0 -10
  154. package/lib/cjs/Merging/StructClassMerger.d.ts.map +0 -1
  155. package/lib/cjs/Merging/StructClassMerger.js +0 -13
  156. package/lib/cjs/Merging/StructClassMerger.js.map +0 -1
@@ -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;QAC3G,KAAK,MAAM,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC,MAAM,EAAE,EAAE;YAC7E,KAAK,MAAM,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,EAAE;gBAClE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,WAAY,CAAC,CAAC,CAAC,CAAC;gBACjD,MAAM,SAAS,GAAG,MAAM,CAAC,yBAAyB,KAAK,MAAM,CAAC;gBAE9D,IAAI,kCAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;oBAC3C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAS,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC9D,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,MAAM,CAAC,IAAI,wBAAwB,CAAC,CAAC;qBAClG;oBAED,MAAM,aAAa,GAAiE,EAAE,CAAC;oBACvF,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;wBAC9B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE;4BACxC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAsB,IAAI,CAAC,CAAC;4BAChE,IAAI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ClE,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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AAK,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":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { type KindOfQuantityDifference } from \"../Differencing/SchemaDifference\";\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName } from \"./SchemaItemMerger\";\nimport { type MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\n/**\n * Defines a merge handler to merge KindOfQuantity schema items.\n * @internal\n */\nexport const kindOfQuantityMerger: SchemaItemMergerHandler<KindOfQuantityDifference> = {\n async add(context, change) {\n if (change.difference.persistenceUnit === undefined) {\n return { errorMessage: \"KindOfQuantity must define persistenceUnit\" };\n }\n if (change.difference.relativeError === undefined) {\n return { errorMessage: \"KindOfQuantity must define relativeError\" };\n }\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\n if(change.difference.presentationUnits) {\n if(Array.isArray(change.difference.presentationUnits)) {\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\n change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\n }\n } else {\n change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);\n }\n }\n\n return context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n persistenceUnit: change.difference.persistenceUnit,\n presentationUnits: change.difference.presentationUnits,\n relativeError: change.difference.relativeError,\n });\n },\n async modify(_context, change, itemKey, item: MutableKindOfQuantity) {\n if(change.difference.label !== undefined) {\n item.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n item.setDescription(change.difference.description);\n }\n if(change.difference.relativeError !== undefined) {\n item.setRelativeError(change.difference.relativeError);\n }\n if(change.difference.persistenceUnit !== undefined) {\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\n throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);\n }\n return { itemKey };\n },\n};\n\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string) {\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\n const match = formatString.match(/^([^(]+)\\((\\d+)\\)\\[(.*)\\]$/);\n if(match === null) {\n return formatString;\n }\n\n const originalFormat = match[1];\n const updatedFormat = await updateSchemaItemFullName(context, originalFormat);\n\n const unitOverrides = match[3].split(\"][\");\n for(let index=0; index< unitOverrides.length; index++) {\n const [unit, label] = unitOverrides[index].split(\"|\");\n const updatedUnit = await updateSchemaItemFullName(context, unit);\n unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : \"\"}`;\n }\n\n return `${updatedFormat}(${match[2]})[${unitOverrides.join(\"][\")}]`;\n}\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":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { type MixinClassDifference } from \"../Differencing/SchemaDifference\";\nimport { type SchemaItemMergerHandler, updateSchemaItemFullName, updateSchemaItemKey } from \"./SchemaItemMerger\";\nimport { type MutableMixin } from \"../Editing/Mutable/MutableMixin\";\nimport { modifyClass } from \"./ClassMerger\";\n\n/**\n * Defines a merge handler to merge Mixin schema items.\n * @internal\n */\nexport const mixinClassMerger: SchemaItemMergerHandler<MixinClassDifference> = {\n async add(context, change) {\n if (change.difference.appliesTo === undefined) {\n return { errorMessage: \"Mixin must define appliesTo\" };\n }\n return context.editor.mixins.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n appliesTo: await updateSchemaItemFullName(context, change.difference.appliesTo),\n });\n },\n async modify(context, change, itemKey, item: MutableMixin) {\n if(change.difference.appliesTo !== undefined) {\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\n const currentValue = await item.appliesTo;\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\n return { errorMessage: `Changing the mixin '${itemKey.name}' appliesTo is not supported.` };\n }\n }\n return modifyClass(context, change, itemKey, item);\n },\n};\n\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":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { type PhenomenonDifference } from \"../Differencing/SchemaDifference\";\nimport { type MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\nimport { type SchemaItemMergerHandler} from \"./SchemaItemMerger\";\nimport { ECObjectsError, ECObjectsStatus } from \"@itwin/ecschema-metadata\";\n\n/**\n * Defines a merge handler to merge Phenomenon schema items.\n * @internal\n */\nexport const phenomenonMerger: SchemaItemMergerHandler<PhenomenonDifference> = {\n add: async (context, change) => {\n if (change.difference.definition === undefined) {\n return { errorMessage: \"Phenomenon must define definition\" };\n }\n\n return context.editor.phenomenons.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n definition: change.difference.definition,\n });\n },\n modify: async (_context, change, itemKey, phenomenon: MutablePhenomenon) => {\n if(change.difference.label !== undefined) {\n phenomenon.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n phenomenon.setDescription(change.difference.description);\n }\n if(change.difference.definition !== undefined) {\n // It would be better if the validation would be part of phenomenon.setDefinition.\n if (phenomenon.definition !== \"\" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);\n\n await phenomenon.setDefinition(change.difference.definition);\n }\n return { itemKey };\n },\n};\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":["/*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport { type MutablePropertyCategory } from \"../Editing/Mutable/MutablePropertyCategory\";\nimport { type PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\nimport { type SchemaItemMergerHandler } from \"./SchemaItemMerger\";\n\n/**\n * Defines a merge handler to merge PropertyCategory schema items.\n * @internal\n */\nexport const propertyCategoryMerger: SchemaItemMergerHandler<PropertyCategoryDifference> = {\n async add(context, change) {\n if (change.difference.priority === undefined) {\n return { errorMessage: \"PropertyCategory must define priority\" };\n }\n\n return context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n priority: change.difference.priority,\n });\n },\n async modify(context, change, itemKey, item: MutablePropertyCategory) {\n if(change.difference.label !== undefined) {\n item.setDisplayLabel(change.difference.label);\n }\n if(change.difference.description !== undefined) {\n item.setDescription(change.difference.description);\n }\n if(change.difference.priority !== undefined) {\n // TODO: inconsistency: setPriority does not return a result whether the priority was set successfully.\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\n }\n return { itemKey };\n },\n};\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"}