@itwin/ecschema-editing 4.3.0-dev.2 → 4.3.0-dev.20

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 (53) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/lib/cjs/Editing/Editor.d.ts +3 -0
  3. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  4. package/lib/cjs/Editing/Editor.js +3 -0
  5. package/lib/cjs/Editing/Editor.js.map +1 -1
  6. package/lib/cjs/Editing/Enumerations.d.ts +2 -0
  7. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  8. package/lib/cjs/Editing/Enumerations.js +22 -0
  9. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  10. package/lib/cjs/Editing/SchemaItems.d.ts +15 -0
  11. package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -0
  12. package/lib/cjs/Editing/SchemaItems.js +28 -0
  13. package/lib/cjs/Editing/SchemaItems.js.map +1 -0
  14. package/lib/cjs/Merging/CAClassMerger.d.ts +8 -2
  15. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  16. package/lib/cjs/Merging/CAClassMerger.js +12 -20
  17. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  18. package/lib/cjs/Merging/ClassMerger.d.ts +7 -2
  19. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  20. package/lib/cjs/Merging/ClassMerger.js +41 -45
  21. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  22. package/lib/cjs/Merging/ConstantMerger.d.ts +7 -7
  23. package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
  24. package/lib/cjs/Merging/ConstantMerger.js +37 -46
  25. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  26. package/lib/cjs/Merging/EnumerationMerger.d.ts +8 -7
  27. package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
  28. package/lib/cjs/Merging/EnumerationMerger.js +38 -67
  29. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  30. package/lib/cjs/Merging/SchemaItemFactory.d.ts +9 -2
  31. package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +1 -1
  32. package/lib/cjs/Merging/SchemaItemFactory.js +45 -11
  33. package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
  34. package/lib/cjs/Merging/SchemaItemMerger.d.ts +49 -20
  35. package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
  36. package/lib/cjs/Merging/SchemaItemMerger.js +76 -71
  37. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  38. package/lib/cjs/Merging/SchemaMerger.d.ts +2 -0
  39. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  40. package/lib/cjs/Merging/SchemaMerger.js +29 -21
  41. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  42. package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
  43. package/lib/cjs/Merging/SchemaReferenceMerger.js +8 -10
  44. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  45. package/package.json +9 -9
  46. package/lib/cjs/Merging/PhenomenonMerger.d.ts +0 -7
  47. package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +0 -1
  48. package/lib/cjs/Merging/PhenomenonMerger.js +0 -16
  49. package/lib/cjs/Merging/PhenomenonMerger.js.map +0 -1
  50. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +0 -7
  51. package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +0 -1
  52. package/lib/cjs/Merging/PropertyCategoryMerger.js +0 -16
  53. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +0 -1
@@ -1,56 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
- * See LICENSE.md in the project root for license terms and full copyright notice.
6
- *--------------------------------------------------------------------------------------------*/
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
7
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
8
8
  const SchemaItemMerger_1 = require("./SchemaItemMerger");
9
9
  /**
10
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
11
  */
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);
12
+ class ConstantsMerger extends SchemaItemMerger_1.SchemaItemMerger {
13
+ /**
14
+ * Creates the property value resolver for [[Constant]] items.
15
+ */
16
+ async createPropertyValueResolver() {
17
+ return {
18
+ phenomenon: (phenomenonFullName, targetItemKey) => {
19
+ // There are two options, either the phenomenon was referenced from another
20
+ // schema or it is defined in the same schema as the constant to be merged.
21
+ // In the latter case, the changes would report a different property value that
22
+ // refers to the source schema. So that needs to be changed here.
23
+ const [schemaName, phenomenonName] = ecschema_metadata_1.SchemaItem.parseFullName(phenomenonFullName);
24
+ if (this.context.targetSchema.getReferenceSync(schemaName) === undefined) {
25
+ return `${targetItemKey.schemaName}.${phenomenonName}`;
50
26
  }
51
- }
52
- }
53
- });
27
+ return phenomenonFullName;
28
+ },
29
+ numerator: (value, targetItemKey) => {
30
+ const item = this.context.targetSchema.lookupItemSync(targetItemKey);
31
+ if (item !== undefined && item.hasNumerator && item.numerator !== value) {
32
+ throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);
33
+ }
34
+ return value;
35
+ },
36
+ denominator: (value, targetItemKey) => {
37
+ const item = this.context.targetSchema.lookupItemSync(targetItemKey);
38
+ if (item !== undefined && item.hasDenominator && item.denominator !== value) {
39
+ throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);
40
+ }
41
+ return value;
42
+ },
43
+ };
44
+ }
54
45
  }
