@itwin/ecschema-editing 4.5.0-dev.3 → 4.5.0-dev.30

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 (120) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/Editing/Constants.js.map +1 -1
  4. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  5. package/lib/cjs/Editing/ECClasses.d.ts +9 -2
  6. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  7. package/lib/cjs/Editing/ECClasses.js +25 -0
  8. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  9. package/lib/cjs/Editing/Editor.js.map +1 -1
  10. package/lib/cjs/Editing/Entities.d.ts +8 -2
  11. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  12. package/lib/cjs/Editing/Entities.js +29 -6
  13. package/lib/cjs/Editing/Entities.js.map +1 -1
  14. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  15. package/lib/cjs/Editing/Formats.js.map +1 -1
  16. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  17. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  18. package/lib/cjs/Editing/Mixins.d.ts +8 -1
  19. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  20. package/lib/cjs/Editing/Mixins.js +35 -0
  21. package/lib/cjs/Editing/Mixins.js.map +1 -1
  22. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  23. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  24. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  25. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  26. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  27. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  28. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  29. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  30. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  31. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  32. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  33. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  34. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  35. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  36. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  37. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  38. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  39. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  40. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  41. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  42. package/lib/cjs/Editing/RelationshipClasses.d.ts +7 -1
  43. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  44. package/lib/cjs/Editing/RelationshipClasses.js +20 -1
  45. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  46. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  47. package/lib/cjs/Editing/Structs.js.map +1 -1
  48. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  49. package/lib/cjs/Editing/Units.js.map +1 -1
  50. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  51. package/lib/cjs/Merging/CAClassMerger.js +1 -5
  52. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  53. package/lib/cjs/Merging/ClassMerger.d.ts +6 -4
  54. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  55. package/lib/cjs/Merging/ClassMerger.js +80 -53
  56. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  57. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  58. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  59. package/lib/cjs/Merging/EntityClassMerger.d.ts +3 -2
  60. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  61. package/lib/cjs/Merging/EntityClassMerger.js +22 -7
  62. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  63. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  64. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  65. package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
  66. package/lib/cjs/Merging/MixinMerger.js +1 -5
  67. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  68. package/lib/cjs/Merging/PropertyMerger.d.ts +21 -0
  69. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -0
  70. package/lib/cjs/Merging/PropertyMerger.js +315 -0
  71. package/lib/cjs/Merging/PropertyMerger.js.map +1 -0
  72. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +15 -0
  73. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -0
  74. package/lib/cjs/Merging/RelationshipClassMerger.js +132 -0
  75. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -0
  76. package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -1
  77. package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
  78. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  79. package/lib/cjs/Merging/SchemaMerger.js +16 -7
  80. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  81. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  82. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  83. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  84. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  85. package/lib/cjs/Validation/ECRules.js.map +1 -1
  86. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  87. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  88. package/lib/cjs/Validation/Rules.js.map +1 -1
  89. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  90. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  91. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  92. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  93. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  94. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  95. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  96. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  97. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  98. package/lib/cjs/ecschema-editing.js.map +1 -1
  99. package/package.json +10 -10
  100. package/public/locales/en/ECSchemaEditing.json +26 -26
  101. package/lib/cjs/Merging/AnyPropertyMerger.d.ts +0 -15
  102. package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +0 -1
  103. package/lib/cjs/Merging/AnyPropertyMerger.js +0 -71
  104. package/lib/cjs/Merging/AnyPropertyMerger.js.map +0 -1
  105. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +0 -32
  106. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +0 -1
  107. package/lib/cjs/Merging/ArrayPropertyMerger.js +0 -143
  108. package/lib/cjs/Merging/ArrayPropertyMerger.js.map +0 -1
  109. package/lib/cjs/Merging/ClassPropertyMerger.d.ts +0 -16
  110. package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +0 -1
  111. package/lib/cjs/Merging/ClassPropertyMerger.js +0 -90
  112. package/lib/cjs/Merging/ClassPropertyMerger.js.map +0 -1
  113. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +0 -24
  114. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +0 -1
  115. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +0 -106
  116. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +0 -1
  117. package/lib/cjs/Merging/StructPropertyMerger.d.ts +0 -11
  118. package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +0 -1
  119. package/lib/cjs/Merging/StructPropertyMerger.js +0 -47
  120. package/lib/cjs/Merging/StructPropertyMerger.js.map +0 -1
