@itwin/ecschema-editing 4.3.2 → 4.4.0-dev.10

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 (67) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/lib/cjs/Editing/ECClasses.d.ts +2 -0
  3. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  4. package/lib/cjs/Editing/ECClasses.js +23 -0
  5. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  6. package/lib/cjs/Editing/Mutable/MutableArrayProperty.d.ts +10 -0
  7. package/lib/cjs/Editing/Mutable/MutableArrayProperty.d.ts.map +1 -0
  8. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js +16 -0
  9. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -0
  10. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +2 -0
  11. package/lib/cjs/Editing/Mutable/MutableClass.d.ts.map +1 -1
  12. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  13. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.d.ts +13 -0
  14. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.d.ts.map +1 -0
  15. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js +16 -0
  16. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -0
  17. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +6 -1
  18. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts.map +1 -1
  19. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  20. package/lib/cjs/Merging/AnyPropertyMerger.d.ts +15 -0
  21. package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +1 -0
  22. package/lib/cjs/Merging/AnyPropertyMerger.js +71 -0
  23. package/lib/cjs/Merging/AnyPropertyMerger.js.map +1 -0
  24. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +32 -0
  25. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +1 -0
  26. package/lib/cjs/Merging/ArrayPropertyMerger.js +143 -0
  27. package/lib/cjs/Merging/ArrayPropertyMerger.js.map +1 -0
  28. package/lib/cjs/Merging/CAClassMerger.d.ts +6 -8
  29. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  30. package/lib/cjs/Merging/CAClassMerger.js +27 -10
  31. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  32. package/lib/cjs/Merging/ClassMerger.d.ts +14 -6
  33. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  34. package/lib/cjs/Merging/ClassMerger.js +133 -35
  35. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  36. package/lib/cjs/Merging/ClassPropertyMerger.d.ts +16 -0
  37. package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +1 -0
  38. package/lib/cjs/Merging/ClassPropertyMerger.js +90 -0
  39. package/lib/cjs/Merging/ClassPropertyMerger.js.map +1 -0
  40. package/lib/cjs/Merging/CustomAttributeMerger.d.ts +21 -0
  41. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -0
  42. package/lib/cjs/Merging/CustomAttributeMerger.js +51 -0
  43. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -0
  44. package/lib/cjs/Merging/EntityClassMerger.d.ts +11 -0
  45. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -0
  46. package/lib/cjs/Merging/EntityClassMerger.js +26 -0
  47. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -0
  48. package/lib/cjs/Merging/MixinMerger.d.ts +11 -0
  49. package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -0
  50. package/lib/cjs/Merging/MixinMerger.js +38 -0
  51. package/lib/cjs/Merging/MixinMerger.js.map +1 -0
  52. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +24 -0
  53. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +1 -0
  54. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +106 -0
  55. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +1 -0
  56. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  57. package/lib/cjs/Merging/SchemaMerger.js +13 -3
  58. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  59. package/lib/cjs/Merging/StructClassMerger.d.ts +10 -0
  60. package/lib/cjs/Merging/StructClassMerger.d.ts.map +1 -0
  61. package/lib/cjs/Merging/StructClassMerger.js +13 -0
  62. package/lib/cjs/Merging/StructClassMerger.js.map +1 -0
  63. package/lib/cjs/Merging/StructPropertyMerger.d.ts +11 -0
  64. package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +1 -0
  65. package/lib/cjs/Merging/StructPropertyMerger.js +47 -0
  66. package/lib/cjs/Merging/StructPropertyMerger.js.map +1 -0
  67. package/package.json +15 -15
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassPropertyMerger = 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 StructPropertyMerger_1 = require("./StructPropertyMerger");
11
+ const ArrayPropertyMerger_1 = require("./ArrayPropertyMerger");
12
+ const PrimitiveOrEnumPropertyMerger_1 = require("./PrimitiveOrEnumPropertyMerger");
13
+ const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
14
+ /**
15
+ * @internal
16
+ */
17
+ class ClassPropertyMerger {
18
+ constructor(context) {
19
+ this.context = context;
20
+ }
21
+ getPropertyMerger(property) {
22
+ if (property.isEnumeration()) {
23
+ if (property.isArray()) {
24
+ return new ArrayPropertyMerger_1.EnumerationArrayPropertyMerger(this.context);
25
+ }
26
+ return new PrimitiveOrEnumPropertyMerger_1.EnumerationPropertyMerger(this.context);
27
+ }
28
+ if (property.isPrimitive()) {
29
+ if (property.isArray()) {
30
+ return new ArrayPropertyMerger_1.PrimitiveArraPropertyMerger(this.context);
31
+ }
32
+ return new PrimitiveOrEnumPropertyMerger_1.PrimitivePropertyMerger(this.context);
33
+ }
34
+ if (property.isStruct()) {
35
+ if (property.isArray()) {
36
+ return new ArrayPropertyMerger_1.StructArrayPropertyMerger(this.context);
37
+ }
38
+ return new StructPropertyMerger_1.StructPropertyMerger(this.context);
39
+ }
40
+ throw new Error(`Unsupported Property Type: ${(0, ecschema_metadata_1.propertyTypeToString)(property.propertyType)}`);
41
+ }
42
+ isPropertyEditResults(obj) {
43
+ return typeof obj === "object" && "errorMessage" in obj;
44
+ }
45
+ async mergeAttributeValueChanges(targetProperty, propertyValueChanges) {
46
+ if (propertyValueChanges.length === 0)
47
+ return;
48
+ const merger = this.getPropertyMerger(targetProperty);
49
+ for (const change of propertyValueChanges) {
50
+ const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs;
51
+ const results = await merger.mergeAttributes(targetProperty, attributeName, attributeNewValue, attributeOldValue);
52
+ if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
53
+ throw new Error(results.errorMessage);
54
+ }
55
+ }
56
+ }
57
+ static async mergeChanges(context, classKey, propertyChanges) {
58
+ const merger = new this(context);
59
+ for (const change of propertyChanges) {
60
+ const targetItem = await context.targetSchema.lookupItem(classKey);
61
+ if (targetItem === undefined) {
62
+ return { errorMessage: `'${classKey.name}' class could not be located in the merged schema.` };
63
+ }
64
+ if (change.propertyMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
65
+ const sourceProperty = change.propertyMissing.diagnostic.ecDefinition;
66
+ if (await targetItem.getProperty(change.ecTypeName) !== undefined) {
67
+ return { errorMessage: `Merged schema already contains a class '${classKey.name}' property '${change.ecTypeName}'.` };
68
+ }
69
+ const propertyMerger = merger.getPropertyMerger(sourceProperty);
70
+ const results = await propertyMerger.createFromProps(classKey, sourceProperty);
71
+ if (results.errorMessage !== undefined) {
72
+ return { errorMessage: results.errorMessage };
73
+ }
74
+ }
75
+ else {
76
+ const targetProperty = (await targetItem.getProperty(change.ecTypeName));
77
+ await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);
78
+ }
79
+ const mergeResults = await (0, CustomAttributeMerger_1.mergeCustomAttributes)(merger.context, change.customAttributeChanges.values(), async (ca) => {
80
+ return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);
81
+ });
82
+ if (mergeResults.errorMessage !== undefined) {
83
+ return { errorMessage: mergeResults.errorMessage };
84
+ }
85
+ }
86
+ return { itemKey: classKey };
87
+ }
88
+ }
89
+ exports.ClassPropertyMerger = ClassPropertyMerger;
90
+ //# sourceMappingURL=ClassPropertyMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAkG;AAElG,+DAA+F;AAE/F,iEAA8D;AAC9D,+DAA+H;AAE/H,mFAAqG;AACrG,mEAAgE;AAEhE;;GAEG;AACH,MAAa,mBAAmB;IAG9B,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEO,iBAAiB,CAAC,QAAkB;QAC1C,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE;YAC5B,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;gBACtB,OAAO,IAAI,oDAA8B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACzD;YACD,OAAO,IAAI,yDAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACpD;QACD,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAA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MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;gBACpH,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACtG,CAAC,CAAC,CAAC;YAEH,IAAI,YAAY,CAAC,YAAY,KAAK,SAAS,EAAE;gBAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,EAAC,CAAC;aACnD;SACF;QACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF;AAnFD,kDAmFC","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 { ECClass, Property, propertyTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { PropertyEditResults, SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ChangeType, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { StructPropertyMerger } from \"./StructPropertyMerger\";\nimport { EnumerationArrayPropertyMerger, PrimitiveArraPropertyMerger, StructArrayPropertyMerger } from \"./ArrayPropertyMerger\";\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\nimport { EnumerationPropertyMerger, PrimitivePropertyMerger } from \"./PrimitiveOrEnumPropertyMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * @internal\n */\nexport class ClassPropertyMerger {\n protected readonly context: SchemaMergeContext;\n\n constructor(context: SchemaMergeContext) {\n this.context = context;\n }\n\n private getPropertyMerger(property: Property): AnyPropertyMerger<Property> {\n if (property.isEnumeration()) {\n if (property.isArray()) {\n return new EnumerationArrayPropertyMerger(this.context);\n }\n return new EnumerationPropertyMerger(this.context);\n }\n if (property.isPrimitive()) {\n if (property.isArray()) {\n return new PrimitiveArraPropertyMerger(this.context);\n }\n return new PrimitivePropertyMerger(this.context);\n }\n if (property.isStruct()) {\n if (property.isArray()) {\n return new StructArrayPropertyMerger(this.context);\n }\n return new StructPropertyMerger(this.context);\n }\n throw new Error(`Unsupported Property Type: ${propertyTypeToString(property.propertyType)}`);\n }\n\n protected isPropertyEditResults(obj: any): obj is PropertyEditResults {\n return typeof obj === \"object\" && \"errorMessage\" in obj;\n }\n\n private async mergeAttributeValueChanges(targetProperty: Property, propertyValueChanges: PropertyValueChange[]) {\n if (propertyValueChanges.length === 0)\n return;\n\n const merger = this.getPropertyMerger(targetProperty);\n\n for (const change of propertyValueChanges) {\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\n const results = await merger.mergeAttributes(targetProperty, attributeName, attributeNewValue, attributeOldValue);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n throw new Error(results.errorMessage);\n }\n }\n }\n\n public static async mergeChanges(context: SchemaMergeContext, classKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\n const merger = new this(context);\n\n for (const change of propertyChanges) {\n const targetItem = await context.targetSchema.lookupItem<ECClass>(classKey);\n if (targetItem === undefined) {\n return { errorMessage: `'${classKey.name}' class could not be located in the merged schema.`};\n }\n\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\n return { errorMessage: `Merged schema already contains a class '${classKey.name}' property '${change.ecTypeName}'.`};\n }\n\n const propertyMerger = merger.getPropertyMerger(sourceProperty);\n const results = await propertyMerger.createFromProps(classKey, sourceProperty);\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage};\n }\n } else {\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\n await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);\n }\n\n const mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\n return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);\n });\n\n if (mergeResults.errorMessage !== undefined) {\n return { errorMessage: mergeResults.errorMessage};\n }\n }\n return { itemKey: classKey };\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ /** @packageDocumentation
2
+ * @module Merging
3
+ */
4
+ import { CustomAttribute } from "@itwin/ecschema-metadata";
5
+ import { CustomAttributeContainerChanges } from "../Validation/SchemaChanges";
6
+ import { SchemaMergeContext } from "./SchemaMerger";
7
+ interface EditResults {
8
+ errorMessage?: string;
9
+ }
10
+ /**
11
+ * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
12
+ * a scope (Class, Property, Schema) specific handler.
13
+ * @param mergeContext The current schema merging context.
14
+ * @param changes An iterable with custom attribute changes.
15
+ * @param callback The callback to add the custom attribute with a scope specific editor.
16
+ * @returns A EditResults object.
17
+ * @internal
18
+ */
19
+ export declare function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults>;
20
+ export {};
21
+ //# sourceMappingURL=CustomAttributeMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAA8D,MAAM,0BAA0B,CAAC;AACvH,OAAO,EAAc,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,CAAC,+BAA+B,CAAC,EAAE,QAAQ,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CA6B5N"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Merging
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.mergeCustomAttributes = void 0;
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ const SchemaChanges_1 = require("../Validation/SchemaChanges");
13
+ /**
14
+ * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
15
+ * a scope (Class, Property, Schema) specific handler.
16
+ * @param mergeContext The current schema merging context.
17
+ * @param changes An iterable with custom attribute changes.
18
+ * @param callback The callback to add the custom attribute with a scope specific editor.
19
+ * @returns A EditResults object.
20
+ * @internal
21
+ */
22
+ async function mergeCustomAttributes(mergeContext, changes, callback) {
23
+ for (const customAttributeContainerChange of changes) {
24
+ for (const change of customAttributeContainerChange.customAttributeChanges) {
25
+ if (change.changeType === SchemaChanges_1.ChangeType.Missing) {
26
+ const [sourceCustomAttribute] = change.diagnostic.messageArgs;
27
+ const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(sourceCustomAttribute.className);
28
+ const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)
29
+ ? mergeContext.targetSchema.schemaKey
30
+ : new ecschema_metadata_1.SchemaKey(schemaName));
31
+ const targetCustomAttribute = await mergeContext.targetSchema.lookupItem(schemaItemKey);
32
+ if (targetCustomAttribute === undefined) {
33
+ return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.` };
34
+ }
35
+ const results = await callback({
36
+ ...sourceCustomAttribute,
37
+ className: targetCustomAttribute.fullName,
38
+ });
39
+ if (results.errorMessage !== undefined) {
40
+ return { errorMessage: results.errorMessage };
41
+ }
42
+ }
43
+ else {
44
+ return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.` };
45
+ }
46
+ }
47
+ }
48
+ return {};
49
+ }
50
+ exports.mergeCustomAttributes = mergeCustomAttributes;
51
+ //# sourceMappingURL=CustomAttributeMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAuH;AACvH,+DAA0F;AAO1F;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CAAC,YAAgC,EAAE,OAAkD,EAAE,QAAoE;IACpM,KAAK,MAAM,8BAA8B,IAAI,OAAO,EAAE;QACpD,KAAK,MAAM,MAAM,IAAI,8BAA8B,CAAC,sBAAsB,EAAE;YAC1E,IAAI,MAAM,CAAC,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAC5C,MAAM,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,WAAgC,CAAC;gBACnF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAI,8BAAU,CAAC,aAAa,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;gBAC1F,MAAM,aAAa,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC;oBAC7G,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS;oBACrC,CAAC,CAAC,IAAI,6BAAS,CAAC,UAAU,CAAC,CAC5B,CAAC;gBACF,MAAM,qBAAqB,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC;gBAC9G,IAAI,qBAAqB,KAAK,SAAS,EAAE;oBACvC,OAAO,EAAE,YAAY,EAAE,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,EAAC,CAAC;iBACnH;gBAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC;oBAC7B,GAAG,qBAAqB;oBACxB,SAAS,EAAE,qBAAqB,CAAC,QAAQ;iBAC1C,CAAC,CAAC;gBAEH,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;oBACtC,OAAO,EAAG,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;iBAChD;aACF;iBAAM;gBACL,OAAO,EAAE,YAAY,EAAE,+BAA+B,8BAA8B,CAAC,UAAU,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,4BAA4B,EAAC,CAAC;aACnK;SACF;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,sDA6BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { CustomAttribute, CustomAttributeClass, SchemaItem, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ChangeType, CustomAttributeContainerChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\n\ninterface EditResults {\n errorMessage?: string;\n}\n\n/**\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\n * a scope (Class, Property, Schema) specific handler.\n * @param mergeContext The current schema merging context.\n * @param changes An iterable with custom attribute changes.\n * @param callback The callback to add the custom attribute with a scope specific editor.\n * @returns A EditResults object.\n * @internal\n */\nexport async function mergeCustomAttributes(mergeContext: SchemaMergeContext, changes: Iterable<CustomAttributeContainerChanges>, callback: (customAttribute: CustomAttribute) => Promise<EditResults>): Promise<EditResults> {\n for (const customAttributeContainerChange of changes) {\n for (const change of customAttributeContainerChange.customAttributeChanges) {\n if (change.changeType === ChangeType.Missing) {\n const [sourceCustomAttribute] = change.diagnostic.messageArgs as [CustomAttribute];\n const [schemaName, itemName] = SchemaItem.parseFullName(sourceCustomAttribute.className);\n const schemaItemKey = new SchemaItemKey(itemName, mergeContext.sourceSchema.schemaKey.compareByName(schemaName)\n ? mergeContext.targetSchema.schemaKey\n : new SchemaKey(schemaName),\n );\n const targetCustomAttribute = await mergeContext.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\n if (targetCustomAttribute === undefined) {\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.`};\n }\n\n const results = await callback({\n ...sourceCustomAttribute,\n className: targetCustomAttribute.fullName,\n });\n\n if (results.errorMessage !== undefined) {\n return { errorMessage: results.errorMessage };\n }\n } else {\n return { errorMessage: `Changes of Custom Attribute ${customAttributeContainerChange.ecTypeName} on ${mergeContext.targetSchema.name} merge is not implemented.`};\n }\n }\n }\n return {};\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { EntityClass, Mixin, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
2
+ import { ClassMerger } from "./ClassMerger";
3
+ import { SchemaItemEditResults } from "../Editing/Editor";
4
+ /**
5
+ * @internal
6
+ */
7
+ export default class EntityClassMerger extends ClassMerger<EntityClass> {
8
+ protected create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults>;
9
+ protected addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults>;
10
+ }
11
+ //# sourceMappingURL=EntityClassMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW,CAAC,WAAW,CAAC;cAC5C,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;cAIlF,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,qBAAqB,CAAC;CASxG"}
@@ -0,0 +1,26 @@
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 ClassMerger_1 = require("./ClassMerger");
9
+ /**
10
+ * @internal
11
+ */
12
+ class EntityClassMerger extends ClassMerger_1.ClassMerger {
13
+ async create(schemaKey, ecClass) {
14
+ return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);
15
+ }
16
+ async addMixin(itemKey, mixin) {
17
+ const mixinKey = new ecschema_metadata_1.SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)
18
+ ? this.context.targetSchema.schemaKey
19
+ : mixin.schema.schemaKey);
20
+ // addMixin should return results instead of throwing exception
21
+ await this.context.editor.entities.addMixin(itemKey, mixinKey);
22
+ return {};
23
+ }
24
+ }
25
+ exports.default = EntityClassMerger;
26
+ //# sourceMappingURL=EntityClassMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAwF;AACxF,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAClD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAEkB,KAAK,CAAC,QAAQ,CAAC,OAAsB,EAAE,KAAY;QACpE,MAAM,QAAQ,GAAG,IAAI,iCAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;YAChH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE5B,+DAA+D;QAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAdD,oCAcC","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 { EntityClass, Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\n/**\n * @internal\n */\nexport default class EntityClassMerger extends ClassMerger<EntityClass> {\n protected override async create(schemaKey: SchemaKey, ecClass: EntityClass): Promise<SchemaItemEditResults> {\n return this.context.editor.entities.create(schemaKey, ecClass.name, ecClass.modifier);\n }\n\n protected override async addMixin(itemKey: SchemaItemKey, mixin: Mixin): Promise<SchemaItemEditResults> {\n const mixinKey = new SchemaItemKey(mixin.name, mixin.schema.schemaKey.matches(this.context.sourceSchema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : mixin.schema.schemaKey);\n\n // addMixin should return results instead of throwing exception\n await this.context.editor.entities.addMixin(itemKey, mixinKey);\n return {};\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { Mixin, SchemaKey } from "@itwin/ecschema-metadata";
2
+ import { SchemaItemEditResults } from "../Editing/Editor";
3
+ import { ClassMerger } from "./ClassMerger";
4
+ /**
5
+ * @internal
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
+ }
11
+ //# sourceMappingURL=MixinMerger.d.ts.map
@@ -0,0 +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;CAe1K"}
@@ -0,0 +1,38 @@
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 ClassMerger_1 = require("./ClassMerger");
9
+ /**
10
+ * @internal
11
+ */
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.` };
16
+ }
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
+ const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);
24
+ if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {
25
+ return results;
26
+ }
27
+ switch (attributeName) {
28
+ case "appliesTo":
29
+ if (attributeOldValue !== undefined) {
30
+ return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };
31
+ }
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+ }
37
+ exports.default = MixinMerger;
38
+ //# sourceMappingURL=MixinMerger.js.map
@@ -0,0 +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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------------------------------------------------------------------------\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 { Mixin, SchemaItemKey, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\nimport { ClassMerger } from \"./ClassMerger\";\n\n/**\n * @internal\n */\nexport default class MixinMerger extends ClassMerger<Mixin> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: Mixin): Promise<SchemaItemEditResults> {\n if (ecClass.appliesTo === undefined) {\n return { errorMessage: `The Mixin ${ecClass.fullName} is missing the required 'appliesTo' attribute.` };\n }\n\n const appliesTo = new SchemaItemKey(ecClass.appliesTo.name, this.context.sourceSchema.schemaKey.matches(ecClass.appliesTo.schemaKey)\n ? this.context.targetSchema.schemaKey\n : ecClass.appliesTo.schemaKey);\n return this.context.editor.mixins.create(schemaKey, ecClass.name, appliesTo);\n }\n\n protected override async mergeAttributes(ecClass: Mixin, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<SchemaItemEditResults | boolean> {\n const results = await super.mergeAttributes(ecClass, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isSchemaItemEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch(attributeName) {\n case \"appliesTo\":\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the mixin '${ecClass.name}' appliesTo is not supported.` };\n }\n return true;\n }\n return false;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { EnumerationProperty, PrimitiveOrEnumPropertyBase, PrimitiveProperty, SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { AnyPropertyMerger } from "./AnyPropertyMerger";
3
+ import { PropertyEditResults } from "../Editing/Editor";
4
+ /**
5
+ * @internal
6
+ */
7
+ declare abstract class PrimitiveOrEnumPropertyMerger<TPrimitiveOrEnumPropertyBase extends PrimitiveOrEnumPropertyBase> extends AnyPropertyMerger<TPrimitiveOrEnumPropertyBase> {
8
+ mergeAttributes(property: TPrimitiveOrEnumPropertyBase, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
9
+ }
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare class PrimitivePropertyMerger extends PrimitiveOrEnumPropertyMerger<PrimitiveProperty> {
14
+ createFromProps(classKey: SchemaItemKey, property: PrimitiveProperty): Promise<PropertyEditResults>;
15
+ }
16
+ /**
17
+ * @internal
18
+ */
19
+ export declare class EnumerationPropertyMerger extends PrimitiveOrEnumPropertyMerger<EnumerationProperty> {
20
+ mergeAttributes(property: EnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
21
+ createFromProps(classKey: SchemaItemKey, property: EnumerationProperty): Promise<PropertyEditResults>;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=PrimitiveOrEnumPropertyMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveOrEnumPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PrimitiveOrEnumPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,mBAAmB,EAA4B,2BAA2B,EAAE,iBAAiB,EAA0B,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC7L,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD;;GAEG;AACH,uBAAe,6BAA6B,CAAC,4BAA4B,SAAS,2BAA2B,CAAE,SAAQ,iBAAiB,CAAC,4BAA4B,CAAC;IAC9I,eAAe,CAAC,QAAQ,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC;CA+B7L;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,6BAA6B,CAAC,iBAAiB,CAAC;IACrE,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAY1H;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,6BAA6B,CAAC,mBAAmB,CAAC;IACzE,eAAe,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC;IAiB7J,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA2B5H"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnumerationPropertyMerger = exports.PrimitivePropertyMerger = 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 AnyPropertyMerger_1 = require("./AnyPropertyMerger");
10
+ /**
11
+ * @internal
12
+ */
13
+ class PrimitiveOrEnumPropertyMerger extends AnyPropertyMerger_1.AnyPropertyMerger {
14
+ async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
15
+ const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
16
+ if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
17
+ return results;
18
+ }
19
+ const mutableProperty = property;
20
+ switch (attributeName) {
21
+ case "extendedTypeName": {
22
+ mutableProperty.setExtendedTypeName(attributeNewValue);
23
+ return true;
24
+ }
25
+ case "minLength": {
26
+ mutableProperty.setMinLength(attributeNewValue);
27
+ return true;
28
+ }
29
+ case "maxLength": {
30
+ mutableProperty.setMaxLength(attributeNewValue);
31
+ return true;
32
+ }
33
+ case "minValue": {
34
+ mutableProperty.setMinValue(attributeNewValue);
35
+ return true;
36
+ }
37
+ case "maxValue": {
38
+ mutableProperty.setMaxValue(attributeNewValue);
39
+ return true;
40
+ }
41
+ }
42
+ return false;
43
+ }
44
+ }
45
+ /**
46
+ * @internal
47
+ */
48
+ class PrimitivePropertyMerger extends PrimitiveOrEnumPropertyMerger {
49
+ async createFromProps(classKey, property) {
50
+ const results = await super.getPropertyProps(property);
51
+ if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
52
+ return results;
53
+ }
54
+ const props = {
55
+ ...property.toJSON(),
56
+ ...results,
57
+ };
58
+ return this.context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, props);
59
+ }
60
+ }
61
+ exports.PrimitivePropertyMerger = PrimitivePropertyMerger;
62
+ /**
63
+ * @internal
64
+ */
65
+ class EnumerationPropertyMerger extends PrimitiveOrEnumPropertyMerger {
66
+ async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
67
+ const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
68
+ if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
69
+ return results;
70
+ }
71
+ switch (attributeName) {
72
+ case "enumeration": {
73
+ if (attributeOldValue !== undefined) {
74
+ return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };
75
+ }
76
+ return true;
77
+ }
78
+ }
79
+ return false;
80
+ }
81
+ async createFromProps(classKey, property) {
82
+ const results = await super.getPropertyProps(property);
83
+ if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
84
+ return results;
85
+ }
86
+ if (property.enumeration === undefined) {
87
+ return { errorMessage: `Property ${property.fullName} is missing the required 'enumeration' attribute.` };
88
+ }
89
+ const enumeration = await property.enumeration;
90
+ const itemKey = new ecschema_metadata_1.SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)
91
+ ? this.context.targetSchema.schemaKey
92
+ : enumeration.schema.schemaKey);
93
+ const type = await this.context.targetSchema.lookupItem(itemKey);
94
+ if (type === undefined) {
95
+ return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };
96
+ }
97
+ const props = {
98
+ ...property.toJSON(),
99
+ ...results,
100
+ typeName: type.fullName,
101
+ };
102
+ return this.context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, props);
103
+ }
104
+ }
105
+ exports.EnumerationPropertyMerger = EnumerationPropertyMerger;
106
+ //# sourceMappingURL=PrimitiveOrEnumPropertyMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveOrEnumPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/PrimitiveOrEnumPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA6L;AAC7L,2DAAwD;AAIxD;;GAEG;AACH,MAAe,6BAAgG,SAAQ,qCAA+C;IACpJ,KAAK,CAAC,eAAe,CAAC,QAAsC,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACjJ,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAC3G,IAAI,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACjG,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,eAAe,GAAG,QAAyD,CAAC;QAClF,QAAQ,aAAa,EAAE;YACrB,KAAK,kBAAkB,CAAC,CAAC;gBACvB,eAAe,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;gBACvD,OAAO,IAAI,CAAC;aACb;YACD,KAAK,WAAW,CAAC,CAAC;gBAChB,eAAe,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC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,EAAE,YAAY,EAAE,0CAA0C,WAAW,CAAC,IAAI,wBAAwB,EAAE,CAAC;SAC7G;QAED,MAAM,KAAK,GAA6B;YACtC,GAAG,QAAQ,CAAC,MAAM,EAAE;YACpB,GAAG,OAAO;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/G,CAAC;CACF;AA7CD,8DA6CC","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 { Enumeration, EnumerationProperty, EnumerationPropertyProps, PrimitiveOrEnumPropertyBase, PrimitiveProperty, PrimitivePropertyProps, SchemaItemKey } from \"@itwin/ecschema-metadata\";\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\nimport { PropertyEditResults } from \"../Editing/Editor\";\nimport { MutablePrimitiveOrEnumPropertyBase } from \"../Editing/Mutable/MutablePrimitiveOrEnumProperty\";\n\n/**\n * @internal\n */\nabstract class PrimitiveOrEnumPropertyMerger<TPrimitiveOrEnumPropertyBase extends PrimitiveOrEnumPropertyBase> extends AnyPropertyMerger<TPrimitiveOrEnumPropertyBase> {\n public override async mergeAttributes(property: TPrimitiveOrEnumPropertyBase, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const mutableProperty = property as unknown as MutablePrimitiveOrEnumPropertyBase;\n switch (attributeName) {\n case \"extendedTypeName\": {\n mutableProperty.setExtendedTypeName(attributeNewValue);\n return true;\n }\n case \"minLength\": {\n mutableProperty.setMinLength(attributeNewValue);\n return true;\n }\n case \"maxLength\": {\n mutableProperty.setMaxLength(attributeNewValue);\n return true;\n }\n case \"minValue\": {\n mutableProperty.setMinValue(attributeNewValue);\n return true;\n }\n case \"maxValue\": {\n mutableProperty.setMaxValue(attributeNewValue);\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * @internal\n */\nexport class PrimitivePropertyMerger extends PrimitiveOrEnumPropertyMerger<PrimitiveProperty> {\n public override async createFromProps(classKey: SchemaItemKey, property: PrimitiveProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n const props: PrimitivePropertyProps = {\n ...property.toJSON(),\n ...results,\n };\n return this.context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, props);\n }\n}\n\n/**\n * @internal\n */\nexport class EnumerationPropertyMerger extends PrimitiveOrEnumPropertyMerger<EnumerationProperty> {\n public override async mergeAttributes(property: EnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n switch (attributeName) {\n case \"enumeration\": {\n if (attributeOldValue !== undefined) {\n return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };\n }\n return true;\n }\n }\n return false;\n }\n\n public override async createFromProps(classKey: SchemaItemKey, property: EnumerationProperty): Promise<PropertyEditResults> {\n const results = await super.getPropertyProps(property);\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\n return results;\n }\n\n if (property.enumeration === undefined) {\n return { errorMessage: `Property ${property.fullName} is missing the required 'enumeration' attribute.` };\n }\n\n const enumeration = await property.enumeration;\n const itemKey = new SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\n ? this.context.targetSchema.schemaKey\n : enumeration.schema.schemaKey,\n );\n const type = await this.context.targetSchema.lookupItem<Enumeration>(itemKey);\n if (type === undefined) {\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };\n }\n\n const props: EnumerationPropertyProps = {\n ...property.toJSON(),\n ...results,\n typeName: type.fullName,\n };\n return this.context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, props);\n }\n}\n"]}
@@ -1 +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;AAGlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;CACtC;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB;;;;;;;OAOG;YACW,gBAAgB;IAW9B;;;;;OAKG;IACU,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA2BhF"}
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;AAGlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAYxD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;CACtC;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB;;;;;;;OAOG;YACW,gBAAgB;IAW9B;;;;;OAKG;IACU,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiChF"}
@@ -13,10 +13,13 @@ const SchemaComparer_1 = require("../Validation/SchemaComparer");
13
13
  const Editor_1 = require("../Editing/Editor");
