@itwin/ecschema-editing 4.10.0-dev.1 → 4.10.0-dev.10
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 +14 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +1 -0
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js +1 -0
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +2 -2
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +26 -4
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts +7 -4
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +28 -25
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Differencing/Utils.d.ts +2 -2
- package/lib/cjs/Differencing/Utils.d.ts.map +1 -1
- package/lib/cjs/Differencing/Utils.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +4 -0
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +2 -6
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +12 -82
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts +10 -4
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +58 -54
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.d.ts +14 -0
- package/lib/cjs/Merging/CustomAttributeClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/CustomAttributeClassMerger.js +41 -0
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -0
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +2 -6
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +39 -48
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +11 -6
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +32 -32
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.d.ts +7 -6
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +39 -67
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.d.ts +14 -0
- package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/EnumeratorMerger.js +41 -0
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +10 -4
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +51 -46
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts +10 -4
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +30 -25
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts +10 -4
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +34 -29
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +10 -4
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js +30 -27
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +2 -2
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +10 -10
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +8 -4
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +40 -40
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +16 -45
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +138 -0
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaMergingVisitor.js +309 -0
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -0
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts +19 -0
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js +62 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -0
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +9 -6
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js +28 -37
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.d.ts +14 -0
- package/lib/cjs/Merging/StructClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/StructClassMerger.js +25 -0
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -0
- package/lib/cjs/Merging/UnitSystemMerger.d.ts +10 -4
- package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js +23 -19
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.d.ts +18 -0
- package/lib/cjs/Merging/Utils.d.ts.map +1 -0
- package/lib/cjs/Merging/Utils.js +56 -0
- package/lib/cjs/Merging/Utils.js.map +1 -0
- package/package.json +9 -9
- package/lib/cjs/Merging/CAClassMerger.d.ts +0 -8
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/CAClassMerger.js +0 -36
- package/lib/cjs/Merging/CAClassMerger.js.map +0 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +0 -35
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +0 -121
- package/lib/cjs/Merging/SchemaItemMerger.js.map +0 -1
|
@@ -1,55 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.modifyKindOfQuantity = exports.addKindOfQuantity = void 0;
|
|
4
|
+
const Utils_1 = require("./Utils");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Merges a new KindOfQuantity into the target schema.
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (change.difference.presentationUnits) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);
|
|
9
|
+
async function addKindOfQuantity(context, change) {
|
|
10
|
+
if (change.difference.persistenceUnit === undefined) {
|
|
11
|
+
throw new Error("KindOfQuantity must define persistenceUnit");
|
|
12
|
+
}
|
|
13
|
+
if (change.difference.relativeError === undefined) {
|
|
14
|
+
throw new Error("KindOfQuantity must define relativeError");
|
|
15
|
+
}
|
|
16
|
+
change.difference.persistenceUnit = await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.persistenceUnit);
|
|
17
|
+
if (change.difference.presentationUnits) {
|
|
18
|
+
if (Array.isArray(change.difference.presentationUnits)) {
|
|
19
|
+
for (let index = 0; index < change.difference.presentationUnits.length; index++) {
|
|
20
|
+
change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
name: change.itemName,
|
|
31
|
-
schemaItemType: change.schemaType,
|
|
32
|
-
persistenceUnit: change.difference.persistenceUnit,
|
|
33
|
-
presentationUnits: change.difference.presentationUnits,
|
|
34
|
-
relativeError: change.difference.relativeError,
|
|
35
|
-
});
|
|
36
|
-
},
|
|
37
|
-
async modify(_context, change, itemKey, item) {
|
|
38
|
-
if (change.difference.label !== undefined) {
|
|
39
|
-
item.setDisplayLabel(change.difference.label);
|
|
23
|
+
else {
|
|
24
|
+
change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);
|
|
40
25
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
}
|
|
27
|
+
await context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {
|
|
28
|
+
...change.difference,
|
|
29
|
+
name: change.itemName,
|
|
30
|
+
schemaItemType: change.schemaType,
|
|
31
|
+
persistenceUnit: change.difference.persistenceUnit,
|
|
32
|
+
presentationUnits: change.difference.presentationUnits,
|
|
33
|
+
relativeError: change.difference.relativeError,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.addKindOfQuantity = addKindOfQuantity;
|
|
37
|
+
/**
|
|
38
|
+
* Merges differences to an existing KindOfQuantity in the target schema.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
async function modifyKindOfQuantity(context, change, itemKey) {
|
|
42
|
+
const kindOfQuantity = await context.targetSchema.lookupItem(itemKey);
|
|
43
|
+
if (change.difference.label !== undefined) {
|
|
44
|
+
await context.editor.kindOfQuantities.setDisplayLabel(itemKey, change.difference.label);
|
|
45
|
+
}
|
|
46
|
+
if (change.difference.description !== undefined) {
|
|
47
|
+
await context.editor.kindOfQuantities.setDescription(itemKey, change.difference.description);
|
|
48
|
+
}
|
|
49
|
+
if (change.difference.relativeError !== undefined) {
|
|
50
|
+
kindOfQuantity.setRelativeError(change.difference.relativeError);
|
|
51
|
+
}
|
|
52
|
+
if (change.difference.persistenceUnit !== undefined) {
|
|
53
|
+
// TODO: It should be checked if the unit is the same, but referring to the source schema.
|
|
54
|
+
throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.modifyKindOfQuantity = modifyKindOfQuantity;
|
|
53
58
|
async function updateOverrideFormat(context, formatString) {
|
|
54
59
|
// https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string
|
|
55
60
|
const match = formatString.match(/^([^(]+)\((\d+)\)\[(.*)\]$/);
|
|
@@ -57,11 +62,11 @@ async function updateOverrideFormat(context, formatString) {
|
|
|
57
62
|
return formatString;
|
|
58
63
|
}
|
|
59
64
|
const originalFormat = match[1];
|
|
60
|
-
const updatedFormat = await (0,
|
|
65
|
+
const updatedFormat = await (0, Utils_1.updateSchemaItemFullName)(context, originalFormat);
|
|
61
66
|
const unitOverrides = match[3].split("][");
|
|
62
67
|
for (let index = 0; index < unitOverrides.length; index++) {
|
|
63
68
|
const [unit, label] = unitOverrides[index].split("|");
|
|
64
|
-
const updatedUnit = await (0,
|
|
69
|
+
const updatedUnit = await (0, Utils_1.updateSchemaItemFullName)(context, unit);
|
|
65
70
|
unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : ""}`;
|
|
66
71
|
}
|
|
67
72
|
return `${updatedFormat}(${match[2]})[${unitOverrides.join("][")}]`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":";;;AAQA,mCAAmD;AAEnD;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAAgC;IACnG,IAAI,MAAM,CAAC,UAAU,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAC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I,IAAI,KAAK,GAAC,CAAC,EAAE,KAAK,GAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClE,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrE,CAAC;IAED,OAAO,GAAG,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AACtE,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 { KindOfQuantityDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName } from \"./Utils\";\r\n\r\n/**\r\n * Merges a new KindOfQuantity into the target schema.\r\n * @internal\r\n */\r\nexport async function addKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference) {\r\n if (change.difference.persistenceUnit === undefined) {\r\n throw new Error(\"KindOfQuantity must define persistenceUnit\");\r\n }\r\n if (change.difference.relativeError === undefined) {\r\n throw new Error(\"KindOfQuantity must define relativeError\");\r\n }\r\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\r\n if(change.difference.presentationUnits) {\r\n if(Array.isArray(change.difference.presentationUnits)) {\r\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\r\n change.difference.presentationUnits[index] = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\r\n }\r\n } else {\r\n change.difference.presentationUnits = await updateOverrideFormat(context, change.difference.presentationUnits);\r\n }\r\n }\r\n\r\n await context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n persistenceUnit: change.difference.persistenceUnit,\r\n presentationUnits: change.difference.presentationUnits,\r\n relativeError: change.difference.relativeError,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing KindOfQuantity in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference, itemKey: SchemaItemKey) {\r\n const kindOfQuantity = await context.targetSchema.lookupItem(itemKey) as MutableKindOfQuantity;\r\n if(change.difference.label !== undefined) {\r\n await context.editor.kindOfQuantities.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.kindOfQuantities.setDescription(itemKey, change.difference.description);\r\n }\r\n if(change.difference.relativeError !== undefined) {\r\n kindOfQuantity.setRelativeError(change.difference.relativeError);\r\n }\r\n if(change.difference.persistenceUnit !== undefined) {\r\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\r\n throw new Error(`Changing the kind of quantity '${itemKey.name}' persistenceUnit is not supported.`);\r\n }\r\n}\r\n\r\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string) {\r\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\r\n const match = formatString.match(/^([^(]+)\\((\\d+)\\)\\[(.*)\\]$/);\r\n if(match === null) {\r\n return formatString;\r\n }\r\n\r\n const originalFormat = match[1];\r\n const updatedFormat = await updateSchemaItemFullName(context, originalFormat);\r\n\r\n const unitOverrides = match[3].split(\"][\");\r\n for(let index=0; index< unitOverrides.length; index++) {\r\n const [unit, label] = unitOverrides[index].split(\"|\");\r\n const updatedUnit = await updateSchemaItemFullName(context, unit);\r\n unitOverrides[index] = `${updatedUnit}${label ? `|${label}` : \"\"}`;\r\n }\r\n\r\n return `${updatedFormat}(${match[2]})[${unitOverrides.join(\"][\")}]`;\r\n}\r\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { MixinClassDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import type { SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Merges a new Mixin into the target schema.
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
+
export declare function addMixinClass(context: SchemaMergeContext, change: MixinClassDifference): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Merges differences to an existing Mixin in the target schema.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function modifyMixinClass(context: SchemaMergeContext, change: MixinClassDifference, itemKey: SchemaItemKey): Promise<void>;
|
|
8
14
|
//# sourceMappingURL=MixinMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MixinMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAU5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAWvH"}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.modifyMixinClass = exports.addMixinClass = void 0;
|
|
4
|
+
const Utils_1 = require("./Utils");
|
|
5
5
|
const ClassMerger_1 = require("./ClassMerger");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Merges a new Mixin into the target schema.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
async function addMixinClass(context, change) {
|
|
11
|
+
if (change.difference.appliesTo === undefined) {
|
|
12
|
+
throw new Error("Mixin must define appliesTo");
|
|
13
|
+
}
|
|
14
|
+
await context.editor.mixins.createFromProps(context.targetSchemaKey, {
|
|
15
|
+
...change.difference,
|
|
16
|
+
name: change.itemName,
|
|
17
|
+
schemaItemType: change.schemaType,
|
|
18
|
+
appliesTo: await (0, Utils_1.updateSchemaItemFullName)(context, change.difference.appliesTo),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.addMixinClass = addMixinClass;
|
|
22
|
+
/**
|
|
23
|
+
* Merges differences to an existing Mixin in the target schema.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
async function modifyMixinClass(context, change, itemKey) {
|
|
27
|
+
const mixin = await context.targetSchema.lookupItem(itemKey);
|
|
28
|
+
if (change.difference.appliesTo !== undefined) {
|
|
29
|
+
const appliesTo = await (0, Utils_1.updateSchemaItemKey)(context, change.difference.appliesTo);
|
|
30
|
+
const currentValue = await mixin.appliesTo;
|
|
31
|
+
if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {
|
|
32
|
+
throw new Error(`Changing the mixin '${itemKey.name}' appliesTo is not supported.`);
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
34
|
+
}
|
|
35
|
+
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, mixin);
|
|
36
|
+
}
|
|
37
|
+
exports.modifyMixinClass = modifyMixinClass;
|
|
33
38
|
//# sourceMappingURL=MixinMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"MixinMerger.js","sourceRoot":"","sources":["../../../src/Merging/MixinMerger.ts"],"names":[],"mappings":";;;AAQA,mCAAwE;AACxE,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACnE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,SAAS,EAAE,MAAM,IAAA,gCAAwB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AAVD,sCAUC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC7E,IAAG,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClF,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC;QAC3C,IAAI,YAAY,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,uBAAuB,OAAO,CAAC,IAAI,+BAA+B,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC;AAXD,4CAWC","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 { MixinClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableMixin } from \"../Editing/Mutable/MutableMixin\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new Mixin into the target schema.\r\n * @internal\r\n */\r\nexport async function addMixinClass(context: SchemaMergeContext, change: MixinClassDifference) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"Mixin must define appliesTo\");\r\n }\r\n await context.editor.mixins.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: await updateSchemaItemFullName(context, change.difference.appliesTo),\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Mixin in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyMixinClass(context: SchemaMergeContext, change: MixinClassDifference, itemKey: SchemaItemKey) {\r\n const mixin = await context.targetSchema.lookupItem(itemKey) as MutableMixin;\r\n if(change.difference.appliesTo !== undefined) {\r\n const appliesTo = await updateSchemaItemKey(context, change.difference.appliesTo);\r\n const currentValue = await mixin.appliesTo;\r\n if (currentValue !== undefined && !appliesTo.matches(currentValue.key)) {\r\n throw new Error(`Changing the mixin '${itemKey.name}' appliesTo is not supported.`);\r\n }\r\n }\r\n\r\n return modifyClass(context, change, itemKey, mixin);\r\n}\r\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { PhenomenonDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import { type SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Merges a new Phenomenon into the target schema.
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
+
export declare function addPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Merges differences to an existing Phenomenon in the target schema.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function modifyPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference, itemKey: SchemaItemKey): Promise<void>;
|
|
8
14
|
//# sourceMappingURL=PhenomenonMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE/F;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAW5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAgBvH"}
|
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.modifyPhenomenon = exports.addPhenomenon = void 0;
|
|
4
4
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Merges a new Phenomenon into the target schema.
|
|
7
7
|
* @internal
|
|
8
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
|
-
|
|
9
|
+
async function addPhenomenon(context, change) {
|
|
10
|
+
if (change.difference.definition === undefined) {
|
|
11
|
+
throw new Error("Phenomenon must define definition");
|
|
12
|
+
}
|
|
13
|
+
await context.editor.phenomenons.createFromProps(context.targetSchemaKey, {
|
|
14
|
+
...change.difference,
|
|
15
|
+
name: change.itemName,
|
|
16
|
+
schemaItemType: change.schemaType,
|
|
17
|
+
definition: change.difference.definition,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.addPhenomenon = addPhenomenon;
|
|
21
|
+
/**
|
|
22
|
+
* Merges differences to an existing Phenomenon in the target schema.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
async function modifyPhenomenon(context, change, itemKey) {
|
|
26
|
+
const phenomenon = await context.targetSchema.lookupItem(itemKey);
|
|
27
|
+
if (change.difference.label !== undefined) {
|
|
28
|
+
await context.editor.phenomenons.setDisplayLabel(itemKey, change.difference.label);
|
|
29
|
+
}
|
|
30
|
+
if (change.difference.description !== undefined) {
|
|
31
|
+
await context.editor.phenomenons.setDescription(itemKey, change.difference.description);
|
|
32
|
+
}
|
|
33
|
+
if (change.difference.definition !== undefined) {
|
|
34
|
+
// It would be better if the validation would be part of phenomenon.setDefinition.
|
|
35
|
+
if (phenomenon.definition !== "" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())
|
|
36
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);
|
|
37
|
+
await phenomenon.setDefinition(change.difference.definition);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.modifyPhenomenon = modifyPhenomenon;
|
|
36
41
|
//# sourceMappingURL=PhenomenonMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":";;;AAOA,
|
|
1
|
+
{"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/Phen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AAW,EAAE,KAAK,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;YACpH,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,kBAAkB,OAAO,CAAC,IAAI,yCAAyC,CAAC,CAAC;QAEnI,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAhBD,4CAgBC","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 { PhenomenonDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECObjectsError, ECObjectsStatus, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new Phenomenon into the target schema.\r\n * @internal\r\n */\r\nexport async function addPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference) {\r\n if (change.difference.definition === undefined) {\r\n throw new Error(\"Phenomenon must define definition\");\r\n }\r\n\r\n await context.editor.phenomenons.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n definition: change.difference.definition,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing Phenomenon in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference, itemKey: SchemaItemKey) {\r\n const phenomenon = await context.targetSchema.lookupItem(itemKey) as MutablePhenomenon;\r\n if(change.difference.label !== undefined) {\r\n await context.editor.phenomenons.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.phenomenons.setDescription(itemKey, change.difference.description);\r\n }\r\n\r\n if(change.difference.definition !== undefined) {\r\n // It would be better if the validation would be part of phenomenon.setDefinition.\r\n if (phenomenon.definition !== \"\" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `The Phenomenon ${itemKey.name} has an invalid 'definition' attribute.`);\r\n\r\n await phenomenon.setDefinition(change.difference.definition);\r\n }\r\n}\r\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { PropertyCategoryDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import type { SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Merges a new PropertyCategory into the target schema.
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
+
export declare function addPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Merges differences to an existing PropertyCategory in the target schema.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function modifyPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference, itemKey: SchemaItemKey): Promise<void>;
|
|
8
14
|
//# sourceMappingURL=PropertyCategoryMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PropertyCategoryMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,0BAA0B,iBAWxG;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,0BAA0B,EAAE,OAAO,EAAE,aAAa,iBAUnI"}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.modifyPropertyCategory = exports.addPropertyCategory = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Merges a new PropertyCategory into the target schema.
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
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
|
-
|
|
8
|
+
async function addPropertyCategory(context, change) {
|
|
9
|
+
if (change.difference.priority === undefined) {
|
|
10
|
+
throw new Error("PropertyCategory must define priority");
|
|
11
|
+
}
|
|
12
|
+
await context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {
|
|
13
|
+
...change.difference,
|
|
14
|
+
name: change.itemName,
|
|
15
|
+
schemaItemType: change.schemaType,
|
|
16
|
+
priority: change.difference.priority,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.addPropertyCategory = addPropertyCategory;
|
|
20
|
+
/**
|
|
21
|
+
* Merges differences to an existing PropertyCategory in the target schema.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
async function modifyPropertyCategory(context, change, itemKey) {
|
|
25
|
+
if (change.difference.label !== undefined) {
|
|
26
|
+
await context.editor.propertyCategories.setDisplayLabel(itemKey, change.difference.label);
|
|
27
|
+
}
|
|
28
|
+
if (change.difference.description !== undefined) {
|
|
29
|
+
await context.editor.propertyCategories.setDescription(itemKey, change.difference.description);
|
|
30
|
+
}
|
|
31
|
+
if (change.difference.priority !== undefined) {
|
|
32
|
+
await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.modifyPropertyCategory = modifyPropertyCategory;
|
|
33
36
|
//# sourceMappingURL=PropertyCategoryMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"PropertyCategoryMerger.js","sourceRoot":"","sources":["../../../src/Merging/PropertyCategoryMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,MAAkC;IACvG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QAC/E,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;QACjC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;KACrC,CAAC,CAAC;AACL,CAAC;AAXD,kDAWC;AAED;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CAAC,OAA2B,EAAE,MAAkC,EAAE,OAAsB;IAClI,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC5F,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACjG,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC;AAVD,wDAUC","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 { PropertyCategoryDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new PropertyCategory into the target schema.\r\n * @internal\r\n */\r\nexport async function addPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference) {\r\n if (change.difference.priority === undefined) {\r\n throw new Error(\"PropertyCategory must define priority\");\r\n }\r\n\r\n await context.editor.propertyCategories.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n priority: change.difference.priority,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing PropertyCategory in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyPropertyCategory(context: SchemaMergeContext, change: PropertyCategoryDifference, itemKey: SchemaItemKey) {\r\n if(change.difference.label !== undefined) {\r\n await context.editor.propertyCategories.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.propertyCategories.setDescription(itemKey, change.difference.description);\r\n }\r\n if(change.difference.priority !== undefined) {\r\n await context.editor.propertyCategories.setPriority(itemKey, change.difference.priority);\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyClassItemDifference, ClassPropertyDifference } from "../Differencing/SchemaDifference";
|
|
3
3
|
import { SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
@@ -8,5 +8,5 @@ export declare function mergePropertyDifference(context: SchemaMergeContext, cha
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export declare function mergeClassProperties(context: SchemaMergeContext, change:
|
|
11
|
+
export declare function mergeClassProperties(context: SchemaMergeContext, change: AnyClassItemDifference, itemKey: SchemaItemKey): Promise<void>;
|
|
12
12
|
//# sourceMappingURL=PropertyMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"PropertyMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PropertyMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AACxH,OAAO,EAA8M,aAAa,EAAoD,MAAM,0BAA0B,CAAC;AAgBvT;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzH;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7I"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeClassProperties = exports.mergePropertyDifference = void 0;
|
|
4
4
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
|
-
const
|
|
5
|
+
const Utils_1 = require("./Utils");
|
|
6
6
|
const CustomAttributeMerger_1 = require("./CustomAttributeMerger");
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
@@ -31,10 +31,10 @@ async function mergeClassProperty(context, change, itemKey, property) {
|
|
|
31
31
|
}
|
|
32
32
|
async function addClassProperty(context, itemKey, property) {
|
|
33
33
|
if (property.category !== undefined) {
|
|
34
|
-
property.category = await (0,
|
|
34
|
+
property.category = await (0, Utils_1.updateSchemaItemFullName)(context, property.category);
|
|
35
35
|
}
|
|
36
36
|
if (property.kindOfQuantity !== undefined) {
|
|
37
|
-
property.kindOfQuantity = await (0,
|
|
37
|
+
property.kindOfQuantity = await (0, Utils_1.updateSchemaItemFullName)(context, property.kindOfQuantity);
|
|
38
38
|
}
|
|
39
39
|
await createProperty(context, itemKey, property);
|
|
40
40
|
if (property.customAttributes !== undefined) {
|
|
@@ -68,9 +68,6 @@ async function modifyClassProperty(context, itemKey, propertyProps) {
|
|
|
68
68
|
if (propertyProps.type !== undefined) {
|
|
69
69
|
throw new Error(`Changing the property '${property.fullName}' type is not supported.`);
|
|
70
70
|
}
|
|
71
|
-
if (propertyProps.kindOfQuantity !== undefined) {
|
|
72
|
-
throw new Error(`Changing the property '${property.fullName}' kind of quantity is not supported.`);
|
|
73
|
-
}
|
|
74
71
|
const classEditor = await getClassEditor(context, ecClass);
|
|
75
72
|
if (propertyProps.description !== undefined) {
|
|
76
73
|
await classEditor.properties.setDescription(itemKey, propertyProps.name, propertyProps.description);
|
|
@@ -84,11 +81,14 @@ async function modifyClassProperty(context, itemKey, propertyProps) {
|
|
|
84
81
|
if (propertyProps.priority !== undefined) {
|
|
85
82
|
await classEditor.properties.setPriority(itemKey, propertyProps.name, propertyProps.priority);
|
|
86
83
|
}
|
|
84
|
+
if (propertyProps.kindOfQuantity !== undefined) {
|
|
85
|
+
await classEditor.properties.setKindOfQuantity(itemKey, propertyProps.name, await (0, Utils_1.updateSchemaItemKey)(context, propertyProps.kindOfQuantity));
|
|
86
|
+
}
|
|
87
87
|
if (property.isArray()) {
|
|
88
88
|
await arrayProperty.merge(context, itemKey, property.name, propertyProps);
|
|
89
89
|
}
|
|
90
90
|
if (propertyProps.category !== undefined) {
|
|
91
|
-
const categoryKey = await (0,
|
|
91
|
+
const categoryKey = await (0, Utils_1.updateSchemaItemKey)(context, propertyProps.category);
|
|
92
92
|
await classEditor.properties.setCategory(itemKey, property.name, categoryKey);
|
|
93
93
|
}
|
|
94
94
|
if (property.isEnumeration()) {
|
|
@@ -142,7 +142,7 @@ const enumerationProperty = {
|
|
|
142
142
|
return primitiveProperty.is(property) && property.typeName.includes(".");
|
|
143
143
|
},
|
|
144
144
|
async add(context, itemKey, property) {
|
|
145
|
-
const enumerationKey = await (0,
|
|
145
|
+
const enumerationKey = await (0, Utils_1.updateSchemaItemKey)(context, property.typeName);
|
|
146
146
|
const enumerationType = await context.editor.schemaContext.getSchemaItem(enumerationKey);
|
|
147
147
|
if (enumerationType === undefined) {
|
|
148
148
|
throw new Error(`Unable to locate the enumeration class ${enumerationKey.name} in the context schema.`);
|
|
@@ -165,7 +165,7 @@ const navigationProperty = {
|
|
|
165
165
|
return property.type === "NavigationProperty";
|
|
166
166
|
},
|
|
167
167
|
async add(context, itemKey, property) {
|
|
168
|
-
const relationshipKey = await (0,
|
|
168
|
+
const relationshipKey = await (0, Utils_1.updateSchemaItemKey)(context, property.relationshipName);
|
|
169
169
|
const relationshipType = await context.editor.schemaContext.getSchemaItem(relationshipKey);
|
|
170
170
|
if (relationshipType === undefined) {
|
|
171
171
|
throw new Error(`Unable to locate the relationship class ${relationshipKey.name} in the context schema.`);
|
|
@@ -230,7 +230,7 @@ const structProperty = {
|
|
|
230
230
|
return property.type === "StructProperty" || property.type === "StructArrayProperty";
|
|
231
231
|
},
|
|
232
232
|
async add(context, itemKey, property) {
|
|
233
|
-
const structKey = await (0,
|
|
233
|
+
const structKey = await (0, Utils_1.updateSchemaItemKey)(context, property.typeName);
|
|
234
234
|
const structType = await context.editor.schemaContext.getSchemaItem(structKey);
|
|
235
235
|
if (structType === undefined) {
|
|
236
236
|
throw new Error(`Unable to locate the struct ${structKey.name} in the context schema.`);
|