55
- exports.default = mergeConstant;
46
+ exports.default = ConstantsMerger;
56
47
  //# sourceMappingURL=ConstantMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8H;AAE9H,yDAAw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AS,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"]}
1
+ {"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA,kGAAkG;AAClG,sEAAsE;AACtE,oFAAoF;AACpF,kGAAkG;AAClG,gEAAgE;AAChE,yDAA6E;AAE7E;;GAEG;AACH,MAAqB,eAAgB,SAAQ,mCAA0B;IACrE;;OAEG;IACgB,KAAK,CAAC,2BAA2B;QAClD,OAAO;YACL,UAAU,EAAE,CAAC,kBAAkB,EAAE,aAAa,EAAE,EAAE;gBAChD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,+EAA+E;gBAC/E,iEAAiE;gBACjE,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBAClF,IAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;oBACvE,OAAO,GAAG,aAAa,CAAC,UAAU,IAAI,cAAc,EAAE,CAAC;iBACxD;gBACD,OAAO,kBAAkB,CAAC;YAC5B,CAAC;YACD,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;oBACtE,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACjG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;gBACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAW,aAAa,CAAC,CAAC;gBAC/E,IAAG,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;oBAC1E,MAAM,IAAI,KAAK,CAAC,oDAAoD,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;iBACrG;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAjCD,kCAiCC","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, SchemaItem } from \"@itwin/ecschema-metadata\";\r\nimport { PropertyValueResolver, SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class ConstantsMerger extends SchemaItemMerger<Constant> {\r\n /**\r\n * Creates the property value resolver for [[Constant]] items.\r\n */\r\n protected override async createPropertyValueResolver(): Promise<PropertyValueResolver<Constant>> {\r\n return {\r\n phenomenon: (phenomenonFullName, targetItemKey) => {\r\n // There are two options, either the phenomenon was referenced from another\r\n // schema or it is defined in the same schema as the constant to be merged.\r\n // In the latter case, the changes would report a different property value that\r\n // refers to the source schema. So that needs to be changed here.\r\n const [schemaName, phenomenonName] = SchemaItem.parseFullName(phenomenonFullName);\r\n if(this.context.targetSchema.getReferenceSync(schemaName) === undefined) {\r\n return `${targetItemKey.schemaName}.${phenomenonName}`;\r\n }\r\n return phenomenonFullName;\r\n },\r\n numerator: (value, targetItemKey) => {\r\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\r\n if(item !== undefined && item.hasNumerator && item.numerator !== value) {\r\n throw new Error(`Failed to merged, constant numerator conflict: ${value} -> ${item.numerator}`);\r\n }\r\n return value;\r\n },\r\n denominator: (value, targetItemKey) => {\r\n const item = this.context.targetSchema.lookupItemSync<Constant>(targetItemKey);\r\n if(item !== undefined && item.hasDenominator && item.denominator !== value) {\r\n throw new Error(`Failed to merged, constant denominator conflict: ${value} -> ${item.denominator}`);\r\n }\r\n return value;\r\n },\r\n };\r\n }\r\n}\r\n\r\n"]}
@@ -1,12 +1,13 @@
1
- import { Enumeration } from "@itwin/ecschema-metadata";
1
+ import { Enumeration, SchemaItemKey } from "@itwin/ecschema-metadata";
2
2
  import { EnumerationChanges } from "../Validation/SchemaChanges";
3
+ import { SchemaItemMerger } from "./SchemaItemMerger";
3
4
  /**
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
5
  * @internal
10
6
  */