@@ -1,143 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrimitiveArraPropertyMerger = exports.EnumerationArrayPropertyMerger = exports.StructArrayPropertyMerger = 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 ArrayPropertyMerger 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 "minOccurs":
22
- mutableProperty.setMinOccurs(attributeNewValue);
23
- return true;
24
- case "maxOccurs":
25
- mutableProperty.setMaxOccurs(attributeNewValue);
26
- return true;
27
- }
28
- return false;
29
- }
30
- }
31
- /**
32
- * @internal
33
- */
34
- class StructArrayPropertyMerger extends ArrayPropertyMerger {
35
- async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
36
- const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
37
- if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
38
- return results;
39
- }
40
- switch (attributeName) {
41
- case "structClass": {
42
- if (attributeOldValue !== undefined) {
43
- return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };
44
- }
45
- return true;
46
- }
47
- }
48
- return false;
49
- }
50
- async createFromProps(classKey, property) {
51
- const results = await super.getPropertyProps(property);
52
- if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
53
- return results;
54
- }
55
- const itemKey = new ecschema_metadata_1.SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)
56
- ? this.context.targetSchema.schemaKey
57
- : property.structClass.schema.schemaKey);
58
- const type = await this.context.targetSchema.lookupItem(itemKey);
59
- if (type === undefined) {
60
- return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };
61
- }
62
- const props = {
63
- ...property.toJSON(),
64
- ...results,
65
- typeName: type.fullName,
66
- };
67
- return this.context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, props);
68
- }
69
- }
70
- exports.StructArrayPropertyMerger = StructArrayPropertyMerger;
71
- /**
72
- * @internal
73
- */
74
- class EnumerationArrayPropertyMerger extends ArrayPropertyMerger {
75
- async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
76
- const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
77
- if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
78
- return results;
79
- }
80
- switch (attributeName) {
81
- case "enumeration": {
82
- if (attributeOldValue !== undefined) {
83
- return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };
84
- }
85
- return true;
86
- }
87
- }
88
- return false;
89
- }
90
- async createFromProps(classKey, property) {
91
- const results = await super.getPropertyProps(property);
92
- if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
93
- return results;
94
- }
95
- if (property.enumeration === undefined) {
96
- return { errorMessage: `Property '${property.fullName}' is missing the required 'enumeration' attribute.` };
97
- }
98
- const enumeration = await property.enumeration;
99
- const itemKey = new ecschema_metadata_1.SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)
100
- ? this.context.targetSchema.schemaKey
101
- : enumeration.schema.schemaKey);
102
- const type = await this.context.targetSchema.lookupItem(itemKey);
103
- if (type === undefined) {
104
- return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };
105
- }
106
- const props = {
107
- ...property.toJSON(),
108
- ...results,
109
- };
110
- return this.context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, props);
111
- }
112
- }
113
- exports.EnumerationArrayPropertyMerger = EnumerationArrayPropertyMerger;
114
- /**
115
- * @internal
116
- */
117
- class PrimitiveArraPropertyMerger extends ArrayPropertyMerger {
118
- async mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue) {
119
- const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);
120
- if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
121
- return results;
122
- }
123
- switch (attributeName) {
124
- case "primitiveType": {
125
- return { errorMessage: `Changing the property '${property.name}' typeName is not supported.` };
126
- }
127
- }
128
- return false;
129
- }
130
- async createFromProps(classKey, property) {
131
- const results = await super.getPropertyProps(property);
132
- if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
133
- return results;
134
- }
135
- const props = {
136
- ...property.toJSON(),
137
- ...results,
138
- };
139
- return this.context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, props);
140
- }
141
- }
142
- exports.PrimitiveArraPropertyMerger = PrimitiveArraPropertyMerger;
143
- //# sourceMappingURL=ArrayPropertyMerger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArrayPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/ArrayPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAmM;AAEnM,2DAAwD;AAIxD;;GAEG;AACH,MAAM,mBAA2D,SAAQ,qCAAkC;IACzF,KAAK,CAAC,eAAe,CAAC,QAAwB,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACnI,MAAM,OAAO,GAAG,MAAM,KAAK,CAA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;QAED,MAAM,KAAK,GAAgC;YACzC,GAAG,QAAQ,CAAC,MAAM,EAAE;YACpB,GAAG,OAAO;SACX,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qCAAqC,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACpI,CAAC;CACF;AA3BD,kEA2BC","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 { ArrayProperty, Enumeration, EnumerationArrayProperty, PrimitiveArrayProperty, SchemaItemKey, StructArrayProperty, StructArrayPropertyProps, StructClass } from \"@itwin/ecschema-metadata\";\r\nimport { PrimitiveArrayPropertyProps } from \"@itwin/ecschema-metadata/src/Deserialization/JsonProps\";\r\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\r\nimport { PropertyEditResults } from \"../Editing/Editor\";\r\nimport { MutableArrayProperty } from \"../Editing/Mutable/MutableArrayProperty\";\r\n\r\n/**\r\n * @internal\r\n */\r\nclass ArrayPropertyMerger<TArrayProperty extends ArrayProperty> extends AnyPropertyMerger <TArrayProperty> {\r\n public override async mergeAttributes(property: TArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const mutableProperty = property as unknown as MutableArrayProperty;\r\n switch (attributeName) {\r\n case \"minOccurs\":\r\n mutableProperty.setMinOccurs(attributeNewValue);\r\n return true;\r\n\r\n case \"maxOccurs\":\r\n mutableProperty.setMaxOccurs(attributeNewValue);\r\n return true;\r\n\r\n }\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class StructArrayPropertyMerger extends ArrayPropertyMerger <StructArrayProperty> {\r\n public override async mergeAttributes(property: StructArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"structClass\": {\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: StructArrayProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const itemKey = new SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : property.structClass.schema.schemaKey,\r\n );\r\n const type = await this.context.targetSchema.lookupItem<StructClass>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };\r\n }\r\n\r\n const props: StructArrayPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n typeName: type.fullName,\r\n };\r\n return this.context.editor.entities.createStructArrayPropertyFromProps(classKey, property.name, type, props);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class EnumerationArrayPropertyMerger extends ArrayPropertyMerger <EnumerationArrayProperty> {\r\n public override async mergeAttributes(property: EnumerationArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"enumeration\": {\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: EnumerationArrayProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n if (property.enumeration === undefined) {\r\n return { errorMessage: `Property '${property.fullName}' is missing the required 'enumeration' attribute.` };\r\n }\r\n\r\n const enumeration = await property.enumeration;\r\n const itemKey = new SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : enumeration.schema.schemaKey,\r\n );\r\n const type = await this.context.targetSchema.lookupItem<Enumeration>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };\r\n }\r\n\r\n const props: PrimitiveArrayPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n };\r\n return this.context.editor.entities.createEnumerationArrayPropertyFromProps(classKey, property.name, type, props);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class PrimitiveArraPropertyMerger extends ArrayPropertyMerger <PrimitiveArrayProperty> {\r\n public override async mergeAttributes(property: PrimitiveArrayProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"primitiveType\": {\r\n return { errorMessage: `Changing the property '${property.name}' typeName is not supported.`};\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: PrimitiveArrayProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const props: PrimitiveArrayPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n };\r\n return this.context.editor.entities.createPrimitiveArrayPropertyFromProps(classKey, property.name, property.primitiveType, props);\r\n }\r\n}\r\n"]}
@@ -1,16 +0,0 @@
1
- import { SchemaItemKey } from "@itwin/ecschema-metadata";
2
- import { PropertyEditResults, SchemaItemEditResults } from "../Editing/Editor";
3
- import { PropertyChanges } from "../Validation/SchemaChanges";
4
- import { SchemaMergeContext } from "./SchemaMerger";
5
- /**
6
- * @internal
7
- */
8
- export declare class ClassPropertyMerger {
9
- protected readonly context: SchemaMergeContext;
10
- constructor(context: SchemaMergeContext);
11
- private getPropertyMerger;
12
- protected isPropertyEditResults(obj: any): obj is PropertyEditResults;
13
- private mergeAttributeValueChanges;
14
- static mergeChanges(context: SchemaMergeContext, classKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults>;
15
- }
16
- //# sourceMappingURL=ClassPropertyMerger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2C,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAc,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOpD;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBAEnC,OAAO,EAAE,kBAAkB;IAIvC,OAAO,CAAC,iBAAiB;IAsBzB,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB;YAIvD,0BAA0B;WAepB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAmCnK"}
@@ -1,90 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAE,EAAE;gBACtB,OAAO,IAAI,iDAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACtD;YACD,OAAO,IAAI,uDAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAClD;QACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE;YACvB,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;gBACtB,OAAO,IAAI,+CAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACpD;YACD,OAAO,IAAI,2CAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC/C;QACD,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAA,wCAAoB,EAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAA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Content":["/*---------------------------------------------------------------------------------------------\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 { ECClass, Property, propertyTypeToString, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { PropertyEditResults, SchemaItemEditResults } from \"../Editing/Editor\";\r\nimport { ChangeType, PropertyChanges, PropertyValueChange } from \"../Validation/SchemaChanges\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { StructPropertyMerger } from \"./StructPropertyMerger\";\r\nimport { EnumerationArrayPropertyMerger, PrimitiveArraPropertyMerger, StructArrayPropertyMerger } from \"./ArrayPropertyMerger\";\r\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\r\nimport { EnumerationPropertyMerger, PrimitivePropertyMerger } from \"./PrimitiveOrEnumPropertyMerger\";\r\nimport { mergeCustomAttributes } from \"./CustomAttributeMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class ClassPropertyMerger {\r\n protected readonly context: SchemaMergeContext;\r\n\r\n constructor(context: SchemaMergeContext) {\r\n this.context = context;\r\n }\r\n\r\n private getPropertyMerger(property: Property): AnyPropertyMerger<Property> {\r\n if (property.isEnumeration()) {\r\n if (property.isArray()) {\r\n return new EnumerationArrayPropertyMerger(this.context);\r\n }\r\n return new EnumerationPropertyMerger(this.context);\r\n }\r\n if (property.isPrimitive()) {\r\n if (property.isArray()) {\r\n return new PrimitiveArraPropertyMerger(this.context);\r\n }\r\n return new PrimitivePropertyMerger(this.context);\r\n }\r\n if (property.isStruct()) {\r\n if (property.isArray()) {\r\n return new StructArrayPropertyMerger(this.context);\r\n }\r\n return new StructPropertyMerger(this.context);\r\n }\r\n throw new Error(`Unsupported Property Type: ${propertyTypeToString(property.propertyType)}`);\r\n }\r\n\r\n protected isPropertyEditResults(obj: any): obj is PropertyEditResults {\r\n return typeof obj === \"object\" && \"errorMessage\" in obj;\r\n }\r\n\r\n private async mergeAttributeValueChanges(targetProperty: Property, propertyValueChanges: PropertyValueChange[]) {\r\n if (propertyValueChanges.length === 0)\r\n return;\r\n\r\n const merger = this.getPropertyMerger(targetProperty);\r\n\r\n for (const change of propertyValueChanges) {\r\n const [attributeName, attributeNewValue, attributeOldValue] = change.diagnostic.messageArgs!;\r\n const results = await merger.mergeAttributes(targetProperty, attributeName, attributeNewValue, attributeOldValue);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n throw new Error(results.errorMessage);\r\n }\r\n }\r\n }\r\n\r\n public static async mergeChanges(context: SchemaMergeContext, classKey: SchemaItemKey, propertyChanges: Iterable<PropertyChanges>): Promise<SchemaItemEditResults> {\r\n const merger = new this(context);\r\n\r\n for (const change of propertyChanges) {\r\n const targetItem = await context.targetSchema.lookupItem<ECClass>(classKey);\r\n if (targetItem === undefined) {\r\n return { errorMessage: `'${classKey.name}' class could not be located in the merged schema.`};\r\n }\r\n\r\n if (change.propertyMissing?.changeType === ChangeType.Missing) {\r\n const sourceProperty = change.propertyMissing.diagnostic.ecDefinition as unknown as Property;\r\n if (await targetItem.getProperty(change.ecTypeName) !== undefined) {\r\n return { errorMessage: `Merged schema already contains a class '${classKey.name}' property '${change.ecTypeName}'.`};\r\n }\r\n\r\n const propertyMerger = merger.getPropertyMerger(sourceProperty);\r\n const results = await propertyMerger.createFromProps(classKey, sourceProperty);\r\n if (results.errorMessage !== undefined) {\r\n return { errorMessage: results.errorMessage};\r\n }\r\n } else {\r\n const targetProperty = (await targetItem.getProperty(change.ecTypeName))!;\r\n await merger.mergeAttributeValueChanges(targetProperty, change.propertyValueChanges);\r\n }\r\n\r\n const mergeResults = await mergeCustomAttributes(merger.context, change.customAttributeChanges.values(), async (ca) => {\r\n return merger.context.editor.entities.addCustomAttributeToProperty(classKey, change.ecTypeName, ca);\r\n });\r\n\r\n if (mergeResults.errorMessage !== undefined) {\r\n return { errorMessage: mergeResults.errorMessage};\r\n }\r\n }\r\n return { itemKey: classKey };\r\n }\r\n}\r\n"]}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,106 +0,0 @@
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
@@ -1 +0,0 @@
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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C,MAAM,CAAC,SAAS,CAC/B,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAc,OAAO,CAAC,CAAC;QAC9E,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,OAAO,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":["/*---------------------------------------------------------------------------------------------\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 { Enumeration, EnumerationProperty, EnumerationPropertyProps, PrimitiveOrEnumPropertyBase, PrimitiveProperty, PrimitivePropertyProps, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\r\nimport { PropertyEditResults } from \"../Editing/Editor\";\r\nimport { MutablePrimitiveOrEnumPropertyBase } from \"../Editing/Mutable/MutablePrimitiveOrEnumProperty\";\r\n\r\n/**\r\n * @internal\r\n */\r\nabstract class PrimitiveOrEnumPropertyMerger<TPrimitiveOrEnumPropertyBase extends PrimitiveOrEnumPropertyBase> extends AnyPropertyMerger<TPrimitiveOrEnumPropertyBase> {\r\n public override async mergeAttributes(property: TPrimitiveOrEnumPropertyBase, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const mutableProperty = property as unknown as MutablePrimitiveOrEnumPropertyBase;\r\n switch (attributeName) {\r\n case \"extendedTypeName\": {\r\n mutableProperty.setExtendedTypeName(attributeNewValue);\r\n return true;\r\n }\r\n case \"minLength\": {\r\n mutableProperty.setMinLength(attributeNewValue);\r\n return true;\r\n }\r\n case \"maxLength\": {\r\n mutableProperty.setMaxLength(attributeNewValue);\r\n return true;\r\n }\r\n case \"minValue\": {\r\n mutableProperty.setMinValue(attributeNewValue);\r\n return true;\r\n }\r\n case \"maxValue\": {\r\n mutableProperty.setMaxValue(attributeNewValue);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class PrimitivePropertyMerger extends PrimitiveOrEnumPropertyMerger<PrimitiveProperty> {\r\n public override async createFromProps(classKey: SchemaItemKey, property: PrimitiveProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const props: PrimitivePropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n };\r\n return this.context.editor.entities.createPrimitivePropertyFromProps(classKey, property.name, property.primitiveType, props);\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class EnumerationPropertyMerger extends PrimitiveOrEnumPropertyMerger<EnumerationProperty> {\r\n public override async mergeAttributes(property: EnumerationProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"enumeration\": {\r\n if (attributeOldValue !== undefined) {\r\n return { errorMessage: `Changing the property '${property.name}' enumeration is not supported.` };\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: EnumerationProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n if (property.enumeration === undefined) {\r\n return { errorMessage: `Property ${property.fullName} is missing the required 'enumeration' attribute.` };\r\n }\r\n\r\n const enumeration = await property.enumeration;\r\n const itemKey = new SchemaItemKey(enumeration.name, this.context.sourceSchema.schemaKey.matches(enumeration.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : enumeration.schema.schemaKey,\r\n );\r\n const type = await this.context.targetSchema.lookupItem<Enumeration>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the enumeration class ${enumeration.name} in the merged schema.` };\r\n }\r\n\r\n const props: EnumerationPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n typeName: type.fullName,\r\n };\r\n return this.context.editor.entities.createEnumerationPropertyFromProps(classKey, property.name, type, props);\r\n }\r\n}\r\n"]}
@@ -1,11 +0,0 @@
1
- import { SchemaItemKey, StructProperty } from "@itwin/ecschema-metadata";
2
- import { AnyPropertyMerger } from "./AnyPropertyMerger";
3
- import { PropertyEditResults } from "../Editing/Editor";
4
- /**
5
- * @internal
6
- */
7
- export declare class StructPropertyMerger extends AnyPropertyMerger<StructProperty> {
8
- mergeAttributes(property: StructProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean>;
9
- createFromProps(classKey: SchemaItemKey, property: StructProperty): Promise<PropertyEditResults>;
10
- }
11
- //# sourceMappingURL=StructPropertyMerger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StructPropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/StructPropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAe,cAAc,EAAuB,MAAM,0BAA0B,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,iBAAiB,CAAC,cAAc,CAAC;IACnD,eAAe,CAAC,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC;IAcxJ,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAsBvH"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StructPropertyMerger = 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 StructPropertyMerger 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
- switch (attributeName) {
20
- case "structClass": {
21
- return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };
22
- }
23
- }
24
- return false;
25
- }
26
- async createFromProps(classKey, property) {
27
- const results = await super.getPropertyProps(property);
28
- if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {
29
- return results;
30
- }
31
- const itemKey = new ecschema_metadata_1.SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)
32
- ? this.context.targetSchema.schemaKey
33
- : property.structClass.schema.schemaKey);
34
- const type = await this.context.targetSchema.lookupItem(itemKey);
35
- if (type === undefined) {
36
- return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };
37
- }
38
- const props = {
39
- ...property.toJSON(),
40
- ...results,
41
- typeName: type.fullName,
42
- };
43
- return this.context.editor.entities.createStructPropertyFromProps(classKey, property.name, type, props);
44
- }
45
- }
46
- exports.StructPropertyMerger = StructPropertyMerger;
47
- //# sourceMappingURL=StructPropertyMerger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StructPropertyMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructPropertyMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA2G;AAC3G,2DAAwD;AAGxD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,qCAAiC;IACzD,KAAK,CAAC,eAAe,CAAC,QAAwB,EAAE,aAAqB,EAAE,iBAAsB,EAAE,iBAAsB;QACnI,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,QAAQ,aAAa,EAAE;YACrB,KAAK,aAAa,CAAC,CAAC;gBAClB,OAAO,EAAE,YAAY,EAAE,0BAA0B,QAAQ,CAAC,IAAI,iCAAiC,EAAE,CAAC;aACnG;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,QAAuB,EAAE,QAAwB;QACrF,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YAC7E,OAAO,OAAO,CAAC;SAChB;QAED,MAAM,OAAO,GAAG,IAAI,iCAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC;YAC7I,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS;YACrC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CACxC,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,UAAU,CAAc,OAAO,CAAC,CAAC;QAC9E,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,OAAO,EAAE,YAAY,EAAE,qCAAqC,QAAQ,CAAC,WAAW,CAAC,IAAI,wBAAwB,EAAE,CAAC;SACjH;QAED,MAAM,KAAK,GAAwB;YACjC,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,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1G,CAAC;CACF;AArCD,oDAqCC","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 { SchemaItemKey, StructClass, StructProperty, StructPropertyProps } from \"@itwin/ecschema-metadata\";\r\nimport { AnyPropertyMerger } from \"./AnyPropertyMerger\";\r\nimport { PropertyEditResults } from \"../Editing/Editor\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class StructPropertyMerger extends AnyPropertyMerger<StructProperty> {\r\n public override async mergeAttributes(property: StructProperty, attributeName: string, attributeNewValue: any, attributeOldValue: any): Promise<PropertyEditResults | boolean> {\r\n const results = await super.mergeAttributes(property, attributeName, attributeNewValue, attributeOldValue);\r\n if (results === true || this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n switch (attributeName) {\r\n case \"structClass\": {\r\n return { errorMessage: `Changing the property '${property.name}' structClass is not supported.` };\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public override async createFromProps(classKey: SchemaItemKey, property: StructProperty): Promise<PropertyEditResults> {\r\n const results = await super.getPropertyProps(property);\r\n if (this.isPropertyEditResults(results) && results.errorMessage !== undefined) {\r\n return results;\r\n }\r\n\r\n const itemKey = new SchemaItemKey(property.structClass.name, this.context.sourceSchema.schemaKey.matches(property.structClass.schema.schemaKey)\r\n ? this.context.targetSchema.schemaKey\r\n : property.structClass.schema.schemaKey,\r\n );\r\n const type = await this.context.targetSchema.lookupItem<StructClass>(itemKey);\r\n if (type === undefined) {\r\n return { errorMessage: `Unable to locate the struct class ${property.structClass.name} in the merged schema.` };\r\n }\r\n\r\n const props: StructPropertyProps = {\r\n ...property.toJSON(),\r\n ...results,\r\n typeName: type.fullName,\r\n };\r\n return this.context.editor.entities.createStructPropertyFromProps(classKey, property.name, type, props);\r\n }\r\n}\r\n"]}