@itwin/ecschema-editing 4.6.0-dev.7 → 4.6.0-dev.9
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/lib/cjs/Differencing/SchemaConflicts.d.ts +2 -2
- package/lib/cjs/Differencing/SchemaConflicts.js +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +9 -6
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +213 -161
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +354 -78
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +184 -11
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +2 -0
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +2 -0
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.d.ts +4 -7
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +26 -23
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +10 -18
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +148 -155
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts +4 -8
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +59 -40
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +16 -13
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +66 -34
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +10 -7
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +41 -29
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.d.ts +9 -9
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +77 -48
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +4 -11
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +57 -53
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts +4 -7
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +24 -25
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts +8 -0
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PhenomenonMerger.js +37 -0
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +8 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.js +34 -0
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -0
- package/lib/cjs/Merging/PropertyMerger.d.ts +6 -14
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +212 -287
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +16 -10
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +121 -112
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +26 -51
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +106 -88
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +21 -9
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +74 -88
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +5 -5
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js +33 -15
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.d.ts +8 -0
- package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/UnitSystemMerger.js +26 -0
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -0
- package/lib/cjs/Validation/ECRules.js +1 -1
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js +1 -1
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +3 -3
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/package.json +9 -9
- package/lib/cjs/Merging/SchemaItemFactory.d.ts +0 -15
- package/lib/cjs/Merging/SchemaItemFactory.d.ts.map +0 -1
- package/lib/cjs/Merging/SchemaItemFactory.js +0 -82
- package/lib/cjs/Merging/SchemaItemFactory.js.map +0 -1
- package/lib/cjs/Merging/StructClassMerger.d.ts +0 -10
- package/lib/cjs/Merging/StructClassMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/StructClassMerger.js +0 -13
- package/lib/cjs/Merging/StructClassMerger.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConstantMerger.js","sourceRoot":"","sources":["../../../src/Merging/ConstantMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAuF;AAEvF,gEAAgH;AAEh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nF,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAa,SAAS,CAAC,CAAC;YAC3F,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,CAAC,QAAQ,yBAAyB,CAAC,CAAC;aAC3F;YAED,IAAI,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;SACzF;QACD,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;CACF,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 { type ConstantDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { type MutableConstant } from \"../Editing/Mutable/MutableConstant\";\r\nimport { DelayedPromiseWithProps, ECObjectsError, ECObjectsStatus, Phenomenon } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Defines a merge handler to merge Constant schema items.\r\n * @internal\r\n */\r\nexport const constantMerger: SchemaItemMergerHandler<ConstantDifference> = {\r\n async add(context, change) {\r\n if (change.difference.phenomenon === undefined) {\r\n return { errorMessage: \"Constant must define phenomenon\" };\r\n }\r\n if (change.difference.definition === undefined) {\r\n return { errorMessage: \"Constant must define definition\" };\r\n }\r\n\r\n // Needs to update the reference from source to target schema.\r\n const phenomenonKey = await updateSchemaItemKey(context, change.difference.phenomenon);\r\n change.difference.phenomenon = phenomenonKey.fullName;\r\n\r\n return context.editor.constants.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n phenomenon: change.difference.phenomenon,\r\n definition: change.difference.definition,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableConstant) {\r\n if (change.difference.label !== undefined) {\r\n item.setDisplayLabel(change.difference.label);\r\n }\r\n if (change.difference.description !== undefined) {\r\n item.setDescription(change.difference.description);\r\n }\r\n\r\n // Note: There are no editor methods to modify a constant.\r\n if (change.difference.definition !== undefined) {\r\n if (change.difference.definition !== \"\" && item.definition.toLowerCase() !== change.difference.definition.toLowerCase()) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Constant ${itemKey.name} has an invalid 'definition' attribute.`);\r\n }\r\n item.setDefinition(change.difference.definition);\r\n }\r\n if (change.difference.denominator !== undefined) {\r\n if (item.hasDenominator && item.denominator !== change.difference.denominator) {\r\n throw new Error(`Failed to merged, constant denominator conflict: ${change.difference.denominator} -> ${item.denominator}`);\r\n }\r\n item.setDenominator(change.difference.denominator);\r\n }\r\n if (change.difference.numerator !== undefined) {\r\n if (item.hasNumerator && item.numerator !== change.difference.numerator) {\r\n throw new Error(`Failed to merged, constant numerator conflict: ${change.difference.numerator} -> ${item.numerator}`);\r\n }\r\n item.setNumerator(change.difference.numerator);\r\n }\r\n if (change.difference.phenomenon !== undefined) {\r\n const lookupKey = await updateSchemaItemKey(context, change.difference.phenomenon);\r\n const phenomenon = await context.editor.schemaContext.getSchemaItem<Phenomenon>(lookupKey);\r\n if (phenomenon === undefined) {\r\n throw new Error(`Could not find phenomenon ${lookupKey.fullName} in the current context`);\r\n }\r\n\r\n item.setPhenomenon(new DelayedPromiseWithProps(phenomenon.key, async () => phenomenon));\r\n }\r\n return { itemKey };\r\n },\r\n};\r\n"]}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Merging
|
|
3
|
-
*/
|
|
4
1
|
import { CustomAttribute } from "@itwin/ecschema-metadata";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
import { type SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import { type CustomAttributeDifference } from "../Differencing/SchemaDifference";
|
|
4
|
+
import { type SchemaEditResults } from "../Editing/Editor";
|
|
5
|
+
type CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<SchemaEditResults>;
|
|
10
6
|
/**
|
|
11
7
|
* Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
|
|
12
8
|
* a scope (Class, Property, Schema) specific handler.
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
9
|
+
* @param context The current schema merging context.
|
|
10
|
+
* @param change The individual custom attribute change.
|
|
11
|
+
* @returns A EditResults object.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<SchemaEditResults>;
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<SchemaEditResults>;
|
|
19
|
+
/**
|
|
17
20
|
* @internal
|
|
18
21
|
*/
|
|
19
|
-
export declare function
|
|
22
|
+
export declare function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<SchemaEditResults>;
|
|
20
23
|
export {};
|
|
21
24
|
//# sourceMappingURL=CustomAttributeMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAA0D,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,KAAK,qBAAqB,GAAG,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA6CrI;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQxK;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAGpK"}
|
|
@@ -1,51 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyCustomAttribute = exports.applyCustomAttributes = exports.mergeCustomAttribute = void 0;
|
|
2
4
|
/*---------------------------------------------------------------------------------------------
|
|
3
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
7
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Merging
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.mergeCustomAttributes = void 0;
|
|
11
8
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
-
const
|
|
9
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
13
10
|
/**
|
|
14
11
|
* Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass
|
|
15
12
|
* a scope (Class, Property, Schema) specific handler.
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @
|
|
19
|
-
* @returns A EditResults object.
|
|
13
|
+
* @param context The current schema merging context.
|
|
14
|
+
* @param change The individual custom attribute change.
|
|
15
|
+
* @returns A EditResults object.
|
|
20
16
|
* @internal
|
|
21
17
|
*/
|
|
22
|
-
async function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
18
|
+
async function mergeCustomAttribute(context, change) {
|
|
19
|
+
if (change.changeType === "add") {
|
|
20
|
+
if (change.difference.className === undefined) {
|
|
21
|
+
return { errorMessage: "CustomAttribute instance must specify className" };
|
|
22
|
+
}
|
|
23
|
+
const schemaItemKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, change.difference.className);
|
|
24
|
+
const targetCustomAttributeClass = await context.targetSchema.lookupItem(schemaItemKey);
|
|
25
|
+
if (targetCustomAttributeClass === undefined) {
|
|
26
|
+
return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.` };
|
|
27
|
+
}
|
|
28
|
+
const caInstance = {
|
|
29
|
+
...change.difference,
|
|
30
|
+
className: schemaItemKey.fullName,
|
|
31
|
+
};
|
|
32
|
+
if (change.appliedTo === "Schema") {
|
|
33
|
+
return context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);
|
|
34
|
+
}
|
|
35
|
+
if (change.appliedTo === "SchemaItem") {
|
|
36
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
37
|
+
return context.editor.entities.addCustomAttribute(itemKey, caInstance);
|
|
38
|
+
}
|
|
39
|
+
if (change.appliedTo === "Property") {
|
|
40
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
41
|
+
const [propertyName] = change.path.split(".");
|
|
42
|
+
return context.editor.entities.addCustomAttributeToProperty(itemKey, propertyName, caInstance);
|
|
43
|
+
}
|
|
44
|
+
if (change.appliedTo === "RelationshipConstraint") {
|
|
45
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
46
|
+
const relationshipClass = await context.targetSchema.lookupItem(itemKey);
|
|
47
|
+
if (relationshipClass === undefined) {
|
|
48
|
+
return { errorMessage: `Unable to locate the relationship class ${itemKey.name} in the merged schema.` };
|
|
45
49
|
}
|
|
50
|
+
const constraint = change.path === "$source"
|
|
51
|
+
? relationshipClass.source
|
|
52
|
+
: relationshipClass.target;
|
|
53
|
+
return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);
|
|
54
|
+
}
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return { errorMessage: `Changes of Custom Attribute on merge is not implemented.` };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.mergeCustomAttribute = mergeCustomAttribute;
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
async function applyCustomAttributes(context, customAttributes, handler) {
|
|
66
|
+
for (const customAttribute of customAttributes) {
|
|
67
|
+
const result = await applyCustomAttribute(context, customAttribute, handler);
|
|
68
|
+
if (result.errorMessage) {
|
|
69
|
+
return result;
|
|
46
70
|
}
|
|
47
71
|
}
|
|
48
72
|
return {};
|
|
49
73
|
}
|
|
50
|
-
exports.
|
|
74
|
+
exports.applyCustomAttributes = applyCustomAttributes;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
async function applyCustomAttribute(context, customAttribute, handler) {
|
|
79
|
+
customAttribute.className = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, customAttribute.className);
|
|
80
|
+
return handler(customAttribute);
|
|
81
|
+
}
|
|
82
|
+
exports.applyCustomAttribute = applyCustomAttribute;
|
|
51
83
|
//# sourceMappingURL=CustomAttributeMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomAttributeMerger.js","sourceRoot":"","sources":["../../../src/Merging/CustomAttributeMerger.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAmH;AAInH,yDAAmF;AAInF;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,MAAiC;IACvG,IAAI,MAAM,CAAC,UAAU,KAAK,KAAK,EAAE;QAC/B,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE;YAC7C,OAAO,EAAE,YAAY,EAAE,iDAAiD,EAAE,CAAC;SAC5E;QACD,MAAM,aAAa,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAEtF,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC;QAC9G,IAAI,0BAA0B,KAAK,SAAS,EAAE;YAC5C,OAAO,EAAE,YAAY,EAAE,+CAA+C,aAAa,CAAC,IAAI,wBAAwB,EAAE,CAAC;SACpH;QAED,MAAM,UAAU,GAAoB;YAClC,GAAG,MAAM,CAAC,UAAU;YACpB,SAAS,EAAE,aAAa,CAAC,QAAQ;SAClC,CAAC;QAEF,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE;YACjC,OAAO,OAAO,CAAC,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,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SAC5F;QACD,OAAO,EAAE,CAAC;KACX;SAAM;QACL,OAAO,EAAE,YAAY,EAAE,0DAA0D,EAAE,CAAC;KACrF;AACH,CAAC;AA7CD,oDA6CC;AAED;;GAEG;AACI,KAAK,UAAU,qBAAqB,CAAC,OAA2B,EAAE,gBAAmC,EAAE,OAA8B;IAC1I,KAAK,MAAM,eAAe,IAAI,gBAAgB,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAC7E,IAAI,MAAM,CAAC,YAAY,EAAE;YACvB,OAAO,MAAM,CAAC;SACf;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AARD,sDAQC;AAED;;GAEG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,eAAgC,EAAE,OAA8B;IACtI,eAAe,CAAC,SAAS,GAAG,MAAM,IAAA,2CAAwB,EAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC;AAClC,CAAC;AAHD,oDAGC","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 { CustomAttribute, CustomAttributeClass, RelationshipClass, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { type SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { type CustomAttributeDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaEditResults } from \"../Editing/Editor\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\n\r\ntype CustomAttributeSetter = (customAttribute: CustomAttribute) => Promise<SchemaEditResults>;\r\n\r\n/**\r\n * Merges the custom attributes of the given changes iterable. The third parameter is a callback to pass\r\n * a scope (Class, Property, Schema) specific handler.\r\n * @param context The current schema merging context.\r\n * @param change The individual custom attribute change.\r\n * @returns A EditResults object.\r\n * @internal\r\n */\r\nexport async function mergeCustomAttribute(context: SchemaMergeContext, change: CustomAttributeDifference): Promise<SchemaEditResults> {\r\n if (change.changeType === \"add\") {\r\n if (change.difference.className === undefined) {\r\n return { errorMessage: \"CustomAttribute instance must specify className\" };\r\n }\r\n const schemaItemKey = await updateSchemaItemKey(context, change.difference.className);\r\n\r\n const targetCustomAttributeClass = await context.targetSchema.lookupItem<CustomAttributeClass>(schemaItemKey);\r\n if (targetCustomAttributeClass === undefined) {\r\n return { errorMessage: `Unable to locate the custom attribute class ${schemaItemKey.name} in the merged schema.` };\r\n }\r\n\r\n const caInstance: CustomAttribute = {\r\n ...change.difference,\r\n className: schemaItemKey.fullName,\r\n };\r\n\r\n if (change.appliedTo === \"Schema\") {\r\n return context.editor.addCustomAttribute(context.targetSchemaKey, caInstance);\r\n }\r\n if (change.appliedTo === \"SchemaItem\") {\r\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n return context.editor.entities.addCustomAttribute(itemKey, caInstance);\r\n }\r\n if (change.appliedTo === \"Property\") {\r\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n const [propertyName] = change.path.split(\".\");\r\n return context.editor.entities.addCustomAttributeToProperty(itemKey, propertyName, caInstance);\r\n }\r\n if (change.appliedTo === \"RelationshipConstraint\") {\r\n const itemKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n const relationshipClass = await context.targetSchema.lookupItem<RelationshipClass>(itemKey);\r\n if (relationshipClass === undefined) {\r\n return { errorMessage: `Unable to locate the relationship class ${itemKey.name} in the merged schema.` };\r\n }\r\n const constraint = change.path === \"$source\"\r\n ? relationshipClass.source\r\n : relationshipClass.target;\r\n\r\n return context.editor.relationships.addCustomAttributeToConstraint(constraint, caInstance);\r\n }\r\n return {};\r\n } else {\r\n return { errorMessage: `Changes of Custom Attribute on merge is not implemented.` };\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function applyCustomAttributes(context: SchemaMergeContext, customAttributes: CustomAttribute[], handler: CustomAttributeSetter): Promise<SchemaEditResults> {\r\n for (const customAttribute of customAttributes) {\r\n const result = await applyCustomAttribute(context, customAttribute, handler);\r\n if (result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n return {};\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function applyCustomAttribute(context: SchemaMergeContext, customAttribute: CustomAttribute, handler: CustomAttributeSetter): Promise<SchemaEditResults> {\r\n customAttribute.className = await updateSchemaItemFullName(context, customAttribute.className);\r\n return handler(customAttribute);\r\n}\r\n"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { type EntityClassDifference, EntityClassMixinDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
|
|
3
|
+
import { SchemaMergeContext } from "./SchemaMerger";
|
|
3
4
|
import { SchemaItemEditResults } from "../Editing/Editor";
|
|
4
|
-
import { ClassChanges } from "../Validation/SchemaChanges";
|
|
5
5
|
/**
|
|
6
|
+
* Defines a merge handler to merge Entity Class schema items.
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare const entityClassMerger: SchemaItemMergerHandler<EntityClassDifference>;
|
|
10
|
+
/**
|
|
11
|
+
* Merges Mixins to Entity Class schema items.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<SchemaItemEditResults>;
|
|
12
15
|
//# sourceMappingURL=EntityClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC1G,OAAO,EAAE,KAAK,uBAAuB,EAAuB,MAAM,oBAAoB,CAAC;AAIvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,CAAC,qBAAqB,CAsB5E,CAAC;AAEF;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CActI"}
|
|
@@ -1,41 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
3
|
+
exports.mergeClassMixins = exports.entityClassMerger = void 0;
|
|
4
|
+
const SchemaItemMerger_1 = require("./SchemaItemMerger");
|
|
8
5
|
const ClassMerger_1 = require("./ClassMerger");
|
|
9
|
-
const
|
|
6
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
10
7
|
/**
|
|
8
|
+
* Defines a merge handler to merge Entity Class schema items.
|
|
11
9
|
* @internal
|
|
12
10
|
*/
|
|
13
|
-
|
|
14
|
-
async
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
: mixin.schema.schemaKey);
|
|
29
|
-
const result = await this.context.editor.entities.addMixin(itemKey, mixinKey);
|
|
30
|
-
if (result.errorMessage !== undefined) {
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
11
|
+
exports.entityClassMerger = {
|
|
12
|
+
async add(context, change) {
|
|
13
|
+
return context.editor.entities.createFromProps(context.targetSchemaKey, {
|
|
14
|
+
name: change.itemName,
|
|
15
|
+
schemaItemType: change.schemaType,
|
|
16
|
+
...change.difference,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
async modify(context, change, itemKey, item) {
|
|
20
|
+
if (change.difference.mixins !== undefined) {
|
|
21
|
+
for (const mixin of change.difference.mixins) {
|
|
22
|
+
const mixinKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, mixin);
|
|
23
|
+
const result = await context.editor.entities.addMixin(itemKey, mixinKey);
|
|
24
|
+
if (result.errorMessage) {
|
|
25
|
+
return result;
|
|
34
26
|
}
|
|
35
27
|
}
|
|
36
28
|
}
|
|
37
|
-
return
|
|
29
|
+
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Merges Mixins to Entity Class schema items.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
async function mergeClassMixins(context, change) {
|
|
37
|
+
if (change.changeType === "add") {
|
|
38
|
+
for (const mixinFullName of change.difference) {
|
|
39
|
+
const mixinKey = await (0, SchemaItemMerger_1.updateSchemaItemKey)(context, mixinFullName);
|
|
40
|
+
const entityKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
41
|
+
const result = await context.editor.entities.addMixin(entityKey, mixinKey);
|
|
42
|
+
if (result.errorMessage) {
|
|
43
|
+
throw new Error(result.errorMessage);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return { errorMessage: `Changing the entity class '${change.itemName}' mixins is not supported.` };
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
|
-
exports.
|
|
52
|
+
exports.mergeClassMixins = mergeClassMixins;
|
|
41
53
|
//# sourceMappingURL=EntityClassMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/EntityClassMerger.ts"],"names":[],"mappings":";;;AAKA,yDAAuF;AAEvF,+CAA4C;AAC5C,gEAAyD;AAIzD;;;GAGG;AACU,QAAA,iBAAiB,GAAmD;IAC/E,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YACtE,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YAEjC,GAAG,MAAM,CAAC,UAAU;SACrB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAwB;QAC7D,IAAG,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE;YACzC,KAAI,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE;gBAC3C,MAAM,QAAQ,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBAC3D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBACzE,IAAG,MAAM,CAAC,YAAY,EAAE;oBACtB,OAAO,MAAM,CAAC;iBACf;aACF;SACF;QAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAAkC;IACpG,IAAG,MAAM,CAAC,UAAU,KAAK,KAAK,EAAE;QAC9B,KAAI,MAAM,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE;YAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACnE,MAAM,SAAS,GAAG,IAAI,iCAAa,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;YAC9E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC3E,IAAG,MAAM,CAAC,YAAY,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;aACtC;SACF;QACD,OAAO,EAAE,CAAC;KACX;SAAM;QACL,OAAO,EAAE,YAAY,EAAE,8BAA8B,MAAM,CAAC,QAAQ,4BAA4B,EAAC,CAAC;KACnG;AACH,CAAC;AAdD,4CAcC","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 { type EntityClassDifference, EntityClassMixinDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { type MutableEntityClass } from \"../Editing/Mutable/MutableEntityClass\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\n\r\n/**\r\n * Defines a merge handler to merge Entity Class schema items.\r\n * @internal\r\n */\r\nexport const entityClassMerger: SchemaItemMergerHandler<EntityClassDifference> = {\r\n async add(context, change) {\r\n return context.editor.entities.createFromProps(context.targetSchemaKey, {\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n\r\n ...change.difference,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableEntityClass) {\r\n if(change.difference.mixins !== undefined) {\r\n for(const mixin of change.difference.mixins) {\r\n const mixinKey = await updateSchemaItemKey(context, mixin);\r\n const result = await context.editor.entities.addMixin(itemKey, mixinKey);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return modifyClass(context, change, itemKey, item);\r\n },\r\n};\r\n\r\n/**\r\n * Merges Mixins to Entity Class schema items.\r\n * @internal\r\n */\r\nexport async function mergeClassMixins(context: SchemaMergeContext, change: EntityClassMixinDifference): Promise<SchemaItemEditResults> {\r\n if(change.changeType === \"add\") {\r\n for(const mixinFullName of change.difference) {\r\n const mixinKey = await updateSchemaItemKey(context, mixinFullName);\r\n const entityKey = new SchemaItemKey(change.itemName, context.targetSchemaKey);\r\n const result = await context.editor.entities.addMixin(entityKey, mixinKey);\r\n if(result.errorMessage) {\r\n throw new Error(result.errorMessage);\r\n }\r\n }\r\n return {};\r\n } else {\r\n return { errorMessage: `Changing the entity class '${change.itemName}' mixins is not supported.`};\r\n }\r\n}\r\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SchemaItemMerger } from "./SchemaItemMerger";
|
|
1
|
+
import type { EnumerationDifference, EnumeratorDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import type { SchemaItemMergerHandler } from "./SchemaItemMerger";
|
|
4
3
|
/**
|
|
4
|
+
* Defines a merge handler to merge Enumeration schema items.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export declare const enumerationMerger: SchemaItemMergerHandler<EnumerationDifference>;
|
|
8
|
+
/**
|
|
9
|
+
* Defines a merge handler to merge Enumeration schema items.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const enumeratorMerger: SchemaItemMergerHandler<EnumeratorDifference>;
|
|
13
13
|
//# sourceMappingURL=EnumerationMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnumerationMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/EnumerationMerger.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,CAAC,qBAAqB,CAoC5E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,uBAAuB,CAAC,oBAAoB,CAgC1E,CAAC"}
|
|
@@ -1,54 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.enumeratorMerger = exports.enumerationMerger = 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");
|
|
5
9
|
/**
|
|
10
|
+
* Defines a merge handler to merge Enumeration schema items.
|
|
6
11
|
* @internal
|
|
7
12
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
13
|
+
exports.enumerationMerger = {
|
|
14
|
+
async add(context, change) {
|
|
15
|
+
if (change.difference.type === undefined) {
|
|
16
|
+
return { errorMessage: "Enumerations must define a type property" };
|
|
17
|
+
}
|
|
18
|
+
if (change.difference.isStrict === undefined) {
|
|
19
|
+
return { errorMessage: "Enumerations must define whether enumeration is strict." };
|
|
20
|
+
}
|
|
21
|
+
if (change.difference.enumerators === undefined) {
|
|
22
|
+
return { errorMessage: "Enumerations must define at least ine enumerator." };
|
|
23
|
+
}
|
|
24
|
+
return context.editor.enumerations.createFromProps(context.targetSchemaKey, {
|
|
25
|
+
...change.difference,
|
|
26
|
+
name: change.itemName,
|
|
27
|
+
schemaItemType: change.schemaType,
|
|
28
|
+
type: change.difference.type,
|
|
29
|
+
isStrict: change.difference.isStrict,
|
|
30
|
+
enumerators: change.difference.enumerators,
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
async modify(_context, change, itemKey, item) {
|
|
34
|
+
if (change.difference.type !== undefined) {
|
|
35
|
+
return { errorMessage: `The Enumeration ${itemKey.name} has an incompatible type. It must be "${(0, ecschema_metadata_1.primitiveTypeToString)(item.type)}", not "${change.difference.type}".` };
|
|
36
|
+
}
|
|
37
|
+
if (change.difference.label !== undefined) {
|
|
38
|
+
item.setDisplayLabel(change.difference.label);
|
|
39
|
+
}
|
|
40
|
+
if (change.difference.description !== undefined) {
|
|
41
|
+
item.setDescription(change.difference.description);
|
|
42
|
+
}
|
|
43
|
+
if (change.difference.isStrict !== undefined) {
|
|
44
|
+
item.setIsStrict(change.difference.isStrict);
|
|
45
|
+
}
|
|
46
|
+
return { itemKey };
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Defines a merge handler to merge Enumeration schema items.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
exports.enumeratorMerger = {
|
|
54
|
+
async add(context, change) {
|
|
55
|
+
if (change.difference.name === undefined) {
|
|
56
|
+
return { errorMessage: "Enumerators must define a name" };
|
|
57
|
+
}
|
|
58
|
+
if (change.difference.value === undefined) {
|
|
59
|
+
return { errorMessage: "Enumerators must define a value" };
|
|
60
|
+
}
|
|
61
|
+
const itemKey = new ecschema_metadata_1.SchemaItemKey(change.itemName, context.targetSchemaKey);
|
|
62
|
+
await context.editor.enumerations.addEnumerator(itemKey, {
|
|
63
|
+
name: change.difference.name,
|
|
64
|
+
value: change.difference.value,
|
|
65
|
+
label: change.difference.label,
|
|
66
|
+
description: change.difference.description,
|
|
67
|
+
});
|
|
68
|
+
return { itemKey };
|
|
69
|
+
},
|
|
70
|
+
async modify(context, change, itemKey) {
|
|
71
|
+
if (change.difference.value !== undefined) {
|
|
72
|
+
return { errorMessage: `Failed to merge enumerator attribute, Enumerator "${change.path}" has different values.` };
|
|
73
|
+
}
|
|
74
|
+
if (change.difference.description !== undefined) {
|
|
75
|
+
await context.editor.enumerations.setEnumeratorDescription(itemKey, change.path, change.difference.description);
|
|
76
|
+
}
|
|
77
|
+
if (change.difference.label !== undefined) {
|
|
78
|
+
await context.editor.enumerations.setEnumeratorLabel(itemKey, change.path, change.difference.label);
|
|
79
|
+
}
|
|
80
|
+
return { itemKey };
|
|
81
|
+
},
|
|
82
|
+
};
|
|
54
83
|
//# sourceMappingURL=EnumerationMerger.js.map
|