14
14
  const SchemaItemMerger_1 = require("./SchemaItemMerger");
15
15
  const SchemaReferenceMerger_1 = require("./SchemaReferenceMerger");
16
- const ClassMerger_1 = require("./ClassMerger");
17
16
  const CAClassMerger_1 = require("./CAClassMerger");
18
17
  const EnumerationMerger_1 = require("./EnumerationMerger");
19
18
  const ConstantMerger_1 = require("./ConstantMerger");
19
+ const EntityClassMerger_1 = require("./EntityClassMerger");
20
+ const StructClassMerger_1 = require("./StructClassMerger");
21
+ const MixinMerger_1 = require("./MixinMerger");
22
+ const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
20
23
  /**
21
24
  * Class to merge two schemas together.
22
25
  * @see [[merge]] to merge the schemas.
@@ -62,7 +65,12 @@ class SchemaMerger {
62
65
  // TODO: For now we just do simple copy and merging of properties and classes. For more complex types
63
66
  // with bases classes or relationships, this might need to get extended.
64
67
  await CAClassMerger_1.default.mergeChanges(mergeContext, itemChanges.customAttributeClasses);
65
- await ClassMerger_1.default.mergeChanges(mergeContext, itemChanges.classes);
68
+ await StructClassMerger_1.default.mergeChanges(mergeContext, itemChanges.structClasses);
69
+ await EntityClassMerger_1.default.mergeChanges(mergeContext, itemChanges.entityClasses);
70
+ await MixinMerger_1.default.mergeChanges(mergeContext, itemChanges.mixins);
71
+ await (0, CustomAttributeMerger_1.mergeCustomAttributes)(mergeContext, schemaChanges.customAttributeChanges.values(), async (ca) => {
72
+ return mergeContext.editor.addCustomAttribute(mergeContext.targetSchema.schemaKey, ca);
73
+ });
66
74
  // TODO: For now we directly manipulate the target schema. For error handing purposes, we should first
67
75
  // merge into a temporary schema and eventually swap that with the given instance.
68
76
  return targetSchema;
@@ -75,13 +83,15 @@ exports.SchemaMerger = SchemaMerger;
75
83
  */
