@itwin/ecschema-editing 4.2.0-dev.9 → 4.3.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Editing/Constants.js.map +1 -1
  3. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  4. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  5. package/lib/cjs/Editing/Editor.js.map +1 -1
  6. package/lib/cjs/Editing/Entities.js.map +1 -1
  7. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  8. package/lib/cjs/Editing/Formats.js.map +1 -1
  9. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  10. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  11. package/lib/cjs/Editing/Mixins.js.map +1 -1
  12. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  13. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  14. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  15. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  16. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  17. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  18. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  19. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  20. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  21. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  28. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  29. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  30. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  31. package/lib/cjs/Editing/Structs.js.map +1 -1
  32. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  33. package/lib/cjs/Editing/Units.js.map +1 -1
  34. package/lib/cjs/Merging/CAClassMerger.d.ts +7 -0
  35. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -0
  36. package/lib/cjs/Merging/CAClassMerger.js +28 -0
  37. package/lib/cjs/Merging/CAClassMerger.js.map +1 -0
  38. package/lib/cjs/Merging/ClassMerger.d.ts +7 -0
  39. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -0
  40. package/lib/cjs/Merging/ClassMerger.js +59 -0
  41. package/lib/cjs/Merging/ClassMerger.js.map +1 -0
  42. package/lib/cjs/Merging/ConstantMerger.d.ts +12 -0
  43. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -0
  44. package/lib/cjs/Merging/ConstantMerger.js +56 -0
  45. package/lib/cjs/Merging/ConstantMerger.js.map +1 -0
  46. package/lib/cjs/Merging/EnumerationMerger.d.ts +12 -0
  47. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -0
  48. package/lib/cjs/Merging/EnumerationMerger.js +83 -0
  49. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -0
  50. package/lib/cjs/Merging/PhenomenonMerger.d.ts +7 -0
  51. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -0
  52. package/lib/cjs/Merging/PhenomenonMerger.js +16 -0
  53. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -0
  54. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +7 -0
  55. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -0
  56. package/lib/cjs/Merging/PropertyCategoryMerger.js +16 -0
  57. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -0
  58. package/lib/cjs/Merging/SchemaItemFactory.d.ts +8 -0
  59. package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +1 -0
  60. package/lib/cjs/Merging/SchemaItemFactory.js +38 -0
  61. package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -0
  62. package/lib/cjs/Merging/SchemaItemMerger.d.ts +31 -0
  63. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -0
  64. package/lib/cjs/Merging/SchemaItemMerger.js +90 -0
  65. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -0
  66. package/lib/cjs/Merging/SchemaMerger.d.ts +36 -0
  67. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -0
  68. package/lib/cjs/Merging/SchemaMerger.js +94 -0
  69. package/lib/cjs/Merging/SchemaMerger.js.map +1 -0
  70. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +10 -0
  71. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -0
  72. package/lib/cjs/Merging/SchemaReferenceMerger.js +55 -0
  73. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -0
  74. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  75. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  76. package/lib/cjs/Validation/ECRules.js.map +1 -1
  77. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  78. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  79. package/lib/cjs/Validation/Rules.js.map +1 -1
  80. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  81. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  82. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  83. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  84. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +4 -2
  85. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
  86. package/lib/cjs/Validation/SchemaCompareVisitor.js +23 -19
  87. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  88. package/lib/cjs/Validation/SchemaComparer.d.ts +9 -1
  89. package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
  90. package/lib/cjs/Validation/SchemaComparer.js +4 -3
  91. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  92. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  93. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  94. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  95. package/lib/cjs/ecschema-editing.d.ts +5 -0
  96. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  97. package/lib/cjs/ecschema-editing.js +7 -1
  98. package/lib/cjs/ecschema-editing.js.map +1 -1
  99. package/package.json +10 -10
  100. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -0,0 +1,12 @@