11
- export default function mergeEnumeration(target: Enumeration, source: Enumeration, changes: EnumerationChanges): Promise<void>;
7
+ export default class EnumerationMerger extends SchemaItemMerger<Enumeration> {
8
+ /** Shorthand property to the enumerations editor. */
9
+ private get _editor();
10
+ protected merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges): Promise<void>;
11
+ private mergeEnumeratorChanges;
12
+ }
12
13
  //# sourceMappingURL=EnumerationMerger.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,WAAW,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAc,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,gBAAgB,CAAC,WAAW,CAAC;IAE1E,qDAAqD;IACrD,OAAO,KAAK,OAAO,GAElB;cAEwB,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB;YA6BzF,sBAAsB;CAgBrC"}
@@ -1,83 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
- * See LICENSE.md in the project root for license terms and full copyright notice.
6
- *--------------------------------------------------------------------------------------------*/
7
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
8
3
  const SchemaChanges_1 = require("../Validation/SchemaChanges");
9
4
  const SchemaItemMerger_1 = require("./SchemaItemMerger");
10
5
  /**
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
6
  * @internal
17
7
  */
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}`);
8
+ class EnumerationMerger extends SchemaItemMerger_1.SchemaItemMerger {
9
+ /** Shorthand property to the enumerations editor. */
10
+ get _editor() {
11
+ return this.context.editor.enumerations;
12
+ }
13
+ async merge(itemKey, source, changes) {
14
+ for (const enumeratorChange of changes.enumeratorChanges.values()) {
15
+ // In case the enumerator entry does not exist in the target enumeration the
16
+ // enumeratorMissing property is set and
17
+ if (enumeratorChange.enumeratorMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
18
+ const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);
19
+ if (enumerator === undefined) {
20
+ throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);
27
21
  }
22
+ // Enumerators are plain javascript objects with out any references to other
23
+ // instances or a schema. That allows to simply copy them over.
24
+ await this._editor.addEnumerator(itemKey, enumerator);
25
+ // Since every missing enumerator has delta changes for ech property, the loop
26
+ // must call continue here to avoid having all properties checked and set again.
27
+ continue;
28
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}`);
29
+ // For changes where the enumerators differ, the enumeratorDeltas property is
30
+ // filled. This allows to change individual enumerator entries. This is only
31
+ // allowed for labels and descriptions, all other deltas would throw an error.
32
+ for (const enumeratorDelta of enumeratorChange.enumeratorDeltas) {
33
+ await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs);
44
34
  }
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
35
  }
62
36
  }
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;
37
+ async mergeEnumeratorChanges(itemKey, [enumerator, propertyName, value]) {
38
+ // In case an enumerator has the same name but different value, the enumerator
39
+ // cannot be merged to keep integrity for the existing schema users.
40
+ if (propertyName === "value") {
41
+ throw new Error(`Failed to merge enumerator attribute, Enumerator "${enumerator.name}" has different values.`);
42
+ }
43
+ // For the other two properties they shall only be merged if the source value is
44
+ // set. In case they'd be undefined, the current enumerators value shall be kept.
45
+ if (propertyName === "label" && value !== undefined) {
46
+ await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);
47
+ }
48
+ if (propertyName === "description" && value !== undefined) {
49
+ await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);
80
50
  }
81
51
  }
82
52
  }
53
+ exports.default = EnumerationMerger;
83
54
  //# sourceMappingURL=EnumerationMerger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiH;AACjH,+DAA8F;AAC9F,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OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,WAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,+FAA+F;QACxL,IAAI,OAAO,CAAC,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,CAAC,KAAK,IAAI,EAAE;YAClF,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACzB,MAAM,GAAG,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"]}