76
84
  function getSchemaItemChanges(schemaChanges) {
77
85
  return {
78
- get classes() { return filterChangesByItemType(schemaChanges.classChanges, ecschema_metadata_1.SchemaItemType.EntityClass, ecschema_metadata_1.SchemaItemType.StructClass); },
86
+ get entityClasses() { return filterChangesByItemType(schemaChanges.classChanges, ecschema_metadata_1.SchemaItemType.EntityClass); },
79
87
  get constants() { return filterChangesByItemType(schemaChanges.schemaItemChanges, ecschema_metadata_1.SchemaItemType.Constant); },
80
88
  get customAttributeClasses() { return filterChangesByItemType(schemaChanges.classChanges, ecschema_metadata_1.SchemaItemType.CustomAttributeClass); },
81
89
  get enumeratations() { return schemaChanges.enumerationChanges.values(); },
82
90
  get phenomenons() { return filterChangesByItemType(schemaChanges.schemaItemChanges, ecschema_metadata_1.SchemaItemType.Phenomenon); },
83
91
  get propertyCategories() { return filterChangesByItemType(schemaChanges.schemaItemChanges, ecschema_metadata_1.SchemaItemType.PropertyCategory); },
84
92
  get unitSystems() { return filterChangesByItemType(schemaChanges.schemaItemChanges, ecschema_metadata_1.SchemaItemType.UnitSystem); },
93
+ get structClasses() { return filterChangesByItemType(schemaChanges.classChanges, ecschema_metadata_1.SchemaItemType.StructClass); },
94
+ get mixins() { return filterChangesByItemType(schemaChanges.classChanges, ecschema_metadata_1.SchemaItemType.Mixin); },
85
95
  };
86
96
  }
