@itwin/ecschema-editing 4.2.0-dev.3 → 4.2.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.
- package/CHANGELOG.md +56 -1
- package/lib/cjs/Merging/CAClassMerger.d.ts +7 -0
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/CAClassMerger.js +28 -0
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -0
- package/lib/cjs/Merging/ClassMerger.d.ts +7 -0
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/ClassMerger.js +59 -0
- package/lib/cjs/Merging/ClassMerger.js.map +1 -0
- package/lib/cjs/Merging/ConstantMerger.d.ts +12 -0
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/ConstantMerger.js +56 -0
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -0
- package/lib/cjs/Merging/EnumerationMerger.d.ts +12 -0
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/EnumerationMerger.js +83 -0
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -0
- package/lib/cjs/Merging/PhenomenonMerger.d.ts +7 -0
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PhenomenonMerger.js +16 -0
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +7 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.js +16 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -0
- package/lib/cjs/Merging/SchemaItemFactory.d.ts +8 -0
- package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaItemFactory.js +38 -0
- package/lib/cjs/Merging/SchemaItemFactory.js.map +1 -0
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +31 -0
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaItemMerger.js +90 -0
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -0
- package/lib/cjs/Merging/SchemaMerger.d.ts +36 -0
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaMerger.js +94 -0
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -0
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +10 -0
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaReferenceMerger.js +55 -0
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -0
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +4 -2
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +23 -19
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +9 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +4 -3
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +5 -0
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +7 -1
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
# Change Log - @itwin/ecschema-editing
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 12 Sep 2023 15:40:33 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.1.6
|
|
6
|
+
Tue, 12 Sep 2023 15:38:52 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.1.5
|
|
11
|
+
Fri, 08 Sep 2023 13:37:23 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 4.1.4
|
|
16
|
+
Thu, 07 Sep 2023 18:26:02 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.1.3
|
|
21
|
+
Wed, 30 Aug 2023 15:35:27 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 4.1.2
|
|
26
|
+
Wed, 23 Aug 2023 15:25:29 GMT
|
|
27
|
+
|
|
28
|
+
_Version update only_
|
|
29
|
+
|
|
30
|
+
## 4.1.1
|
|
31
|
+
Fri, 18 Aug 2023 13:02:53 GMT
|
|
32
|
+
|
|
33
|
+
_Version update only_
|
|
34
|
+
|
|
35
|
+
## 4.1.0
|
|
36
|
+
Mon, 14 Aug 2023 14:36:34 GMT
|
|
37
|
+
|
|
38
|
+
### Updates
|
|
39
|
+
|
|
40
|
+
- Add the ability to update the name of an EC Class via the ecschema-editing API.
|
|
41
|
+
- Added the ability to update the base class of an EC Class via the ecschema-editing API.
|
|
42
|
+
- Upgrade sinon to 15.0.4
|
|
43
|
+
- Switch to ESLint new flat config system
|
|
44
|
+
|
|
45
|
+
## 4.0.7
|
|
46
|
+
Thu, 10 Aug 2023 13:19:24 GMT
|
|
47
|
+
|
|
48
|
+
_Version update only_
|
|
4
49
|
|
|
5
50
|
## 4.0.6
|
|
6
51
|
Mon, 24 Jul 2023 05:07:33 GMT
|
|
@@ -41,6 +86,16 @@ Mon, 22 May 2023 15:34:14 GMT
|
|
|
41
86
|
- Update to eslint@8
|
|
42
87
|
- Removed obsolete EC rule 102 - Abstract class must have abstract base class.
|
|
43
88
|
|
|
89
|
+
## 3.7.13
|
|
90
|
+
Tue, 08 Aug 2023 19:49:18 GMT
|
|
91
|
+
|
|
92
|
+
_Version update only_
|
|
93
|
+
|
|
94
|
+
## 3.7.12
|
|
95
|
+
Thu, 27 Jul 2023 21:50:57 GMT
|
|
96
|
+
|
|
97
|
+
_Version update only_
|
|
98
|
+
|
|
44
99
|
## 3.7.11
|
|
45
100
|
Tue, 11 Jul 2023 17:17:21 GMT
|
|
46
101
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CustomAttributeClass } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export default function mergeCAClasses(target: CustomAttributeClass, source: CustomAttributeClass, changes: ClassChanges): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=CAClassMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CAClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAqC,MAAM,0BAA0B,CAAC;AAEnG,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAI3D;;GAEG;AACH,wBAA8B,cAAc,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,iBAc7H"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
9
|
+
const ClassMerger_1 = require("./ClassMerger");
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
async function mergeCAClasses(target, source, changes) {
|
|
14
|
+
const mutableCAClass = target;
|
|
15
|
+
await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutableCAClass, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
|
|
16
|
+
switch (propertyName) {
|
|
17
|
+
case "appliesTo": {
|
|
18
|
+
const containerType = (0, ecschema_metadata_1.parseCustomAttributeContainerType)(propertyValue);
|
|
19
|
+
if (containerType !== undefined) {
|
|
20
|
+
return item.setContainerType(containerType);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return (0, ClassMerger_1.default)(target, source, changes);
|
|
26
|
+
}
|
|
27
|
+
exports.default = mergeCAClasses;
|
|
28
|
+
//# sourceMappingURL=CAClassMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAmG;AAGnG,yDAA+D;AAC/D,+CAAyC;AAEzC;;GAEG;AACY,KAAK,UAAU,cAAc,CAAC,MAA4B,EAAE,MAA4B,EAAE,OAAqB;IAC5H,MAAM,cAAc,GAAG,MAAwB,CAAC;IAChD,MAAM,IAAA,4CAAyB,EAAC,cAAc,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QAClH,QAAO,YAAY,EAAE;YACnB,KAAK,WAAW,CAAC,CAAC;gBAChB,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,aAAa,CAAC,CAAC;gBACvE,IAAI,aAAa,KAAK,SAAS,EAAE;oBAC/B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;iBAC7C;aACF;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,qBAAY,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAdD,iCAcC","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 { CustomAttributeClass, parseCustomAttributeContainerType } from \"@itwin/ecschema-metadata\";\r\nimport { MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\r\nimport { ClassChanges } from \"../Validation/SchemaChanges\";\r\nimport { mergeSchemaItemProperties } from \"./SchemaItemMerger\";\r\nimport mergeClasses from \"./ClassMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default async function mergeCAClasses(target: CustomAttributeClass, source: CustomAttributeClass, changes: ClassChanges) {\r\n const mutableCAClass = target as MutableCAClass;\r\n await mergeSchemaItemProperties(mutableCAClass, changes.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n switch(propertyName) {\r\n case \"appliesTo\": {\r\n const containerType = parseCustomAttributeContainerType(propertyValue);\r\n if (containerType !== undefined) {\r\n return item.setContainerType(containerType);\r\n }\r\n }\r\n }\r\n });\r\n\r\n return mergeClasses(target, source, changes);\r\n}\r\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ECClass } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export default function mergeClasses(target: ECClass, source: ECClass, change: ClassChanges): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=ClassMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,OAAO,EAAoC,MAAM,0BAA0B,CAAC;AAE9G,OAAO,EAA8B,YAAY,EAAmB,MAAM,6BAA6B,CAAC;AAExG;;GAEG;AACH,wBAA8B,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,iBAQhG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
|
+
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
async function mergeClasses(target, source, change) {
|
|
13
|
+
// This applies to all type of classes regardless if they are Entities, Structs, Mixins,...
|
|
14
|
+
// all can have properties that required to get merged.
|
|
15
|
+
await mergeBaseClass(target, source, change.baseClassDelta);
|
|
16
|
+
for (const propertyChange of change.propertyChanges.values()) {
|
|
17
|
+
await mergeClassProperties(target, source, propertyChange);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = mergeClasses;
|
|
21
|
+
async function mergeBaseClass(target, source, baseClassChange) {
|
|
22
|
+
if (baseClassChange !== undefined) {
|
|
23
|
+
const sourceBaseClass = baseClassChange.diagnostic.messageArgs[0];
|
|
24
|
+
const targetBaseClass = baseClassChange.diagnostic.messageArgs[1];
|
|
25
|
+
if (targetBaseClass === undefined) {
|
|
26
|
+
const itemKey = sourceBaseClass.schema.schemaKey.matches(source.schema.schemaKey)
|
|
27
|
+
? new ecschema_metadata_1.SchemaItemKey(sourceBaseClass.name, target.schema.schemaKey)
|
|
28
|
+
: sourceBaseClass.key;
|
|
29
|
+
const baseClassEntity = await target.schema.context.getSchemaItem(itemKey);
|
|
30
|
+
if (baseClassEntity === undefined)
|
|
31
|
+
throw new Error(`Unable to locate base class ${sourceBaseClass.name} in schema ${target.schema.name}`);
|
|
32
|
+
const mutableTargetClass = target;
|
|
33
|
+
mutableTargetClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClassEntity.key, async () => baseClassEntity);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error(`Failed to merge base class '${sourceBaseClass.name}': not supported case`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function mergeClassProperties(target, source, propertyChange) {
|
|
41
|
+
const mutableTargetClass = target;
|
|
42
|
+
if (propertyChange.propertyMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
|
|
43
|
+
const property = await source.getProperty(propertyChange.ecTypeName);
|
|
44
|
+
if (property === undefined) {
|
|
45
|
+
throw Error(`Property '${propertyChange.ecTypeName}' not found in class ${source.name}`);
|
|
46
|
+
}
|
|
47
|
+
if (property.isPrimitive()) {
|
|
48
|
+
const primitiveProps = property.toJSON();
|
|
49
|
+
const result = property.isArray()
|
|
50
|
+
? await mutableTargetClass.createPrimitiveArrayProperty(propertyChange.ecTypeName, property.primitiveType)
|
|
51
|
+
: await mutableTargetClass.createPrimitiveProperty(propertyChange.ecTypeName, property.primitiveType);
|
|
52
|
+
await result.fromJSON(primitiveProps);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw Error(`Failed to merge '${propertyChange.ecTypeName}' property: not supported type`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ClassMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8G;AAE9G,+DAAwG;AAExG;;GAEG;AACY,KAAK,UAAU,YAAY,CAAC,MAAe,EAA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Ae,CAAsB,CAAC;SACnI;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,CAAC,IAAI,uBAAuB,CAAC,CAAC;SAC7F;KACF;AACH,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,MAAe,EAAE,MAAe,EAAE,cAA+B;IACnG,MAAM,kBAAkB,GAAG,MAAsB,CAAC;IAClD,IAAI,cAAc,CAAC,eAAe,EAAE,UAAU,KAAK,0BAAU,CAAC,OAAO,EAAE;QAErE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,KAAK,CAAC,aAAa,cAAc,CAAC,UAAU,wBAAwB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;SAC1F;QAED,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE;YAC1B,MAAM,cAAc,GAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE;gBAC/B,CAAC,CAAC,MAAM,kBAAkB,CAAC,4BAA4B,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,aAAa,CAAC;gBAC1G,CAAC,CAAC,MAAM,kBAAkB,CAAC,uBAAuB,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;YAExG,MAAM,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;SAEvC;aAAM;YACL,MAAM,KAAK,CAAC,oBAAoB,cAAc,CAAC,UAAU,gCAAgC,CAAC,CAAC;SAC5F;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 { DelayedPromiseWithProps, ECClass, LazyLoadedECClass, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport { BaseClassDelta, ChangeType, ClassChanges, PropertyChanges } from \"../Validation/SchemaChanges\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default async function mergeClasses(target: ECClass, source: ECClass, change: ClassChanges) {\r\n // This applies to all type of classes regardless if they are Entities, Structs, Mixins,...\r\n // all can have properties that required to get merged.\r\n await mergeBaseClass(target, source, change.baseClassDelta);\r\n\r\n for(const propertyChange of change.propertyChanges.values()) {\r\n await mergeClassProperties(target, source, propertyChange);\r\n }\r\n}\r\n\r\nasync function mergeBaseClass(target: ECClass, source: ECClass, baseClassChange?: BaseClassDelta) {\r\n if (baseClassChange !== undefined) {\r\n const sourceBaseClass = baseClassChange.diagnostic.messageArgs![0] as ECClass;\r\n const targetBaseClass = baseClassChange.diagnostic.messageArgs![1] as ECClass;\r\n\r\n if (targetBaseClass === undefined) {\r\n const itemKey = sourceBaseClass.schema.schemaKey.matches(source.schema.schemaKey)\r\n ? new SchemaItemKey(sourceBaseClass.name, target.schema.schemaKey)\r\n : sourceBaseClass.key;\r\n\r\n const baseClassEntity = await target.schema.context.getSchemaItem<ECClass>(itemKey);\r\n if (baseClassEntity === undefined)\r\n throw new Error(`Unable to locate base class ${sourceBaseClass.name} in schema ${target.schema.name}`);\r\n\r\n const mutableTargetClass = target as MutableClass;\r\n mutableTargetClass.baseClass = new DelayedPromiseWithProps(baseClassEntity.key, async () => baseClassEntity) as LazyLoadedECClass;\r\n } else {\r\n throw new Error(`Failed to merge base class '${sourceBaseClass.name}': not supported case`);\r\n }\r\n }\r\n}\r\n\r\nasync function mergeClassProperties(target: ECClass, source: ECClass, propertyChange: PropertyChanges) {\r\n const mutableTargetClass = target as MutableClass;\r\n if (propertyChange.propertyMissing?.changeType === ChangeType.Missing) {\r\n\r\n const property = await source.getProperty(propertyChange.ecTypeName);\r\n if (property === undefined) {\r\n throw Error(`Property '${propertyChange.ecTypeName}' not found in class ${source.name}`);\r\n }\r\n\r\n if (property.isPrimitive()) {\r\n const primitiveProps = property.toJSON();\r\n const result = property.isArray()\r\n ? await mutableTargetClass.createPrimitiveArrayProperty(propertyChange.ecTypeName, property.primitiveType)\r\n : await mutableTargetClass.createPrimitiveProperty(propertyChange.ecTypeName, property.primitiveType);\r\n\r\n await result.fromJSON(primitiveProps);\r\n\r\n } else {\r\n throw Error(`Failed to merge '${propertyChange.ecTypeName}' property: not supported type`);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Constant } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { SchemaItemChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* @param target The constant the differences get merged into
|
|
6
|
+
* @param source The constant to compare
|
|
7
|
+
* @param changes Gets the @see SchemaItemChanges between the two constants.
|
|
8
|
+
* For example, if source constant has an attribute/property that it missing in
|
|
9
|
+
* target one, it would be listed in propertyValueChanges.
|
|
10
|
+
*/
|
|
11
|
+
export default function mergeConstant(target: Constant, source: Constant, changes: SchemaItemChanges): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=ConstantMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConstantMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAA4E,MAAM,0BAA0B,CAAC;AAC9H,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAIhE;;;;;;;GAOG;AACH,wBAA8B,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,iBAuCzG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* @param target The constant the differences get merged into
|
|
12
|
+
* @param source The constant to compare
|
|
13
|
+
* @param changes Gets the @see SchemaItemChanges between the two constants.
|
|
14
|
+
* For example, if source constant has an attribute/property that it missing in
|
|
15
|
+
* target one, it would be listed in propertyValueChanges.
|
|
16
|
+
*/
|
|
17
|
+
async function mergeConstant(target, source, changes) {
|
|
18
|
+
const mutableConstant = target;
|
|
19
|
+
// Get referenced higher level phenomenon
|
|
20
|
+
const [refSchema, itemName] = await (0, SchemaItemMerger_1.getItemNameAndSchemaRef)(source, source.phenomenon.fullName);
|
|
21
|
+
await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutableConstant, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
|
|
22
|
+
switch (propertyName) {
|
|
23
|
+
case "definition": {
|
|
24
|
+
if (item.definition === "")
|
|
25
|
+
return item.setDefinition(propertyValue);
|
|
26
|
+
throw Error(`Failed to merged, constant definition conflict: ${propertyValue} -> ${item.definition}`);
|
|
27
|
+
}
|
|
28
|
+
case "numerator": {
|
|
29
|
+
if (!item.hasNumerator)
|
|
30
|
+
return item.setNumerator(propertyValue);
|
|
31
|
+
throw Error(`Failed to merged, constant numerator conflict: ${propertyValue} -> ${item.numerator}`);
|
|
32
|
+
}
|
|
33
|
+
case "denominator": {
|
|
34
|
+
if (!item.hasDenominator)
|
|
35
|
+
return item.setDenominator(propertyValue);
|
|
36
|
+
throw Error(`Failed to merged, constant denominator conflict: ${propertyValue} -> ${item.denominator}`);
|
|
37
|
+
}
|
|
38
|
+
case "phenomenon": {
|
|
39
|
+
if (item.phenomenon === undefined) {
|
|
40
|
+
// A lazy loaded phenomenon with the correct reference schema is needed, if reference schema is undefined then item schema.
|
|
41
|
+
const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, refSchema ? refSchema.schemaKey : target.schema.schemaKey);
|
|
42
|
+
const lazyTargetPhenomenon = new ecschema_metadata_1.DelayedPromiseWithProps(schemaItemKey, async () => {
|
|
43
|
+
const phenomenon = (await target.schema.context.getSchemaItem(schemaItemKey));
|
|
44
|
+
// At this point, higher level phenomenon item should not be undefined
|
|
45
|
+
if (phenomenon === undefined)
|
|
46
|
+
throw Error(`Unable to locate phenomenon item in schema ${schemaItemKey.schemaName}`);
|
|
47
|
+
return phenomenon;
|
|
48
|
+
});
|
|
49
|
+
return item.setPhenomenon(lazyTargetPhenomenon);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.default = mergeConstant;
|
|
56
|
+
//# sourceMappingURL=ConstantMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAA8H;AAE9H,yDAAwF;AAGxF;;;;;;;GAOG;AACY,KAAK,UAAU,aAAa,CAAC,MAAgB,EAAE,MAAgB,EAAE,OAA0B;IACxG,MAAM,eAAe,GAAG,MAAyB,CAAC;IAElD,yCAAyC;IACzC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,MAAM,IAAA,0CAAuB,EAAC,MAAM,EAAE,MAAM,CAAC,UAAW,CAAC,QAAQ,CAAC,CAAC;IAEjG,MAAM,IAAA,4CAAyB,EAAC,eAAe,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QACnH,QAAQ,YAAY,EAAE;YACpB,KA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C,CAAC,CAAC;oBACH,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;iBACjD;aACF;SACF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAvCD,gCAuCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Constant, DelayedPromiseWithProps, LazyLoadedPhenomenon, Phenomenon, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { getItemNameAndSchemaRef, mergeSchemaItemProperties } from \"./SchemaItemMerger\";\r\nimport { MutableConstant } from \"../Editing/Mutable/MutableConstant\";\r\n\r\n/**\r\n * @internal\r\n * @param target The constant the differences get merged into\r\n * @param source The constant to compare\r\n * @param changes Gets the @see SchemaItemChanges between the two constants.\r\n * For example, if source constant has an attribute/property that it missing in\r\n * target one, it would be listed in propertyValueChanges.\r\n */\r\nexport default async function mergeConstant(target: Constant, source: Constant, changes: SchemaItemChanges) {\r\n const mutableConstant = target as MutableConstant;\r\n\r\n // Get referenced higher level phenomenon\r\n const [refSchema, itemName] = await getItemNameAndSchemaRef(source, source.phenomenon!.fullName);\r\n\r\n await mergeSchemaItemProperties(mutableConstant, changes.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n switch (propertyName) {\r\n case \"definition\": {\r\n if (item.definition === \"\")\r\n return item.setDefinition(propertyValue);\r\n throw Error(`Failed to merged, constant definition conflict: ${propertyValue} -> ${item.definition}`);\r\n }\r\n case \"numerator\": {\r\n if (!item.hasNumerator)\r\n return item.setNumerator(propertyValue);\r\n throw Error(`Failed to merged, constant numerator conflict: ${propertyValue} -> ${item.numerator}`);\r\n }\r\n case \"denominator\": {\r\n if (!item.hasDenominator)\r\n return item.setDenominator(propertyValue);\r\n throw Error(`Failed to merged, constant denominator conflict: ${propertyValue} -> ${item.denominator}`);\r\n }\r\n case \"phenomenon\": {\r\n if (item.phenomenon === undefined) {\r\n // A lazy loaded phenomenon with the correct reference schema is needed, if reference schema is undefined then item schema.\r\n const schemaItemKey = new SchemaItemKey(itemName, refSchema ? refSchema.schemaKey : target.schema.schemaKey);\r\n const lazyTargetPhenomenon: LazyLoadedPhenomenon = new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(schemaItemKey, async () => {\r\n const phenomenon = (await target.schema.context.getSchemaItem<Phenomenon>(schemaItemKey));\r\n // At this point, higher level phenomenon item should not be undefined\r\n if (phenomenon === undefined)\r\n throw Error(`Unable to locate phenomenon item in schema ${schemaItemKey.schemaName}`);\r\n return phenomenon;\r\n });\r\n return item.setPhenomenon(lazyTargetPhenomenon);\r\n }\r\n }\r\n }\r\n });\r\n}\r\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Enumeration } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { EnumerationChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
/**
|
|
4
|
+
* @param target The Enumeration the differences get merged into
|
|
5
|
+
* @param source The Enumeration to compare
|
|
6
|
+
* @param changes Gets the @see EnumerationChanges between the two Enumerations.
|
|
7
|
+
* For example, if source Enumeration has an attribute that is undefined in
|
|
8
|
+
* target one, it would be listed in propertyValueChanges.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export default function mergeEnumeration(target: Enumeration, source: Enumeration, changes: EnumerationChanges): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=EnumerationMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,WAAW,EAA6C,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAc,kBAAkB,EAAmB,MAAM,6BAA6B,CAAC;AAsB9F;;;;;;;GAOG;AACH,wBAA8B,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB,iBA8CnH"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*---------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
5
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
8
|
+
const SchemaChanges_1 = require("../Validation/SchemaChanges");
|
|
9
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
10
|
+
/**
|
|
11
|
+
* @param target The Enumeration the differences get merged into
|
|
12
|
+
* @param source The Enumeration to compare
|
|
13
|
+
* @param changes Gets the @see EnumerationChanges between the two Enumerations.
|
|
14
|
+
* For example, if source Enumeration has an attribute that is undefined in
|
|
15
|
+
* target one, it would be listed in propertyValueChanges.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
async function mergeEnumeration(target, source, changes) {
|
|
19
|
+
const mutableEnumeration = target;
|
|
20
|
+
await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutableEnumeration, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
|
|
21
|
+
switch (propertyName) {
|
|
22
|
+
case "isStrict": return item.setIsStrict(propertyValue);
|
|
23
|
+
case "type": {
|
|
24
|
+
const primitiveType = (0, ecschema_metadata_1.parsePrimitiveType)(propertyValue);
|
|
25
|
+
if (primitiveType && item.type !== primitiveType) {
|
|
26
|
+
throw Error(`Merged enumeration ${item.name} types not equal: ${(0, ecschema_metadata_1.primitiveTypeToString)(item.type)} -> ${propertyValue}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
for (const enumeratorChange of changes.enumeratorChanges.values()) {
|
|
32
|
+
if (enumeratorChange.enumeratorMissing?.changeType === SchemaChanges_1.ChangeType.Missing) {
|
|
33
|
+
const enumerator = source.getEnumeratorByName(enumeratorChange.ecTypeName);
|
|
34
|
+
if (enumerator === undefined) {
|
|
35
|
+
throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in Enumeration ${source.fullName}`);
|
|
36
|
+
}
|
|
37
|
+
const result = mutableEnumeration.createEnumerator(enumerator.name, enumerator.value, enumerator.label, enumerator.description);
|
|
38
|
+
mutableEnumeration.addEnumerator(result);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const targetEnumerator = target.getEnumeratorByName(enumeratorChange.ecTypeName);
|
|
42
|
+
if (targetEnumerator === undefined) {
|
|
43
|
+
throw Error(`Enumerator '${enumeratorChange.ecTypeName}' not found in Enumeration ${target.fullName}`);
|
|
44
|
+
}
|
|
45
|
+
const mutableEnumerator = targetEnumerator;
|
|
46
|
+
await mergeEnumeratorAttributes(mutableEnumerator, enumeratorChange.enumeratorDeltas, (enumerator, attributeName, deltaChange, attributeValue) => {
|
|
47
|
+
switch (attributeName) {
|
|
48
|
+
case "label": {
|
|
49
|
+
enumerator.label = attributeValue;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
case "description": {
|
|
53
|
+
enumerator.description = attributeValue;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
case "value": {
|
|
57
|
+
throw Error(`Failed to merge enumerator attribute, ${deltaChange} in ${enumerator.name}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = mergeEnumeration;
|
|
65
|
+
/**
|
|
66
|
+
* Similar logic to mergeSchemaItemProperties but for EnumeratorDelta, which has the differences starting at index 1,
|
|
67
|
+
* hence the .slice(1), this is the main difference between mergeSchemaItemProperties.
|
|
68
|
+
* @param targetEnumerator The enumerator the differences get merged into.
|
|
69
|
+
* @param changes Gets the @see EnumeratorDelta, the Enumerator delta array holds information about changes between two Enumerators.
|
|
70
|
+
* @param handler Defines the information needed to merge the attributes.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
async function mergeEnumeratorAttributes(targetEnumerator, changes, handler) {
|
|
74
|
+
for (let index = 0, stepUp = true; index < changes.length; stepUp && index++, stepUp = true) {
|
|
75
|
+
const deltaChange = changes[index].toString(); // this will be useful for error message.
|
|
76
|
+
const [attributeName, attributeValue] = changes[index].diagnostic.messageArgs.slice(1); // messageArgs[0] seems to be an object, need to get to the next one, slice to start at index 1
|
|
77
|
+
if (handler(targetEnumerator, attributeName, deltaChange, attributeValue) === true) {
|
|
78
|
+
changes.splice(index, 1);
|
|
79
|
+
stepUp = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=EnumerationMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.js","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,gEAAiH;AACjH,+DAA8F;AAC9F,yDAA+D;AAqB/D;;;;;;;GAOG;AACY,KAAK,UAAU,gBAAgB,CAAC,MAAmB,EAAE,MAAmB,EAAE,OAA2B;IAClH,MAAM,kBAAkB,GAAG,MAA4B,CAAC;IAExD,MAAM,IAAA,4CAAyB,EAAC,kBAAkB,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QACtH,QAAQ,YAAY,EAAE;YACpB,KAAK,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YACxD,KAAK,MAAM,CAAC,CAAC;gBACX,MAAM,aAAa,GAAG,IAAA,sCAAkB,EAAC,aAAa,CAAC,CAAC;gBACxD,IAAI,aAAa,IA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AAE;oBACrB,KAAK,OAAO,CAAC,CAAC;wBACZ,UAAU,CAAC,KAAK,GAAG,cAAc,CAAC;wBAClC,OAAO;qBACR;oBACD,KAAK,aAAa,CAAC,CAAC;wBAClB,UAAU,CAAC,WAAW,GAAG,cAAc,CAAC;wBACxC,OAAO;qBACR;oBACD,KAAK,OAAO,CAAC,CAAC;wBACZ,MAAM,KAAK,CAAC,yCAAyC,WAAW,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;qBAC3F;iBACF;YACH,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AA9CD,mCA8CC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,yBAAyB,CAA0B,gBAAmB,EAAE,OAA0B,EAAE,OAAsC;IACvJ,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE;QAC3F,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,yCAAyC;QACxF,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Phenomenon } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { SchemaItemChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export default function mergePhenomenon(target: Phenomenon, source: Phenomenon, _changes?: SchemaItemChanges): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=PhenomenonMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;GAEG;AACH,wBAA8B,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,iBAAiB,iBAQjH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
async function mergePhenomenon(target, source, _changes) {
|
|
7
|
+
const mutablePhenomenon = target;
|
|
8
|
+
if (mutablePhenomenon.definition === "") {
|
|
9
|
+
await mutablePhenomenon.setDefinition(source.definition);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
throw Error(`Failed to merge schemas, definition attribute conflict: ${source.definition} -> ${target.definition}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = mergePhenomenon;
|
|
16
|
+
//# sourceMappingURL=PhenomenonMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":";;AAQA;;GAEG;AACY,KAAK,UAAU,eAAe,CAAC,MAAkB,EAAE,MAAkB,EAAE,QAA4B;IAChH,MAAM,iBAAiB,GAAG,MAA2B,CAAC;IAEtD,IAAG,iBAAiB,CAAC,UAAU,KAAK,EAAE,EAAC;QACrC,MAAM,iBAAiB,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAC1D;SAAI;QACH,MAAM,KAAK,CAAC,2DAA2D,MAAM,CAAC,UAAU,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;KACrH;AACH,CAAC;AARD,kCAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Phenomenon } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default async function mergePhenomenon(target: Phenomenon, source: Phenomenon, _changes?: SchemaItemChanges) {\r\n const mutablePhenomenon = target as MutablePhenomenon;\r\n\r\n if(mutablePhenomenon.definition === \"\"){\r\n await mutablePhenomenon.setDefinition(source.definition);\r\n }else{\r\n throw Error(`Failed to merge schemas, definition attribute conflict: ${source.definition} -> ${target.definition}`);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropertyCategory } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { SchemaItemChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export default function mergePropertyCategory(target: PropertyCategory, _source: PropertyCategory, changes: SchemaItemChanges): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=PropertyCategoryMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;GAEG;AACH,wBAA8B,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,iBAOlI"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
async function mergePropertyCategory(target, _source, changes) {
|
|
8
|
+
const mutablePropertyCategory = target;
|
|
9
|
+
await (0, SchemaItemMerger_1.mergeSchemaItemProperties)(mutablePropertyCategory, changes.propertyValueChanges, (item, propertyName, propertyValue) => {
|
|
10
|
+
switch (propertyName) {
|
|
11
|
+
case "priority": return item.setPriority(propertyValue);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.default = mergePropertyCategory;
|
|
16
|
+
//# sourceMappingURL=PropertyCategoryMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;AAOA,yDAA+D;AAE/D;;GAEG;AACY,KAAK,UAAU,qBAAqB,CAAC,MAAwB,EAAE,OAAyB,EAAE,OAA0B;IACjI,MAAM,uBAAuB,GAAG,MAAiC,CAAC;IAClE,MAAM,IAAA,4CAAyB,EAAC,uBAAuB,EAAE,OAAO,CAAC,oBAAoB,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE;QAC3H,QAAO,YAAY,EAAE;YACnB,KAAK,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;SACzD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,wCAOC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { PropertyCategory } from \"@itwin/ecschema-metadata\";\r\nimport { MutablePropertyCategory } from \"../Editing/Mutable/MutablePropertyCategory\";\r\nimport { SchemaItemChanges } from \"../Validation/SchemaChanges\";\r\nimport { mergeSchemaItemProperties } from \"./SchemaItemMerger\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport default async function mergePropertyCategory(target: PropertyCategory, _source: PropertyCategory, changes: SchemaItemChanges) {\r\n const mutablePropertyCategory = target as MutablePropertyCategory;\r\n await mergeSchemaItemProperties(mutablePropertyCategory, changes.propertyValueChanges, (item, propertyName, propertyValue) => {\r\n switch(propertyName) {\r\n case \"priority\": return item.setPriority(propertyValue);\r\n }\r\n });\r\n}\r\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema, SchemaItem } from "@itwin/ecschema-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace SchemaItemFactory {
|
|
6
|
+
function create(targetSchema: Schema, template: SchemaItem): Promise<SchemaItem>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=SchemaItemFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaItemFactory.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0F,MAAM,EAAE,UAAU,EAA2B,MAAM,0BAA0B,CAAC;AAE/K;;GAEG;AACH,yBAAiB,iBAAiB,CAAC;IAEjC,SAAsB,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAoB5F;CAKF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaItemFactory = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
var SchemaItemFactory;
|
|
13
|
+
(function (SchemaItemFactory) {
|
|
14
|
+
async function create(targetSchema, template) {
|
|
15
|
+
if (is(template, ecschema_metadata_1.Enumeration))
|
|
16
|
+
return new ecschema_metadata_1.Enumeration(targetSchema, template.name, template.type);
|
|
17
|
+
if (is(template, ecschema_metadata_1.EntityClass))
|
|
18
|
+
return new ecschema_metadata_1.EntityClass(targetSchema, template.name, template.modifier);
|
|
19
|
+
if (is(template, ecschema_metadata_1.StructClass))
|
|
20
|
+
return new ecschema_metadata_1.StructClass(targetSchema, template.name, template.modifier);
|
|
21
|
+
if (is(template, ecschema_metadata_1.CustomAttributeClass))
|
|
22
|
+
return new ecschema_metadata_1.CustomAttributeClass(targetSchema, template.name, template.modifier);
|
|
23
|
+
if (is(template, ecschema_metadata_1.PropertyCategory))
|
|
24
|
+
return new ecschema_metadata_1.PropertyCategory(targetSchema, template.name);
|
|
25
|
+
if (is(template, ecschema_metadata_1.Phenomenon))
|
|
26
|
+
return new ecschema_metadata_1.Phenomenon(targetSchema, template.name);
|
|
27
|
+
if (is(template, ecschema_metadata_1.Constant))
|
|
28
|
+
return new ecschema_metadata_1.Constant(targetSchema, template.name);
|
|
29
|
+
if (is(template, ecschema_metadata_1.UnitSystem))
|
|
30
|
+
return new ecschema_metadata_1.UnitSystem(targetSchema, template.name);
|
|
31
|
+
throw new Error(`Unsupported Schema Item Type: ${template.constructor.name}`);
|
|
32
|
+
}
|
|
33
|
+
SchemaItemFactory.create = create;
|
|
34
|
+
function is(item, type) {
|
|
35
|
+
return item instanceof type;
|
|
36
|
+
}
|
|
37
|
+
})(SchemaItemFactory = exports.SchemaItemFactory || (exports.SchemaItemFactory = {}));
|
|
38
|
+
//# sourceMappingURL=SchemaItemFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaItemFactory.js","sourceRoot":"","sources":["../../../src/Merging/SchemaItemFactory.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA+K;AAE/K;;GAEG;AACH,IAAiB,iBAAiB,CA2BjC;AA3BD,WAAiB,iBAAiB;IAEzB,KAAK,UAAU,MAAM,CAAC,YAAoB,EAAE,QAAoB;QACrE,IAAI,EAAE,CAAC,QAAQ,EAAE,+BAAW,CAAC;YAC3B,OAAO,IAAI,+BAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrE,IAAI,EAAE,CAAC,QAAQ,EAAE,+BAAW,CAAC;YAC3B,OAAO,IAAI,+BAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzE,IAAI,EAAE,CAAC,QAAQ,EAAE,+BAAW,CAAC;YAC3B,OAAO,IAAI,+BAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzE,IAAI,EAAE,CAAC,QAAQ,EAAE,wCAAoB,CAAC;YACpC,OAAO,IAAI,wCAAoB,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClF,IAAG,EAAE,CAAC,QAAQ,EAAE,oCAAgB,CAAC;YAC/B,OAAO,IAAI,oCAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,EAAE,CAAC,QAAQ,EAAE,8BAAU,CAAC;YAC1B,OAAO,IAAI,8BAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,EAAE,CAAC,QAAQ,EAAE,4BAAQ,CAAC;YACxB,OAAO,IAAI,4BAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,EAAE,CAAC,QAAQ,EAAE,8BAAU,CAAC;YAC1B,OAAO,IAAI,8BAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Schema, SchemaItem } from "@itwin/ecschema-metadata";
|
|
2
|
+
import { PropertyValueChange, SchemaItemChanges } from "../Validation/SchemaChanges";
|
|
3
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
4
|
+
type SchemaItemMergeFn<TChange extends SchemaItemChanges, TItem extends SchemaItem> = (target: TItem, source: TItem, change: TChange, context: SchemaMergeContext) => Promise<void>;
|
|
5
|
+
type PropertyChangedFn<TItem extends SchemaItem> = (item: TItem, propertyName: string, propertyValue: any) => void | boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Merges schema items from the source in the target schema. This method applies for all schema items
|
|
8
|
+
* and handles the basic processing such as create-if-not-exists or name collisions or base property setting.
|
|
9
|
+
* @param context The current merge context
|
|
10
|
+
* @param schemaItemChanges The schema items to be merged
|
|
11
|
+
* @param mergeFn Merge function for complex merging.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export default function mergeSchemaItems<TChange extends SchemaItemChanges, TItem extends SchemaItem>(context: SchemaMergeContext, schemaItemChanges: Iterable<TChange>, mergeFn?: SchemaItemMergeFn<TChange, TItem>): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Performs the specified action for each property in the given PropertyValueChange array.
|
|
17
|
+
* @param targetItem The target item
|
|
18
|
+
* @param changes The array with PropertyValueChanges
|
|
19
|
+
* @param handler The callback that gets invoked vor every change.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeSchemaItemProperties<T extends SchemaItem>(targetItem: T, changes: PropertyValueChange[], handler: PropertyChangedFn<T>): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* @param source The schema item the reference gets copied from
|
|
25
|
+
* @param itemFullName Parsing through item full name give us the schema reference name and the item name, these values are needed to create a new schema item key.
|
|
26
|
+
* @returns Item referenced schema and item name.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function getItemNameAndSchemaRef(source: SchemaItem, itemFullName: string): Promise<[Schema | undefined, string]>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=SchemaItemMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAc,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,KAAK,iBAAiB,CAAC,OAAO,SAAS,iBAAiB,EAAE,KAAK,SAAS,UAAU,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACpL,KAAK,iBAAiB,CAAC,KAAK,SAAS,UAAU,IAAI,CAAC,IAAI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