1
+ import { Constant } from "@itwin/ecschema-metadata";
2
+ import { SchemaItemChanges } from "../Validation/SchemaChanges";
3
+ /**
4
+ * @internal
5
+ * @param target The constant the differences get merged into
6
+ * @param source The constant to compare
7
+ * @param changes Gets the @see SchemaItemChanges between the two constants.
8
+ * For example, if source constant has an attribute/property that it missing in
9
+ * target one, it would be listed in propertyValueChanges.
10
+ */
11
+ export default function mergeConstant(target: Constant, source: Constant, changes: SchemaItemChanges): Promise<void>;
12
+ //# sourceMappingURL=ConstantMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConstantMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAA4E,MAAM,0BAA0B,CAAC;AAC9H,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE;;;;;;;GAOG;AACH,wBAA8B,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,iBAuCzG"}
@@ -0,0 +1,56 @@
1
+ "use strict";
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");
8
+ const SchemaItemMerger_1 = require("./SchemaItemMerger");
9
+ /**
10
+ * @internal
11
+ * @param target The constant the differences get merged into
12
+ * @param source The constant to compare
13
+ * @param changes Gets the @see SchemaItemChanges between the two constants.
14
+ * For example, if source constant has an attribute/property that it missing in
15
+ * target one, it would be listed in propertyValueChanges.
16
+ */
17
+ async function mergeConstant(target, source, changes) {
18
+ const mutableConstant = target;
19
+ // Get referenced higher level phenomenon
20
+ const [refSchema, itemName] = await (0, SchemaItemMerger_1.getItemNameAndSchemaRef)(source, source.phenomenon.fullName);
21
+ await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutableConstant, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
22
+ switch (propertyName) {
23
+ case "definition": {
24
+ if (item.definition === "")
25
+ return item.setDefinition(propertyValue);
26
+ throw Error(`Failed to merged, constant definition conflict: ${propertyValue} -> ${item.definition}`);
27
+ }
28
+ case "numerator": {
29
+ if (!item.hasNumerator)
30
+ return item.setNumerator(propertyValue);
31
+ throw Error(`Failed to merged, constant numerator conflict: ${propertyValue} -> ${item.numerator}`);
32
+ }
33
+ case "denominator": {
34
+ if (!item.hasDenominator)
35
+ return item.setDenominator(propertyValue);
36
+ throw Error(`Failed to merged, constant denominator conflict: ${propertyValue} -> ${item.denominator}`);
37
+ }
38
+ case "phenomenon": {
39
+ if (item.phenomenon === undefined) {
40
+ // A lazy loaded phenomenon with the correct reference schema is needed, if reference schema is undefined then item schema.
41
+ const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, refSchema ? refSchema.schemaKey : target.schema.schemaKey);
42
+ const lazyTargetPhenomenon = new ecschema_metadata_1.DelayedPromiseWithProps(schemaItemKey, async () => {
43
+ const phenomenon = (await target.schema.context.getSchemaItem(schemaItemKey));
44
+ // At this point, higher level phenomenon item should not be undefined
45
+ if (phenomenon === undefined)
46
+ throw Error(`Unable to locate phenomenon item in schema ${schemaItemKey.schemaName}`);
47
+ return phenomenon;
48
+ });
49
+ return item.setPhenomenon(lazyTargetPhenomenon);
50
+ }
51
+ }
52
+ }
53
+ });
54
+ }
55
+ exports.default = mergeConstant;
56
+ //# sourceMappingURL=ConstantMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8H;AAE9H,yDAAwF;AAGxF;;;;;;;GAOG;AACY,KAAK,UAAU,aAAa,CAAC,MAAgB,EAAE,MAAgB,EAAE,OAA0B;IACxG,MAAM,eAAe,GAAG,MAAyB,CAAC;IAElD,yCAAyC;IACzC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,MAAM,IAAA,0CAAuB,EAAC,MAAM,EAAE,MAAM,CAAC,UAAW,CAAC,QAAQ,CAAC,CAAC;IAEjG,MAAM,IAAA,4CAAyB,EAAC,eAAe,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QACnH,QAAQ,YAAY,EAAE;YACpB,KAAK,YAAY,CAAC,CAAC;gBACjB,IAAI,IAAI,CAAC,UAAU,KAAK,EAAE;oBACxB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;gBAC3C,MAAM,KAAK,CAAC,mDAAmD,aAAa,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;aACvG;YACD,KAAK,WAAW,CAAC,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,YAAY;oBACpB,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;gBAC1C,MAAM,KAAK,CAAC,kDAAkD,aAAa,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;aACrG;YACD,KAAK,aAAa,CAAC,CAAC;gBAClB,IAAI,CAAC,IAAI,CAAC,cAAc;oBACtB,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;gBAC5C,MAAM,KAAK,CAAC,oDAAoD,aAAa,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;aACzG;YACD,KAAK,YAAY,CAAC,CAAC;gBACjB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;oBACjC,2HAA2H;oBAC3H,MAAM,aAAa,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;oBAC7G,MAAM,oBAAoB,GAAyB,IAAI,2CAAuB,CAA4B,aAAa,EAAE,KAAK,IAAI,EAAE;wBAClI,MAAM,UAAU,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAa,aAAa,CAAC,CAAC,CAAC;wBAC1F,sEAAsE;wBACtE,IAAI,UAAU,KAAK,SAAS;4BAC1B,MAAM,KAAK,CAAC,8CAA8C,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC;wBACxF,OAAO,UAAU,CAAC;oBACpB,CAAC,CAAC,CAAC;oBACH,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;iBACjD;aACF;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAvCD,gCAuCC","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 { Constant, DelayedPromiseWithProps, LazyLoadedPhenomenon, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { getItemNameAndSchemaRef, mergeSchemaItemProperties } from \"./SchemaItemMerger\";\r\nimport { MutableConstant } from \"../Editing/Mutable/MutableConstant\";\r\n\r\n/**\r\n * @internal\r\n * @param target The constant the differences get merged into\r\n * @param source The constant to compare\r\n * @param changes Gets the @see SchemaItemChanges between the two constants.\r\n * For example, if source constant has an attribute/property that it missing in\r\n * target one, it would be listed in propertyValueChanges.\r\n */\r\nexport default async function mergeConstant(target: Constant, source: Constant, changes: SchemaItemChanges) {\r\n const mutableConstant = target as MutableConstant;\r\n\r\n // Get referenced higher level phenomenon\r\n const [refSchema, itemName] = await getItemNameAndSchemaRef(source, source.phenomenon!.fullName);\r\n\r\n await mergeSchemaItemProperties(mutableConstant, changes.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n switch (propertyName) {\r\n case \"definition\": {\r\n if (item.definition === \"\")\r\n return item.setDefinition(propertyValue);\r\n throw Error(`Failed to merged, constant definition conflict: ${propertyValue} -> ${item.definition}`);\r\n }\r\n case \"numerator\": {\r\n if (!item.hasNumerator)\r\n return item.setNumerator(propertyValue);\r\n throw Error(`Failed to merged, constant numerator conflict: ${propertyValue} -> ${item.numerator}`);\r\n }\r\n case \"denominator\": {\r\n if (!item.hasDenominator)\r\n return item.setDenominator(propertyValue);\r\n throw Error(`Failed to merged, constant denominator conflict: ${propertyValue} -> ${item.denominator}`);\r\n }\r\n case \"phenomenon\": {\r\n if (item.phenomenon === undefined) {\r\n // A lazy loaded phenomenon with the correct reference schema is needed, if reference schema is undefined then item schema.\r\n const schemaItemKey = new SchemaItemKey(itemName, refSchema ? refSchema.schemaKey : target.schema.schemaKey);\r\n const lazyTargetPhenomenon: LazyLoadedPhenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey, async () => {\r\n const phenomenon = (await target.schema.context.getSchemaItem<Phenomenon>(schemaItemKey));\r\n // At this point, higher level phenomenon item should not be undefined\r\n if (phenomenon === undefined)\r\n throw Error(`Unable to locate phenomenon item in schema ${schemaItemKey.schemaName}`);\r\n return phenomenon;\r\n });\r\n return item.setPhenomenon(lazyTargetPhenomenon);\r\n }\r\n }\r\n }\r\n });\r\n}\r\n"]}
@@ -0,0 +1,12 @@
1
+ import { Enumeration } from "@itwin/ecschema-metadata";
2
+ import { EnumerationChanges } from "../Validation/SchemaChanges";
3
+ /**
4
+ * @param target The Enumeration the differences get merged into
5
+ * @param source The Enumeration to compare
6
+ * @param changes Gets the @see EnumerationChanges between the two Enumerations.
7
+ * For example, if source Enumeration has an attribute that is undefined in
8
+ * target one, it would be listed in propertyValueChanges.
9
+ * @internal
10
+ */
11
+ export default function mergeEnumeration(target: Enumeration, source: Enumeration, changes: EnumerationChanges): Promise<void>;
12
+ //# sourceMappingURL=EnumerationMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,WAAW,EAA6C,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAc,kBAAkB,EAAmB,MAAM,6BAA6B,CAAC;AAsB9F;;;;;;;GAOG;AACH,wBAA8B,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB,iBA8CnH"}
@@ -0,0 +1,83 @@
1
+ "use strict";
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");
8
+ const SchemaChanges_1 = require("../Validation/SchemaChanges");
9
+ const SchemaItemMerger_1 = require("./SchemaItemMerger");
10
+ /**
11
+ * @param target The Enumeration the differences get merged into
12
+ * @param source The Enumeration to compare
13
+ * @param changes Gets the @see EnumerationChanges between the two Enumerations.
14
+ * For example, if source Enumeration has an attribute that is undefined in
15
+ * target one, it would be listed in propertyValueChanges.
16
+ * @internal
17
+ */
18
+ async function mergeEnumeration(target, source, changes) {
19
+ const mutableEnumeration = target;
20
+ await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutableEnumeration, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
21
+ switch (propertyName) {
22
+ case "isStrict": return item.setIsStrict(propertyValue);
23
+ case "type": {
24
+ const primitiveType = (0, ecschema_metadata_1.parsePrimitiveType)(propertyValue);
25
+ if (primitiveType && item.type !== primitiveType) {
26
+ throw Error(`Merged enumeration ${item.name} types not equal: ${(0, ecschema_metadata_1.primitiveTypeToString)(item.type)} -> ${propertyValue}`);
27
+ }
28
+ }
29
+ }
30
+ });
31
+ for (const enumeratorChange of changes.enumeratorChanges.values()) {
32
+ if (enumeratorChange.enumeratorMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
33
+ const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);
34
+ if (enumerator === undefined) {
35
+ throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in Enumeration ${source.fullName}`);
36
+ }
37
+ const result = mutableEnumeration.createEnumerator(enumerator.name, enumerator.value, enumerator.label, enumerator.description);
38
+ mutableEnumeration.addEnumerator(result);
39
+ }
40
+ else {
41
+ const targetEnumerator = target.getEnumeratorByName(enumeratorChange.ecTypeName);
42
+ if (targetEnumerator === undefined) {
43
+ throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in Enumeration ${target.fullName}`);
44
+ }
45
+ const mutableEnumerator = targetEnumerator;
46
+ await mergeEnumeratorAttributes(mutableEnumerator, enumeratorChange.enumeratorDeltas, (enumerator, attributeName, deltaChange, attributeValue) => {
47
+ switch (attributeName) {
48
+ case "label": {
49
+ enumerator.label = attributeValue;
50
+ return;
51
+ }
52
+ case "description": {
53
+ enumerator.description = attributeValue;
54
+ return;
55
+ }
56
+ case "value": {
57
+ throw Error(`Failed to merge enumerator attribute, ${deltaChange} in ${enumerator.name}`);
58
+ }
59
+ }
60
+ });
61
+ }
62
+ }
63
+ }
64
+ exports.default = mergeEnumeration;
65
+ /**
66
+ * Similar logic to mergeSchemaItemProperties but for EnumeratorDelta, which has the differences starting at index 1,
67
+ * hence the .slice(1), this is the main difference between mergeSchemaItemProperties.
68
+ * @param targetEnumerator The enumerator the differences get merged into.
69
+ * @param changes Gets the @see EnumeratorDelta, the Enumerator delta array holds information about changes between two Enumerators.
70
+ * @param handler Defines the information needed to merge the attributes.
71
+ * @internal
72
+ */
73
+ async function mergeEnumeratorAttributes(targetEnumerator, changes, handler) {
74
+ for (let index = 0, stepUp = true; index < changes.length; stepUp && index++, stepUp = true) {
75
+ const deltaChange = changes[index].toString(); // this will be useful for error message.
76
+ const [attributeName, attributeValue] = changes[index].diagnostic.messageArgs.slice(1); // messageArgs[0] seems to be an object, need to get to the next one, slice to start at index 1
77
+ if (handler(targetEnumerator, attributeName, deltaChange, attributeValue) === true) {
78
+ changes.splice(index, 1);
79
+ stepUp = false;
80
+ }
81
+ }
82
+ }
83
+ //# sourceMappingURL=EnumerationMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiH;AACjH,+DAA8F;AAC9F,yDAA+D;AAqB/D;;;;;;;GAOG;AACY,KAAK,UAAU,gBAAgB,CAAC,MAAmB,EAAE,MAAmB,EAAE,OAA2B;IAClH,MAAM,kBAAkB,GAAG,MAA4B,CAAC;IAExD,MAAM,IAAA,4CAAyB,EAAC,kBAAkB,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QACtH,QAAQ,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KAAK,CAAC;SAChB;KACF;AACH,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 { AnyEnumerator, Enumeration, parsePrimitiveType, primitiveTypeToString } from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, EnumerationChanges, EnumeratorDelta } from \"../Validation/SchemaChanges\";\r\nimport { mergeSchemaItemProperties } from \"./SchemaItemMerger\";\r\nimport { MutableEnumeration } from \"../Editing/Mutable/MutableEnumeration\";\r\n\r\n/**\r\n * @internal\r\n * @param item Type Enumerator, the Enumerator the differences get merged into.\r\n * @param attributeName Name of the Enumerator attribute that changed.\r\n * @param deltaChange Provides information about the changes in Enumerator attributes.\r\n * @param attributeValue The value that gets merged into the Enumerator attribute.\r\n */\r\ntype EnumeratorAttributeChanged<TEnumerator extends AnyEnumerator> = (item: TEnumerator, attributeName: string, deltaChange: string, attributeValue: any) => void | boolean;\r\n\r\n/**\r\n * Simple interface to extend access Enumerator attributes\r\n * and allow editing.\r\n */\r\ninterface MutableEnumerator extends AnyEnumerator {\r\n label?: string;\r\n description?: string;\r\n}\r\n\r\n/**\r\n * @param target The Enumeration the differences get merged into\r\n * @param source The Enumeration to compare\r\n * @param changes Gets the @see EnumerationChanges between the two Enumerations.\r\n * For example, if source Enumeration has an attribute that is undefined in\r\n * target one, it would be listed in propertyValueChanges.\r\n * @internal\r\n */\r\nexport default async function mergeEnumeration(target: Enumeration, source: Enumeration, changes: EnumerationChanges) {\r\n const mutableEnumeration = target as MutableEnumeration;\r\n\r\n await mergeSchemaItemProperties(mutableEnumeration, changes.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n switch (propertyName) {\r\n case \"isStrict\": return item.setIsStrict(propertyValue);\r\n case \"type\": {\r\n const primitiveType = parsePrimitiveType(propertyValue);\r\n if (primitiveType && item.type !== primitiveType) {\r\n throw Error(`Merged enumeration ${item.name} types not equal: ${primitiveTypeToString(item.type!)} -> ${propertyValue}`);\r\n }\r\n }\r\n }\r\n });\r\n\r\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\r\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\r\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\r\n if (enumerator === undefined) {\r\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in Enumeration ${source.fullName}`);\r\n }\r\n const result = mutableEnumeration.createEnumerator(enumerator.name, enumerator.value, enumerator.label, enumerator.description);\r\n mutableEnumeration.addEnumerator(result);\r\n } else {\r\n const targetEnumerator = target.getEnumeratorByName(enumeratorChange.ecTypeName);\r\n if (targetEnumerator === undefined) {\r\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in Enumeration ${target.fullName}`);\r\n }\r\n const mutableEnumerator = targetEnumerator as MutableEnumerator;\r\n await mergeEnumeratorAttributes(mutableEnumerator, enumeratorChange.enumeratorDeltas, (enumerator, attributeName, deltaChange, attributeValue) => {\r\n switch (attributeName) {\r\n case \"label\": {\r\n enumerator.label = attributeValue;\r\n return;\r\n }\r\n case \"description\": {\r\n enumerator.description = attributeValue;\r\n return;\r\n }\r\n case \"value\": {\r\n throw Error(`Failed to merge enumerator attribute, ${deltaChange} in ${enumerator.name}`);\r\n }\r\n }\r\n });\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Similar logic to mergeSchemaItemProperties but for EnumeratorDelta, which has the differences starting at index 1,\r\n * hence the .slice(1), this is the main difference between mergeSchemaItemProperties.\r\n * @param targetEnumerator The enumerator the differences get merged into.\r\n * @param changes Gets the @see EnumeratorDelta, the Enumerator delta array holds information about changes between two Enumerators.\r\n * @param handler Defines the information needed to merge the attributes.\r\n * @internal\r\n */\r\nasync function mergeEnumeratorAttributes<T extends AnyEnumerator>(targetEnumerator: T, changes: EnumeratorDelta[], handler: EnumeratorAttributeChanged<T>) {\r\n for (let index = 0, stepUp = true; index < changes.length; stepUp && index++, stepUp = true) {\r\n const deltaChange = changes[index].toString(); // this will be useful for error message.\r\n const [attributeName, attributeValue] = changes[index].diagnostic.messageArgs!.slice(1); // messageArgs[0] seems to be an object, need to get to the next one, slice to start at index 1\r\n if (handler(targetEnumerator, attributeName, deltaChange, attributeValue) === true) {\r\n changes.splice(index, 1);\r\n stepUp = false;\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ import { Phenomenon } from "@itwin/ecschema-metadata";
2
+ import { SchemaItemChanges } from "../Validation/SchemaChanges";
3
+ /**
4
+ * @internal
5
+ */
6
+ export default function mergePhenomenon(target: Phenomenon, source: Phenomenon, _changes?: SchemaItemChanges): Promise<void>;
7
+ //# 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,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;GAEG;AACH,wBAA8B,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,iBAAiB,iBAQjH"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * @internal
5
+ */
6
+ async function mergePhenomenon(target, source, _changes) {
7
+ const mutablePhenomenon = target;
8
+ if (mutablePhenomenon.definition === "") {
9
+ await mutablePhenomenon.setDefinition(source.definition);
10
+ }
11
+ else {
12
+ throw Error(`Failed to merge schemas, definition attribute conflict: ${source.definition} -> ${target.definition}`);
13
+ }
14
+ }
15
+ exports.default = mergePhenomenon;
16
+ //# sourceMappingURL=PhenomenonMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":";;AAQA;;GAEG;AACY,KAAK,UAAU,eAAe,CAAC,MAAkB,EAAE,MAAkB,EAAE,QAA4B;IAChH,MAAM,iBAAiB,GAAG,MAA2B,CAAC;IAEtD,IAAG,iBAAiB,CAAC,UAAU,KAAK,EAAE,EAAC;QACrC,MAAM,iBAAiB,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAC1D;SAAI;QACH,MAAM,KAAK,CAAC,2DAA2D,MAAM,CAAC,UAAU,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;KACrH;AACH,CAAC;AARD,kCAQC","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 { Phenomenon } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default async function mergePhenomenon(target: Phenomenon, source: Phenomenon, _changes?: SchemaItemChanges) {\r\n const mutablePhenomenon = target as MutablePhenomenon;\r\n\r\n if(mutablePhenomenon.definition === \"\"){\r\n await mutablePhenomenon.setDefinition(source.definition);\r\n }else{\r\n throw Error(`Failed to merge schemas, definition attribute conflict: ${source.definition} -> ${target.definition}`);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ import { PropertyCategory } from "@itwin/ecschema-metadata";
2
+ import { SchemaItemChanges } from "../Validation/SchemaChanges";
3
+ /**
4
+ * @internal
5
+ */
6
+ export default function mergePropertyCategory(target: PropertyCategory, _source: PropertyCategory, changes: SchemaItemChanges): Promise<void>;
7
+ //# sourceMappingURL=PropertyCategoryMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;GAEG;AACH,wBAA8B,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,iBAOlI"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const SchemaItemMerger_1 = require("./SchemaItemMerger");
4
+ /**
5
+ * @internal
6
+ */
7
+ async function mergePropertyCategory(target, _source, changes) {
8
+ const mutablePropertyCategory = target;
9
+ await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutablePropertyCategory, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
10
+ switch (propertyName) {
11
+ case "priority": return item.setPriority(propertyValue);
12
+ }
13
+ });
14
+ }
15
+ exports.default = mergePropertyCategory;
16
+ //# sourceMappingURL=PropertyCategoryMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;AAOA,yDAA+D;AAE/D;;GAEG;AACY,KAAK,UAAU,qBAAqB,CAAC,MAAwB,EAAE,OAAyB,EAAE,OAA0B;IACjI,MAAM,uBAAuB,GAAG,MAAiC,CAAC;IAClE,MAAM,IAAA,4CAAyB,EAAC,uBAAuB,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QAC3H,QAAO,YAAY,EAAE;YACnB,KAAK,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;SACzD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,wCAOC","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 { PropertyCategory } from \"@itwin/ecschema-metadata\";\r\nimport { MutablePropertyCategory } from \"../Editing/Mutable/MutablePropertyCategory\";\r\nimport { SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { mergeSchemaItemProperties } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default async function mergePropertyCategory(target: PropertyCategory, _source: PropertyCategory, changes: SchemaItemChanges) {\r\n const mutablePropertyCategory = target as MutablePropertyCategory;\r\n await mergeSchemaItemProperties(mutablePropertyCategory, changes.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n switch(propertyName) {\r\n case \"priority\": return item.setPriority(propertyValue);\r\n }\r\n });\r\n}\r\n"]}
@@ -0,0 +1,8 @@
1
+ import { Schema, SchemaItem } from "@itwin/ecschema-metadata";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare namespace SchemaItemFactory {
6
+ function create(targetSchema: Schema, template: SchemaItem): Promise<SchemaItem>;
7
+ }
8
+ //# sourceMappingURL=SchemaItemFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaItemFactory.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0F,MAAM,EAAE,UAAU,EAA2B,MAAM,0BAA0B,CAAC;AAE/K;;GAEG;AACH,yBAAiB,iBAAiB,CAAC;IAEjC,SAAsB,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAoB5F;CAKF"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaItemFactory = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
+ /**
10
+ * @internal
11
+ */
12
+ var SchemaItemFactory;
13
+ (function (SchemaItemFactory) {
14
+ async function create(targetSchema, template) {
15
+ if (is(template, ecschema_metadata_1.Enumeration))
16
+ return new ecschema_metadata_1.Enumeration(targetSchema, template.name, template.type);
17
+ if (is(template, ecschema_metadata_1.EntityClass))
18
+ return new ecschema_metadata_1.EntityClass(targetSchema, template.name, template.modifier);
19
+ if (is(template, ecschema_metadata_1.StructClass))
20
+ return new ecschema_metadata_1.StructClass(targetSchema, template.name, template.modifier);
21
+ if (is(template, ecschema_metadata_1.CustomAttributeClass))
22
+ return new ecschema_metadata_1.CustomAttributeClass(targetSchema, template.name, template.modifier);
23
+ if (is(template, ecschema_metadata_1.PropertyCategory))
24
+ return new ecschema_metadata_1.PropertyCategory(targetSchema, template.name);
25
+ if (is(template, ecschema_metadata_1.Phenomenon))
26
+ return new ecschema_metadata_1.Phenomenon(targetSchema, template.name);
27
+ if (is(template, ecschema_metadata_1.Constant))
28
+ return new ecschema_metadata_1.Constant(targetSchema, template.name);
29
+ if (is(template, ecschema_metadata_1.UnitSystem))
30
+ return new ecschema_metadata_1.UnitSystem(targetSchema, template.name);
31
+ throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);
32
+ }
33
+ SchemaItemFactory.create = create;
34
+ function is(item, type) {
35
+ return item instanceof type;
36
+ }
37
+ })(SchemaItemFactory = exports.SchemaItemFactory || (exports.SchemaItemFactory = {}));
38
+ //# sourceMappingURL=SchemaItemFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaItemFactory.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA+K;AAE/K;;GAEG;AACH,IAA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I,KAAK,CAAC,iCAAiC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAEhF,CAAC;IApBqB,wBAAM,SAoB3B,CAAA;IAED,SAAS,EAAE,CAAuB,IAAgB,EAAE,IAA6B;QAC/E,OAAO,IAAI,YAAY,IAAI,CAAC;IAC9B,CAAC;AACH,CAAC,EA3BgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QA2BjC","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 { Constant, CustomAttributeClass, EntityClass, Enumeration, Phenomenon, PropertyCategory, Schema, SchemaItem, StructClass, UnitSystem } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport namespace SchemaItemFactory {\r\n\r\n export async function create(targetSchema: Schema, template: SchemaItem): Promise<SchemaItem> {\r\n if (is(template, Enumeration))\r\n return new Enumeration(targetSchema, template.name, template.type);\r\n if (is(template, EntityClass))\r\n return new EntityClass(targetSchema, template.name, template.modifier);\r\n if (is(template, StructClass))\r\n return new StructClass(targetSchema, template.name, template.modifier);\r\n if (is(template, CustomAttributeClass))\r\n return new CustomAttributeClass(targetSchema, template.name, template.modifier);\r\n if(is(template, PropertyCategory))\r\n return new PropertyCategory(targetSchema, template.name);\r\n if (is(template, Phenomenon))\r\n return new Phenomenon(targetSchema, template.name);\r\n if (is(template, Constant))\r\n return new Constant(targetSchema, template.name);\r\n if (is(template, UnitSystem))\r\n return new UnitSystem(targetSchema, template.name);\r\n\r\n throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);\r\n\r\n }\r\n\r\n function is<T extends SchemaItem>(item: SchemaItem, type: new (...args: any) => T ): item is T {\r\n return item instanceof type;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,31 @@
1
+ import { Schema, SchemaItem } from "@itwin/ecschema-metadata";
2
+ import { PropertyValueChange, SchemaItemChanges } from "../Validation/SchemaChanges";
3
+ import { SchemaMergeContext } from "./SchemaMerger";
4
+ type SchemaItemMergeFn<TChange extends SchemaItemChanges, TItem extends SchemaItem> = (target: TItem, source: TItem, change: TChange, context: SchemaMergeContext) => Promise<void>;
5
+ type PropertyChangedFn<TItem extends SchemaItem> = (item: TItem, propertyName: string, propertyValue: any) => void | boolean;
6
+ /**
7
+ * Merges schema items from the source in the target schema. This method applies for all schema items
8
+ * and handles the basic processing such as create-if-not-exists or name collisions or base property setting.
9
+ * @param context The current merge context
10
+ * @param schemaItemChanges The schema items to be merged
11
+ * @param mergeFn Merge function for complex merging.
12
+ * @internal
13
+ */
14
+ export default function mergeSchemaItems<TChange extends SchemaItemChanges, TItem extends SchemaItem>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>, mergeFn?: SchemaItemMergeFn<TChange, TItem>): Promise<void>;
15
+ /**
16
+ * Performs the specified action for each property in the given PropertyValueChange array.
17
+ * @param targetItem The target item
18
+ * @param changes The array with PropertyValueChanges
19
+ * @param handler The callback that gets invoked vor every change.
20
+ * @internal
21
+ */
22
+ export declare function mergeSchemaItemProperties<T extends SchemaItem>(targetItem: T, changes: PropertyValueChange[], handler: PropertyChangedFn<T>): Promise<void>;
23
+ /**
24
+ * @param source The schema item the reference gets copied from
25
+ * @param itemFullName Parsing through item full name give us the schema reference name and the item name, these values are needed to create a new schema item key.
26
+ * @returns Item referenced schema and item name.
27
+ * @internal
28
+ */
29
+ export declare function getItemNameAndSchemaRef(source: SchemaItem, itemFullName: string): Promise<[Schema | undefined, string]>;
30
+ export {};
31
+ //# sourceMappingURL=SchemaItemMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAc,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,KAAK,iBAAiB,CAAC,OAAO,SAAS,iBAAiB,EAAE,KAAK,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACpL,KAAK,iBAAiB,CAAC,KAAK,SAAS,UAAU,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC;AAO7H;;;;;;;GAOG;AACH,wBAA8B,gBAAgB,CAAC,OAAO,SAAS,iBAAiB,EAAE,KAAK,SAAS,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,iBA6CzN;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,iBAQjJ;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,CAAC,CAI7H"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getItemNameAndSchemaRef = exports.mergeSchemaItemProperties = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
+ const SchemaChanges_1 = require("../Validation/SchemaChanges");
10
+ const SchemaItemFactory_1 = require("./SchemaItemFactory");
11
+ class MutableSchemaItem extends ecschema_metadata_1.SchemaItem {
12
+ }
13
+ /**
14
+ * Merges schema items from the source in the target schema. This method applies for all schema items
15
+ * and handles the basic processing such as create-if-not-exists or name collisions or base property setting.
16
+ * @param context The current merge context
17
+ * @param schemaItemChanges The schema items to be merged
18
+ * @param mergeFn Merge function for complex merging.
19
+ * @internal
20
+ */
21
+ async function mergeSchemaItems(context, schemaItemChanges, mergeFn) {
22
+ for (const change of schemaItemChanges) {
23
+ // Gets the source and the target item. The target item could be undefined at that point.
24
+ const sourceItem = (await context.sourceSchema.getItem(change.ecTypeName));
25
+ let targetItem = await context.targetSchema.getItem(change.ecTypeName);
26
+ // In case the schema item does not exists in the target schema, an instance for
27
+ // this schema item is created. It's properties get set by the merger then.
28
+ if (change.schemaItemMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
29
+ // Check for name to make sure there is no collision for items with the same name
30
+ // but different type.
31
+ if (targetItem !== undefined) {
32
+ throw new Error(`Schema ${context.targetSchema.name} already contains a Schema Item ${change.ecTypeName}.`);
33
+ }
34
+ // TODO: Think about renaming the Schema Item. This could be controlled though a flag.
35
+ const createdItem = await SchemaItemFactory_1.SchemaItemFactory.create(context.targetSchema, sourceItem);
36
+ context.targetSchema.addItem(targetItem = createdItem);
37
+ }
38
+ if (targetItem === undefined) {
39
+ throw new Error("Invalid state, targetItem must not be undefined at that point.");
40
+ }
41
+ // Sets the Schema items base properties...
42
+ await mergeSchemaItemProperties(targetItem, change.propertyValueChanges, (item, propertyName, propertyValue) => {
43
+ const mutableSchemaItem = item;
44
+ switch (propertyName) {
45
+ case "label":
46
+ mutableSchemaItem.setDisplayLabel(propertyValue);
47
+ return true;
48
+ case "description":
49
+ mutableSchemaItem.setDescription(propertyValue);
50
+ return true;
51
+ case "schemaItemType":
52
+ return true;
53
+ }
54
+ return;
55
+ });
56
+ if (mergeFn)
57
+ await mergeFn(targetItem, sourceItem, change, context);
58
+ }
59
+ }
60
+ exports.default = mergeSchemaItems;
61
+ /**
62
+ * Performs the specified action for each property in the given PropertyValueChange array.
63
+ * @param targetItem The target item
64
+ * @param changes The array with PropertyValueChanges
65
+ * @param handler The callback that gets invoked vor every change.
66
+ * @internal
67
+ */
68
+ async function mergeSchemaItemProperties(targetItem, changes, handler) {
69
+ for (let index = 0, increment = true; index < changes.length; increment && index++, increment = true) {
70
+ const [propertyName, propertyValue] = changes[index].diagnostic.messageArgs;
71
+ if (handler(targetItem, propertyName, propertyValue) === true) {
72
+ changes.splice(index, 1);
73
+ increment = false;
74
+ }
75
+ }
76
+ }
77
+ exports.mergeSchemaItemProperties = mergeSchemaItemProperties;
78
+ /**
79
+ * @param source The schema item the reference gets copied from
80
+ * @param itemFullName Parsing through item full name give us the schema reference name and the item name, these values are needed to create a new schema item key.
81
+ * @returns Item referenced schema and item name.
82
+ * @internal
83
+ */
84
+ async function getItemNameAndSchemaRef(source, itemFullName) {
85
+ const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(itemFullName);
86
+ const refSchema = await source.schema.getReference(schemaName);
87
+ return [refSchema, itemName];
88
+ }
89
+ exports.getItemNameAndSchemaRef = getItemNameAndSchemaRef;
90
+ //# sourceMappingURL=SchemaItemMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaItemMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA8D;AAC9D,+DAAiG;AAEjG,2DAAwD;AAMxD,MAAe,iBAAkB,SAAQ,8BAAU;CAGlD;AAED;;;;;;;GAOG;AACY,KAAK,UAAU,gBAAgB,CAA8D,OAA2B,EAAE,iBAAoC,EAAE,OAA2C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gBACd,KAAK,gBAAgB;oBACnB,OAAO,IAAI,CAAC;aACf;YACD,OAAO;QACT,CAAC,CAAC,CAAC;QAEH,IAAI,OAAO;YACT,MAAM,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KAC1D;AACH,CAAC;AA7CD,mCA6CC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,yBAAyB,CAAuB,UAAa,EAAE,OAA8B,EAAE,OAA6B;IAChJ,KAAI,IAAI,KAAK,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,SAAS,IAAI,KAAK,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE;QACnG,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,WAAY,CAAC;QAC7E,IAAG,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,KAAK,IAAI,EAAE;YAC5D,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACzB,SAAS,GAAG,KAAK,CAAC;SACnB;KACF;AACH,CAAC;AARD,8DAQC;AAED;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAAC,MAAkB,EAAE,YAAoB;IACpF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC/D,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAJD,0DAIC","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 { Schema, SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, PropertyValueChange, SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { MutableSchema } from \"../Editing/Mutable/MutableSchema\";\r\nimport { SchemaItemFactory } from \"./SchemaItemFactory\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\ntype SchemaItemMergeFn<TChange extends SchemaItemChanges, TItem extends SchemaItem> = (target: TItem, source: TItem, change: TChange, context: SchemaMergeContext) => Promise<void>;\r\ntype PropertyChangedFn<TItem extends SchemaItem> = (item: TItem, propertyName: string, propertyValue: any) => void | boolean;\r\n\r\nabstract class MutableSchemaItem extends SchemaItem{\r\n public abstract override setDisplayLabel(displayLabel: string): void;\r\n public abstract override setDescription(description: string): void;\r\n}\r\n\r\n/**\r\n * Merges schema items from the source in the target schema. This method applies for all schema items\r\n * and handles the basic processing such as create-if-not-exists or name collisions or base property setting.\r\n * @param context The current merge context\r\n * @param schemaItemChanges The schema items to be merged\r\n * @param mergeFn Merge function for complex merging.\r\n * @internal\r\n */\r\nexport default async function mergeSchemaItems<TChange extends SchemaItemChanges, TItem extends SchemaItem>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>, mergeFn?: SchemaItemMergeFn<TChange, TItem>) {\r\n for(const change of schemaItemChanges) {\r\n\r\n // Gets the source and the target item. The target item could be undefined at that point.\r\n const sourceItem = (await context.sourceSchema.getItem<TItem>(change.ecTypeName))!;\r\n let targetItem = await context.targetSchema.getItem<TItem>(change.ecTypeName);\r\n\r\n // In case the schema item does not exists in the target schema, an instance for\r\n // this schema item is created. It's properties get set by the merger then.\r\n if(change.schemaItemMissing?.changeType === ChangeType.Missing) {\r\n // Check for name to make sure there is no collision for items with the same name\r\n // but different type.\r\n if(targetItem !== undefined) {\r\n throw new Error(`Schema ${context.targetSchema.name} already contains a Schema Item ${change.ecTypeName}.`);\r\n }\r\n\r\n // TODO: Think about renaming the Schema Item. This could be controlled though a flag.\r\n\r\n const createdItem = await SchemaItemFactory.create(context.targetSchema, sourceItem) as TItem;\r\n (context.targetSchema as MutableSchema).addItem(targetItem = createdItem);\r\n }\r\n\r\n if(targetItem === undefined) {\r\n throw new Error(\"Invalid state, targetItem must not be undefined at that point.\");\r\n }\r\n\r\n // Sets the Schema items base properties...\r\n await mergeSchemaItemProperties(targetItem, change.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n const mutableSchemaItem = item as unknown as MutableSchemaItem;\r\n switch(propertyName) {\r\n case \"label\":\r\n mutableSchemaItem.setDisplayLabel(propertyValue);\r\n return true;\r\n case \"description\":\r\n mutableSchemaItem.setDescription(propertyValue);\r\n return true;\r\n case \"schemaItemType\":\r\n return true;\r\n }\r\n return;\r\n });\r\n\r\n if (mergeFn)\r\n await mergeFn(targetItem, sourceItem, change, context);\r\n }\r\n}\r\n\r\n/**\r\n * Performs the specified action for each property in the given PropertyValueChange array.\r\n * @param targetItem The target item\r\n * @param changes The array with PropertyValueChanges\r\n * @param handler The callback that gets invoked vor every change.\r\n * @internal\r\n */\r\nexport async function mergeSchemaItemProperties<T extends SchemaItem>(targetItem: T, changes: PropertyValueChange[], handler: PropertyChangedFn<T>) {\r\n for(let index = 0, increment = true; index < changes.length; increment && index++, increment = true) {\r\n const [propertyName, propertyValue] = changes[index].diagnostic.messageArgs!;\r\n if(handler(targetItem, propertyName, propertyValue) === true) {\r\n changes.splice(index, 1);\r\n increment = false;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @param source The schema item the reference gets copied from\r\n * @param itemFullName Parsing through item full name give us the schema reference name and the item name, these values are needed to create a new schema item key.\r\n * @returns Item referenced schema and item name.\r\n * @internal\r\n */\r\nexport async function getItemNameAndSchemaRef(source: SchemaItem, itemFullName: string): Promise<[Schema | undefined, string]> {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(itemFullName);\r\n const refSchema = await source.schema.getReference(schemaName);\r\n return [refSchema, itemName];\r\n}\r\n"]}
@@ -0,0 +1,36 @@
1
+ /** @packageDocumentation
2
+ * @module Merging
3
+ */
4
+ import { Schema } from "@itwin/ecschema-metadata";
5
+ /**
6
+ * Defines the context of a Schema merging run.
7
+ * @beta
8
+ */
9
+ export interface SchemaMergeContext {
10
+ readonly targetSchema: Schema;
11
+ readonly sourceSchema: Schema;
12
+ }
13
+ /**
14
+ * Class to merge two schemas together.
15
+ * @see [[merge]] to merge the schemas.
16
+ * @beta
17
+ */
18
+ export declare class SchemaMerger {
19
+ /**
20
+ * Gets the @see SchemaChanges between the two given Schemas from perspective of the source
21
+ * to the target schema. For example if source contains a class which does not exists in the
22
+ * target one, it would be listed as missing.
23
+ * @param targetSchema The schema the differences gets merged into.
24
+ * @param sourceSchema The schema to compare.
25
+ * @returns An instance of @see SchemaChanges between the two schemas.
26
+ */
27
+ private getSchemaChanges;
28
+ /**
29
+ * Copy the SchemaItems of the source schemas to the target schema.
30
+ * @param targetSchema The schema the SchemaItems gets merged to.
31
+ * @param sourceSchema The schema the SchemaItems gets copied from.
32
+ * @returns The merged target schema.
33
+ */
34
+ merge(targetSchema: Schema, sourceSchema: Schema): Promise<Schema>;
35
+ }
36
+ //# sourceMappingURL=SchemaMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAkB,MAAM,0BAA0B,CAAC;AAalE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB;;;;;;;OAOG;YACW,gBAAgB;IAa9B;;;;;OAKG;IACU,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAmChF"}