1
+ {"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAKA,+DAA6E;AAC7E,yDAAsD;AAItD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,mCAA6B;IAE1E,qDAAqD;IACrD,IAAY,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,OAAsB,EAAE,MAAmB,EAAE,OAA2B;QACrG,KAAK,MAAM,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE;YACjE,4EAA4E;YAC5E,wCAAwC;YACxC,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;gBAEzE,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;gBAC3E,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC5B,MAAM,KAAK,CAAC,eAAe,gBAAgB,CAAC,UAAU,wBAAwB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAClG;gBAED,4EAA4E;gBAC5E,+DAA+D;gBAC/D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAEtD,8EAA8E;gBAC9E,gFAAgF;gBAChF,SAAS;aACV;YAED,6EAA6E;YAC7E,4EAA4E;YAC5E,8EAA8E;YAC9E,KAAI,MAAM,eAAe,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;gBAC9D,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,WAAmC,CAAC,CAAC;aAC5G;SACF;IACH,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,OAAsB,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,CAAsB;QACjH,8EAA8E;QAC9E,oEAAoE;QACpE,IAAG,YAAY,KAAK,OAAO,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,qDAAqD,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;SAChH;QAED,gFAAgF;QAChF,iFAAiF;QACjF,IAAG,YAAY,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAAE;YAClD,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACxE;QACD,IAAG,YAAY,KAAK,aAAa,IAAI,KAAK,KAAK,SAAS,EAAE;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC9E;IACH,CAAC;CACF;AApDD,oCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { AnyEnumerator, Enumeration, SchemaItemKey} from \"@itwin/ecschema-metadata\";\r\nimport { ChangeType, EnumerationChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaItemMerger } from \"./SchemaItemMerger\";\r\n\r\ntype EnumeratorDeltaArgs = [AnyEnumerator, keyof AnyEnumerator, string | undefined];\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default class EnumerationMerger extends SchemaItemMerger<Enumeration> {\r\n\r\n /** Shorthand property to the enumerations editor. */\r\n private get _editor() {\r\n return this.context.editor.enumerations;\r\n }\r\n\r\n protected override async merge(itemKey: SchemaItemKey, source: Enumeration, changes: EnumerationChanges) {\r\n for (const enumeratorChange of changes.enumeratorChanges.values()) {\r\n // In case the enumerator entry does not exist in the target enumeration the\r\n // enumeratorMissing property is set and\r\n if (enumeratorChange.enumeratorMissing?.changeType === ChangeType.Missing) {\r\n\r\n const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);\r\n if (enumerator === undefined) {\r\n throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in class ${source.fullName}`);\r\n }\r\n\r\n // Enumerators are plain javascript objects with out any references to other\r\n // instances or a schema. That allows to simply copy them over.\r\n await this._editor.addEnumerator(itemKey, enumerator);\r\n\r\n // Since every missing enumerator has delta changes for ech property, the loop\r\n // must call continue here to avoid having all properties checked and set again.\r\n continue;\r\n }\r\n\r\n // For changes where the enumerators differ, the enumeratorDeltas property is\r\n // filled. This allows to change individual enumerator entries. This is only\r\n // allowed for labels and descriptions, all other deltas would throw an error.\r\n for(const enumeratorDelta of enumeratorChange.enumeratorDeltas) {\r\n await this.mergeEnumeratorChanges(itemKey, enumeratorDelta.diagnostic.messageArgs! as EnumeratorDeltaArgs);\r\n }\r\n }\r\n }\r\n\r\n private async mergeEnumeratorChanges(itemKey: SchemaItemKey, [enumerator, propertyName, value]: EnumeratorDeltaArgs) {\r\n // In case an enumerator has the same name but different value, the enumerator\r\n // cannot be merged to keep integrity for the existing schema users.\r\n if(propertyName === \"value\") {\r\n throw new Error(`Failed to merge enumerator attribute, Enumerator \"${enumerator.name}\" has different values.`);\r\n }\r\n\r\n // For the other two properties they shall only be merged if the source value is\r\n // set. In case they'd be undefined, the current enumerators value shall be kept.\r\n if(propertyName === \"label\" && value !== undefined) {\r\n await this._editor.setEnumeratorLabel(itemKey, enumerator.name, value);\r\n }\r\n if(propertyName === \"description\" && value !== undefined) {\r\n await this._editor.setEnumeratorDescription(itemKey, enumerator.name, value);\r\n }\r\n }\r\n}\r\n"]}
@@ -1,8 +1,15 @@
1
- import { Schema, SchemaItem } from "@itwin/ecschema-metadata";
1
+ import { SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { SchemaMergeContext } from "./SchemaMerger";
2
3
  /**
3
4
  * @internal
4
5
  */
5
6
  export declare namespace SchemaItemFactory {
6
- function create(targetSchema: Schema, template: SchemaItem): Promise<SchemaItem>;
7
+ /**
8
+ * Creates a new Schema Item based on the given template instance.
9
+ * @param context The current merging context.
10
+ * @param template The Schema Items Template
11
+ * @returns The SchemaItemKey of the created item.
12
+ */
13
+ function create(context: SchemaMergeContext, template: SchemaItem): Promise<SchemaItemKey>;
7
14
  }
8
15
  //# sourceMappingURL=SchemaItemFactory.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"SchemaItemFactory.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyG,UAAU,EAAE,aAAa,EAAsC,MAAM,0BAA0B,CAAC;AAEhN,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;GAEG;AACH,yBAAiB,iBAAiB,CAAC;IAEjC;;;;;OAKG;IACH,SAAsB,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAMtG;CAgDF"}
@@ -11,26 +11,60 @@ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
11
11
  */
12
12
  var SchemaItemFactory;
13
13
  (function (SchemaItemFactory) {
14
- async function create(targetSchema, template) {
14
+ /**
15
+ * Creates a new Schema Item based on the given template instance.
16
+ * @param context The current merging context.
17
+ * @param template The Schema Items Template
18
+ * @returns The SchemaItemKey of the created item.
19
+ */
20
+ async function create(context, template) {
21
+ const result = await createItem(context.editor, context.targetSchema.schemaKey, template);
22
+ if (result.errorMessage) {
23
+ throw new Error(result.errorMessage);
24
+ }
25
+ return result.itemKey;
26
+ }
27
+ SchemaItemFactory.create = create;
28
+ /**
29
+ * Creates a new Schema Item in the SchemaContextEditor.
30
+ * @param editor The SchemaContextEditor
31
+ * @param targetSchemaKey The key of the target schema the item shall be created in.
32
+ * @param template The Schema Items Template
33
+ * @returns A SchemaItemEditResults with a schema key if the item could be created.
34
+ */
35
+ async function createItem(editor, targetSchemaKey, template) {
15
36
  if (is(template, ecschema_metadata_1.Enumeration))
16
- return new ecschema_metadata_1.Enumeration(targetSchema, template.name, template.type);
37
+ return editor.enumerations.create(targetSchemaKey, template.name, template.isInt ? ecschema_metadata_1.PrimitiveType.Integer : ecschema_metadata_1.PrimitiveType.String, template.label, template.isStrict);
17
38
  if (is(template, ecschema_metadata_1.EntityClass))
18
- return new ecschema_metadata_1.EntityClass(targetSchema, template.name, template.modifier);
39
+ return editor.entities.create(targetSchemaKey, template.name, template.modifier);
19
40
  if (is(template, ecschema_metadata_1.StructClass))
20
- return new ecschema_metadata_1.StructClass(targetSchema, template.name, template.modifier);
41
+ return editor.structs.create(targetSchemaKey, template.name);
21
42
  if (is(template, ecschema_metadata_1.CustomAttributeClass))
22
- return new ecschema_metadata_1.CustomAttributeClass(targetSchema, template.name, template.modifier);
43
+ return editor.customAttributes.create(targetSchemaKey, template.name, template.containerType);
23
44
  if (is(template, ecschema_metadata_1.PropertyCategory))
24
- return new ecschema_metadata_1.PropertyCategory(targetSchema, template.name);
45
+ return editor.propertyCategories.create(targetSchemaKey, template.name, template.priority);
25
46
  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);
47
+ return editor.phenomenons.create(targetSchemaKey, template.name, template.definition);
48
+ if (is(template, ecschema_metadata_1.Constant)) {
49
+ if (template.phenomenon === undefined) {
50
+ throw new Error(`Invalid Constant ${template.name} has no phenomenon defined`);
51
+ }
52
+ const phenomenon = await template.phenomenon;
53
+ const itemKey = phenomenon.key.schemaKey.matches(template.key.schemaKey)
54
+ ? new ecschema_metadata_1.SchemaItemKey(phenomenon.name, targetSchemaKey)
55
+ : phenomenon.key;
56
+ return editor.constants.create(targetSchemaKey, template.name, itemKey, template.definition);
57
+ }
29
58
  if (is(template, ecschema_metadata_1.UnitSystem))
30
- return new ecschema_metadata_1.UnitSystem(targetSchema, template.name);
59
+ return editor.unitSystems.create(targetSchemaKey, template.name);
31
60
  throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);
32
61
  }
33
- SchemaItemFactory.create = create;
62
+ /**
63
+ * Type Guard to "cast" a given schema item into an implementation
64
+ * @param item Item to be checked
65
+ * @param type The desired implementation.
66
+ * @returns true if the item could be casted, otherwise false.
67
+ */
34
68
  function is(item, type) {
35
69
  return item instanceof type;
36
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaItemFactory.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;A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AC,IAAI,CAAC,CAAC;QAErD,MAAM,IAAI,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"]}
1
+ {"version":3,"file":"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AE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEnE,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;OAKG;IACH,SAAS,EAAE,CAAuB,IAAgB,EAAE,IAA6B;QAC/E,OAAO,IAAI,YAAY,IAAI,CAAC;IAC9B,CAAC;AACH,CAAC,EA9DgB,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QA8DjC","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, PrimitiveType, PropertyCategory, SchemaItem, SchemaItemKey, SchemaKey, StructClass, UnitSystem } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport namespace SchemaItemFactory {\r\n\r\n /**\r\n * Creates a new Schema Item based on the given template instance.\r\n * @param context The current merging context.\r\n * @param template The Schema Items Template\r\n * @returns The SchemaItemKey of the created item.\r\n */\r\n export async function create(context: SchemaMergeContext, template: SchemaItem): Promise<SchemaItemKey> {\r\n const result = await createItem(context.editor, context.targetSchema.schemaKey, template);\r\n if(result.errorMessage) {\r\n throw new Error(result.errorMessage);\r\n }\r\n return result.itemKey!;\r\n }\r\n\r\n /**\r\n * Creates a new Schema Item in the SchemaContextEditor.\r\n * @param editor The SchemaContextEditor\r\n * @param targetSchemaKey The key of the target schema the item shall be created in.\r\n * @param template The Schema Items Template\r\n * @returns A SchemaItemEditResults with a schema key if the item could be created.\r\n */\r\n async function createItem(editor: SchemaContextEditor, targetSchemaKey: SchemaKey, template: SchemaItem): Promise<SchemaItemEditResults> {\r\n if (is(template, Enumeration))\r\n return editor.enumerations.create(targetSchemaKey, template.name, template.isInt ? PrimitiveType.Integer : PrimitiveType.String, template.label, template.isStrict);\r\n if (is(template, EntityClass))\r\n return editor.entities.create(targetSchemaKey, template.name, template.modifier);\r\n if (is(template, StructClass))\r\n return editor.structs.create(targetSchemaKey, template.name);\r\n if (is(template, CustomAttributeClass))\r\n return editor.customAttributes.create(targetSchemaKey, template.name, template.containerType);\r\n if(is(template, PropertyCategory))\r\n return editor.propertyCategories.create(targetSchemaKey, template.name, template.priority);\r\n if (is(template, Phenomenon))\r\n return editor.phenomenons.create(targetSchemaKey, template.name, template.definition);\r\n if (is(template, Constant)) {\r\n if(template.phenomenon === undefined) {\r\n throw new Error(`Invalid Constant ${template.name} has no phenomenon defined`);\r\n }\r\n const phenomenon = await template.phenomenon;\r\n const itemKey = phenomenon.key.schemaKey.matches(template.key.schemaKey)\r\n ? new SchemaItemKey(phenomenon.name, targetSchemaKey)\r\n : phenomenon.key;\r\n\r\n return editor.constants.create(targetSchemaKey, template.name, itemKey, template.definition);\r\n }\r\n if (is(template, UnitSystem))\r\n return editor.unitSystems.create(targetSchemaKey, template.name);\r\n\r\n throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);\r\n }\r\n\r\n /**\r\n * Type Guard to \"cast\" a given schema item into an implementation\r\n * @param item Item to be checked\r\n * @param type The desired implementation.\r\n * @returns true if the item could be casted, otherwise false.\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"]}
@@ -1,31 +1,60 @@
1
- import { Schema, SchemaItem } from "@itwin/ecschema-metadata";
2
- import { PropertyValueChange, SchemaItemChanges } from "../Validation/SchemaChanges";
1
+ import { SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
2
+ import { SchemaItemChanges } from "../Validation/SchemaChanges";
3
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
4
  /**
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.
5
+ * Defines a type-safe interface of Property Value resolver.
12
6
  * @internal
13
7
  */
14
- export default function mergeSchemaItems<TChange extends SchemaItemChanges, TItem extends SchemaItem>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>, mergeFn?: SchemaItemMergeFn<TChange, TItem>): Promise<void>;
8
+ export type PropertyValueResolver<T extends SchemaItem, TProps = MutableSchemaItemProps<T>> = {
9
+ [P in keyof TProps]?: (value: any, item: SchemaItemKey) => any;
10
+ };
15
11
  /**
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
12
+ * Defines a Mutable Schema Props interface.
21
13
  */
22
- export declare function mergeSchemaItemProperties<T extends SchemaItem>(targetItem: T, changes: PropertyValueChange[], handler: PropertyChangedFn<T>): Promise<void>;
14
+ type MutableSchemaItemProps<T extends SchemaItem> = {
15
+ -readonly [key in keyof ReturnType<T["toJSON"]>]: ReturnType<T["toJSON"]>[key];
16
+ };
23
17
  /**
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.
18
+ * The SchemaItemMerger is an base class for several other mergers with the actual logic
19
+ * to perform merging for a certain schema item type. The class provides the shared logics
20
+ * that is shared for all schema item mergers and custom logic can be applied by overriding
21
+ * the protected class members.
27
22
  * @internal
28
23
  */
29
- export declare function getItemNameAndSchemaRef(source: SchemaItem, itemFullName: string): Promise<[Schema | undefined, string]>;
24
+ export declare class SchemaItemMerger<TItem extends SchemaItem> {
25
+ protected readonly context: SchemaMergeContext;
26
+ /**
27
+ * Constructor of the SchemaItemMerger class. This should not be overriden or extended
28
+ * by sub-implementations.
29
+ * @param context The current merging context.
30
+ */
31
+ constructor(context: SchemaMergeContext);
32
+ /**
33
+ * This overridable method allows to create a property value resolver that gets defines
34
+ * a handler function for every possible property change. This allows adding complex handing
35
+ * if a property value requires complicated merging.
36
+ * @returns A resolver map with resolvers for the property.
37
+ */
38
+ protected createPropertyValueResolver(): Promise<PropertyValueResolver<TItem>>;
39
+ /**
40
+ * This overridable method gets called for more complex merging.
41
+ * @param _itemKey The key of the current schema item.
42
+ * @param _source The source item that shall gets merged into.
43
+ * @param _change The schema item change to be applied.
44
+ */
45
+ protected merge(_itemKey: SchemaItemKey, _source: TItem, _change: SchemaItemChanges): Promise<void>;
46
+ /**
47
+ * Merges the given schema item changes in the current context.
48
+ * @param context The merging context
49
+ * @param schemaItemChanges An iterable of item changes.
50
+ */
51
+ static mergeChanges<TChange extends SchemaItemChanges>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>): Promise<void>;
52
+ /**
53
+ * Merges the property values.
54
+ * @param targetItem The current schema item
55
+ * @param changes The property changes.
56
+ */
57
+ private mergeItemPropertyValues;
58
+ }
30
59
  export {};
31
60
  //# sourceMappingURL=SchemaItemMerger.d.ts.map
@@ -1 +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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