@itwin/ecschema-editing 4.5.0-dev.9 → 4.5.0
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.
- package/CHANGELOG.md +63 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +76 -0
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaConflicts.js +56 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +43 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +501 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -0
- package/lib/cjs/Differencing/SchemaDifference.d.ts +150 -0
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -0
- package/lib/cjs/Differencing/SchemaDifference.js +54 -0
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -0
- package/lib/cjs/Editing/ECClasses.d.ts +9 -2
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +25 -0
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +8 -2
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +29 -6
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +7 -1
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +15 -0
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +7 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +20 -1
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +1 -5
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +4 -3
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +57 -49
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +3 -2
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +22 -7
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +1 -5
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +21 -0
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PropertyMerger.js +315 -0
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -0
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +15 -0
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/RelationshipClassMerger.js +132 -0
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -0
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +7 -3
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +4 -0
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +4 -0
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +10 -10
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts +0 -15
- package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/AnyPropertyMerger.js +0 -71
- package/lib/cjs/Merging/AnyPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +0 -32
- package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/ArrayPropertyMerger.js +0 -143
- package/lib/cjs/Merging/ArrayPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts +0 -16
- package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/ClassPropertyMerger.js +0 -90
- package/lib/cjs/Merging/ClassPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +0 -24
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +0 -106
- package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +0 -1
- package/lib/cjs/Merging/StructPropertyMerger.d.ts +0 -11
- package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/StructPropertyMerger.js +0 -47
- package/lib/cjs/Merging/StructPropertyMerger.js.map +0 -1
|
@@ -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,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;gBACvD,OAAO,IAAI,CAAC;aACb;YACD,KAAK,WAAW,CAAC,CAAC;gBAChB,eAAe,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;aACb;YACD,KAAK,WAAW,CAAC,CAAC;gBAChB,eAAe,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;aACb;YACD,KAAK,UAAU,CAAC,CAAC;gBACf,eAAe,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;gBAC/C,OAAO,IAAI,CAAC;aACb;YACD,KAAK,UAAU,CAAC,CAAC;gBACf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,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"]}
|