87
97
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkE;AAElE,iEAA8D;AAC9D,8CAAwD;AACxD,yDAAsD;AAEtD,mEAA4D;AAC5D,+CAAwC;AACxC,mDAA4C;AAC5C,2DAAoD;AACpD,qDAA+C;AAY/C;;;;GAIG;AACH,MAAa,YAAY;IACvB;;;;;;;O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,MAAM,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YACzC,MAAM,MAAM,CAAC;SACd;KACF;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { Schema, SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { SchemaChanges, SchemaItemChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\nimport mergeSchemaReferences from \"./SchemaReferenceMerger\";\nimport ClassMerger from \"./ClassMerger\";\nimport CAClassMerger from \"./CAClassMerger\";\nimport EnumerationMerger from \"./EnumerationMerger\";\nimport ConstantsMerger from \"./ConstantMerger\";\n\n/**\n * Defines the context of a Schema merging run.\n * @beta\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly sourceSchema: Schema;\n readonly editor: SchemaContextEditor;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] to merge the schemas.\n * @beta\n */\nexport class SchemaMerger {\n /**\n * Gets the @see SchemaChanges between the two given Schemas from perspective of the source\n * to the target schema. For example if source contains a class which does not exists in the\n * target one, it would be listed as missing.\n * @param targetSchema The schema the differences gets merged into.\n * @param sourceSchema The schema to compare.\n * @returns An instance of @see SchemaChanges between the two schemas.\n */\n private async getSchemaChanges(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaChanges> {\n const changesList: SchemaChanges[] = [];\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\n\n // It is important to compare the schema items by name, not full name as otherwise\n // we'd often see differences when comparing two different schemas.\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\n\n return changesList[0];\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @returns The merged target schema.\n */\n public async merge(targetSchema: Schema, sourceSchema: Schema): Promise<Schema> {\n const schemaChanges = await this.getSchemaChanges(targetSchema, sourceSchema);\n const mergeContext: SchemaMergeContext = {\n editor: new SchemaContextEditor(targetSchema.context),\n targetSchema,\n sourceSchema,\n };\n\n await mergeSchemaReferences(mergeContext, schemaChanges);\n\n const itemChanges = getSchemaItemChanges(schemaChanges);\n await EnumerationMerger.mergeChanges(mergeContext, itemChanges.enumeratations);\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.propertyCategories);\n\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.unitSystems);\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.phenomenons);\n await ConstantsMerger.mergeChanges(mergeContext, itemChanges.constants);\n\n // TODO: For now we just do simple copy and merging of properties and classes. For more complex types\n // with bases classes or relationships, this might need to get extended.\n await CAClassMerger.mergeChanges(mergeContext, itemChanges.customAttributeClasses);\n await ClassMerger.mergeChanges(mergeContext, itemChanges.classes);\n\n // TODO: For now we directly manipulate the target schema. For error handing purposes, we should first\n // merge into a temporary schema and eventually swap that with the given instance.\n return targetSchema;\n }\n}\n\n/**\n * This helper method composes the different schema change objects to a single easier\n * to use object that should improve readability when the methods get called.\n */\nfunction getSchemaItemChanges(schemaChanges: SchemaChanges) {\n return {\n get classes() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.EntityClass, SchemaItemType.StructClass); },\n get constants() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Constant); },\n get customAttributeClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.CustomAttributeClass); },\n get enumeratations() { return schemaChanges.enumerationChanges.values(); },\n get phenomenons() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Phenomenon); },\n get propertyCategories() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.PropertyCategory); },\n get unitSystems() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.UnitSystem); },\n };\n}\n\n/**\n * Filters and returns the changed items by its schema item type.\n * @param changes A map of changed schema items.\n * @param types A list of schema item types to filter.\n * @returns An Iterable with the filtered schema items.\n */\nfunction * filterChangesByItemType<TChange extends SchemaItemChanges>(changes: Map<string, TChange>, ...types: SchemaItemType[]): Iterable<TChange> {\n for(const change of changes.values()) {\n if (types.includes(change.schemaItemType)) {\n yield change;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkE;AAElE,iEAA8D;AAC9D,8CAAwD;AACxD,yDAAsD;AAEtD,mEAA4D;AAC5D,mDAA4C;AAC5C,2DAAoD;AACpD,qDAA+C;AAC/C,2DAAoD;AACpD,2DAAoD;AACpD,+CAAwC;AACxC,mEAAgE;AAYhE;;;;GAIG;AACH,MAAa,YAAY;IACvB;;;;;;;OAOG;IACK,KAAK,CAAC,gBAAgB,CAAC,YAAoB,EAAE,YAAoB;QACvE,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAE1F,kFAAkF;QAClF,mEAAmE;QACnE,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAEhE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,YAAoB,EAAE,YAAoB;QAC3D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY,CA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S,CAAC,CAAC,uBAAuB,CAAoC,OAA6B,EAAE,GAAG,KAAuB;IAC7H,KAAI,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YACzC,MAAM,MAAM,CAAC;SACd;KACF;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport { Schema, SchemaItemType } from \"@itwin/ecschema-metadata\";\nimport { SchemaChanges, SchemaItemChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\nimport { SchemaContextEditor } from \"../Editing/Editor\";\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\n\nimport mergeSchemaReferences from \"./SchemaReferenceMerger\";\nimport CAClassMerger from \"./CAClassMerger\";\nimport EnumerationMerger from \"./EnumerationMerger\";\nimport ConstantsMerger from \"./ConstantMerger\";\nimport EntityClassMerger from \"./EntityClassMerger\";\nimport StructClassMerger from \"./StructClassMerger\";\nimport MixinMerger from \"./MixinMerger\";\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\n\n/**\n * Defines the context of a Schema merging run.\n * @beta\n */\nexport interface SchemaMergeContext {\n readonly targetSchema: Schema;\n readonly sourceSchema: Schema;\n readonly editor: SchemaContextEditor;\n}\n\n/**\n * Class to merge two schemas together.\n * @see [[merge]] to merge the schemas.\n * @beta\n */\nexport class SchemaMerger {\n /**\n * Gets the @see SchemaChanges between the two given Schemas from perspective of the source\n * to the target schema. For example if source contains a class which does not exists in the\n * target one, it would be listed as missing.\n * @param targetSchema The schema the differences gets merged into.\n * @param sourceSchema The schema to compare.\n * @returns An instance of @see SchemaChanges between the two schemas.\n */\n private async getSchemaChanges(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaChanges> {\n const changesList: SchemaChanges[] = [];\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\n\n // It is important to compare the schema items by name, not full name as otherwise\n // we'd often see differences when comparing two different schemas.\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\n\n return changesList[0];\n }\n\n /**\n * Copy the SchemaItems of the source schemas to the target schema.\n * @param targetSchema The schema the SchemaItems gets merged to.\n * @param sourceSchema The schema the SchemaItems gets copied from.\n * @returns The merged target schema.\n */\n public async merge(targetSchema: Schema, sourceSchema: Schema): Promise<Schema> {\n const schemaChanges = await this.getSchemaChanges(targetSchema, sourceSchema);\n const mergeContext: SchemaMergeContext = {\n editor: new SchemaContextEditor(targetSchema.context),\n targetSchema,\n sourceSchema,\n };\n\n await mergeSchemaReferences(mergeContext, schemaChanges);\n\n const itemChanges = getSchemaItemChanges(schemaChanges);\n await EnumerationMerger.mergeChanges(mergeContext, itemChanges.enumeratations);\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.propertyCategories);\n\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.unitSystems);\n await SchemaItemMerger.mergeChanges(mergeContext, itemChanges.phenomenons);\n await ConstantsMerger.mergeChanges(mergeContext, itemChanges.constants);\n\n // TODO: For now we just do simple copy and merging of properties and classes. For more complex types\n // with bases classes or relationships, this might need to get extended.\n await CAClassMerger.mergeChanges(mergeContext, itemChanges.customAttributeClasses);\n await StructClassMerger.mergeChanges(mergeContext, itemChanges.structClasses);\n await EntityClassMerger.mergeChanges(mergeContext, itemChanges.entityClasses);\n await MixinMerger.mergeChanges(mergeContext, itemChanges.mixins);\n\n await mergeCustomAttributes(mergeContext, schemaChanges.customAttributeChanges.values(), async (ca) => {\n return mergeContext.editor.addCustomAttribute(mergeContext.targetSchema.schemaKey, ca);\n });\n\n // TODO: For now we directly manipulate the target schema. For error handing purposes, we should first\n // merge into a temporary schema and eventually swap that with the given instance.\n return targetSchema;\n }\n}\n\n/**\n * This helper method composes the different schema change objects to a single easier\n * to use object that should improve readability when the methods get called.\n */\nfunction getSchemaItemChanges(schemaChanges: SchemaChanges) {\n return {\n get entityClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.EntityClass); },\n get constants() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Constant); },\n get customAttributeClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.CustomAttributeClass); },\n get enumeratations() { return schemaChanges.enumerationChanges.values(); },\n get phenomenons() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.Phenomenon); },\n get propertyCategories() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.PropertyCategory); },\n get unitSystems() { return filterChangesByItemType(schemaChanges.schemaItemChanges, SchemaItemType.UnitSystem); },\n get structClasses() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.StructClass); },\n get mixins() { return filterChangesByItemType(schemaChanges.classChanges, SchemaItemType.Mixin); },\n };\n}\n\n/**\n * Filters and returns the changed items by its schema item type.\n * @param changes A map of changed schema items.\n * @param types A list of schema item types to filter.\n * @returns An Iterable with the filtered schema items.\n */\nfunction * filterChangesByItemType<TChange extends SchemaItemChanges>(changes: Map<string, TChange>, ...types: SchemaItemType[]): Iterable<TChange> {\n for(const change of changes.values()) {\n if (types.includes(change.schemaItemType)) {\n yield change;\n }\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { SchemaKey, StructClass } from "@itwin/ecschema-metadata";
2
+ import { ClassMerger } from "./ClassMerger";
3
+ import { SchemaItemEditResults } from "../Editing/Editor";
4
+ /**
5
+ * @internal
6
+ */
7
+ export default class StructClassMerger extends ClassMerger<StructClass> {
8
+ protected create(schemaKey: SchemaKey, ecClass: StructClass): Promise<SchemaItemEditResults>;
9
+ }
10
+ //# sourceMappingURL=StructClassMerger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW,CAAC,WAAW,CAAC;cAE5C,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAG5G"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ClassMerger_1 = require("./ClassMerger");
4
+ /**
5
+ * @internal
6
+ */
7
+ class StructClassMerger extends ClassMerger_1.ClassMerger {
8
+ async create(schemaKey, ecClass) {
9
+ return this.context.editor.structs.create(schemaKey, ecClass.name);
10
+ }
11
+ }
12
+ exports.default = StructClassMerger;
13
+ //# sourceMappingURL=StructClassMerger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":";;AAKA,+CAA4C;AAG5C;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,yBAAwB;IAElD,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,OAAoB;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;CACF;AALD,oCAKC","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 { SchemaKey, StructClass } from \"@itwin/ecschema-metadata\";\nimport { ClassMerger } from \"./ClassMerger\";\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\n\n/**\n * @internal\n */\nexport default class StructClassMerger extends ClassMerger<StructClass> {\n\n protected override async create(schemaKey: SchemaKey, ecClass: StructClass): Promise<SchemaItemEditResults> {\n return this.context.editor.structs.create(schemaKey, ecClass.name);\n }\n}\n"]}