@itwin/ecschema-editing 5.7.0-dev.4 → 5.7.0-dev.6
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/Merging/SchemaMerger.d.ts +65 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +66 -1
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +13 -2
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js +122 -79
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/esm/Merging/SchemaMerger.d.ts +65 -1
- package/lib/esm/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/esm/Merging/SchemaMerger.js +64 -0
- package/lib/esm/Merging/SchemaMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.d.ts +13 -2
- package/lib/esm/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.js +122 -79
- package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.d.ts +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.js +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAA6B,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,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BAAgB,EAAE,sBAAsB,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAoDlG;;;OAGG;IACI,cAAc,IAAI,iBAAiB,GAAG,SAAS;CAGvD"}
|
|
@@ -13,6 +13,59 @@ import { SchemaMergingVisitor } from "./SchemaMergingVisitor";
|
|
|
13
13
|
import { SchemaMergingWalker } from "./SchemaMergingWalker";
|
|
14
14
|
import { ECEditingStatus, SchemaEditingError } from "../Editing/Exception";
|
|
15
15
|
import { NameMapping } from "./Edits/NameMapping";
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export class SchemaMergeReporter {
|
|
20
|
+
sourceSchemaKey;
|
|
21
|
+
targetSchemaKey;
|
|
22
|
+
totalDifferences;
|
|
23
|
+
_succeeded = [];
|
|
24
|
+
_failed = [];
|
|
25
|
+
constructor(sourceSchemaKey, targetSchemaKey, totalDifferences) {
|
|
26
|
+
this.sourceSchemaKey = sourceSchemaKey;
|
|
27
|
+
this.targetSchemaKey = targetSchemaKey;
|
|
28
|
+
this.totalDifferences = totalDifferences;
|
|
29
|
+
}
|
|
30
|
+
get successfulOperations() {
|
|
31
|
+
return [...this._succeeded];
|
|
32
|
+
}
|
|
33
|
+
get failedOperations() {
|
|
34
|
+
return [...this._failed];
|
|
35
|
+
}
|
|
36
|
+
get mergeStatistics() {
|
|
37
|
+
return {
|
|
38
|
+
total: this.totalDifferences,
|
|
39
|
+
succeeded: this._succeeded.length,
|
|
40
|
+
failed: this._failed.length,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
get success() {
|
|
44
|
+
return this._failed.length === 0;
|
|
45
|
+
}
|
|
46
|
+
recordSuccess(change) {
|
|
47
|
+
this._succeeded.push({ change });
|
|
48
|
+
}
|
|
49
|
+
recordFailure(change, error) {
|
|
50
|
+
this._failed.push({ change, error: error.message });
|
|
51
|
+
}
|
|
52
|
+
getMergeReport() {
|
|
53
|
+
return {
|
|
54
|
+
sourceSchemaKey: this.sourceSchemaKey,
|
|
55
|
+
targetSchemaKey: this.targetSchemaKey,
|
|
56
|
+
successfulOperations: [...this._succeeded],
|
|
57
|
+
failedOperations: [...this._failed],
|
|
58
|
+
mergeStatistics: {
|
|
59
|
+
total: this.totalDifferences,
|
|
60
|
+
succeeded: this._succeeded.length,
|
|
61
|
+
failed: this._failed.length,
|
|
62
|
+
},
|
|
63
|
+
get success() {
|
|
64
|
+
return this.failedOperations.length === 0;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
16
69
|
/**
|
|
17
70
|
* Class to merge two schemas together.
|
|
18
71
|
* @see [[merge]] or [[mergeSchemas]] to merge two schemas together.
|
|
@@ -20,6 +73,7 @@ import { NameMapping } from "./Edits/NameMapping";
|
|
|
20
73
|
*/
|
|
21
74
|
export class SchemaMerger {
|
|
22
75
|
_editingContext;
|
|
76
|
+
_mergeReporter;
|
|
23
77
|
/**
|
|
24
78
|
* Constructs a new instance of the SchemaMerger object.
|
|
25
79
|
* @param editingContext The schema contexts that holds the schema to be edited.
|
|
@@ -73,11 +127,21 @@ export class SchemaMerger {
|
|
|
73
127
|
sourceSchemaKey,
|
|
74
128
|
nameMapping,
|
|
75
129
|
});
|
|
130
|
+
// Initialize the merge reporter
|
|
131
|
+
this._mergeReporter = new SchemaMergeReporter(sourceSchemaKey, targetSchemaKey, differenceResult.differences.length);
|
|
132
|
+
visitor.setReporter(this._mergeReporter);
|
|
76
133
|
const walker = new SchemaMergingWalker(visitor);
|
|
77
134
|
await walker.traverse(differenceResult.differences, "add");
|
|
78
135
|
await walker.traverse(differenceResult.differences, "modify");
|
|
79
136
|
return schema;
|
|
80
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Gets the merge report for the last merge operation.
|
|
140
|
+
* @alpha
|
|
141
|
+
*/
|
|
142
|
+
getMergeReport() {
|
|
143
|
+
return this._mergeReporter?.getMergeReport();
|
|
144
|
+
}
|
|
81
145
|
}
|
|
82
146
|
/**
|
|
83
147
|
* SchemaContext implementation that overrides certain methods to allow to apply name mappings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAU,aAAa,EAAc,aAAa,EAAE,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AACxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAclD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAEN,eAAe,CAAgB;IAEhD;;;OAGG;IACH,YAAY,cAA6B;QACvC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,YAAY,CAAC,YAAoB,EAAE,YAAoB,EAAE,KAAmB;QACvF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,oBAAoB,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1F,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,KAAK,CAAC,gBAAwC,EAAE,KAAmB;QAC9E,MAAM,eAAe,GAAG,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QACjF,MAAM,eAAe,GAAG,SAAS,CAAC,WAAW,CAAC,gBAAgB,C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AAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","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\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"../Editing/Editor\";\r\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\r\nimport { getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\r\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\r\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\r\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\r\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\r\nimport { NameMapping } from \"./Edits/NameMapping\";\r\n\r\n/**\r\n * Defines the context of a Schema merging run.\r\n * @internal\r\n */\r\nexport interface SchemaMergeContext {\r\n readonly targetSchema: Schema;\r\n readonly targetSchemaKey: SchemaKey;\r\n readonly sourceSchemaKey: SchemaKey;\r\n readonly editor: SchemaContextEditor;\r\n readonly nameMapping: NameMapping;\r\n}\r\n\r\n/**\r\n * Class to merge two schemas together.\r\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\r\n * @beta\r\n */\r\nexport class SchemaMerger {\r\n\r\n private readonly _editingContext: SchemaContext;\r\n\r\n /**\r\n * Constructs a new instance of the SchemaMerger object.\r\n * @param editingContext The schema contexts that holds the schema to be edited.\r\n */\r\n constructor(editingContext: SchemaContext) {\r\n this._editingContext = editingContext;\r\n }\r\n\r\n /**\r\n * Copy the SchemaItems of the source schemas to the target schema.\r\n * @param targetSchema The schema the SchemaItems gets merged to.\r\n * @param sourceSchema The schema the SchemaItems gets copied from.\r\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\r\n * @returns The merged target schema.\r\n * @alpha\r\n */\r\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\r\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\r\n }\r\n\r\n /**\r\n * Merges the schema differences into the target schema context.\r\n * @param differenceResult The differences that shall be applied to the target schema.\r\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\r\n * @alpha\r\n */\r\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\r\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\r\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\r\n\r\n const nameMapping = new NameMapping();\r\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\r\n\r\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\r\n // to prevent altering the differenceResult the caller passed in.\r\n if (edits) {\r\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\r\n }\r\n\r\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\r\n throw new SchemaConflictsError(\r\n \"Schema's can't be merged if there are unresolved conflicts.\",\r\n differenceResult.conflicts,\r\n sourceSchemaKey,\r\n targetSchemaKey,\r\n );\r\n }\r\n\r\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\r\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\r\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\r\n }\r\n throw error;\r\n });\r\n\r\n if (!schema.isDynamic) {\r\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\r\n }\r\n\r\n const visitor = new SchemaMergingVisitor({\r\n editor,\r\n targetSchema: schema,\r\n targetSchemaKey,\r\n sourceSchemaKey,\r\n nameMapping,\r\n });\r\n\r\n const walker = new SchemaMergingWalker(visitor);\r\n await walker.traverse(differenceResult.differences, \"add\");\r\n await walker.traverse(differenceResult.differences, \"modify\");\r\n\r\n return schema;\r\n }\r\n}\r\n\r\n/**\r\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\r\n * for certain schema elements during the schema merging process.\r\n *\r\n * @internal\r\n */\r\nclass MergingSchemaContext extends SchemaContext {\r\n private _internalContext: SchemaContext;\r\n private _nameMappings: NameMapping;\r\n\r\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\r\n super();\r\n this._internalContext = internalContext;\r\n this._nameMappings = nameMapping;\r\n }\r\n\r\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\r\n return this._internalContext.getCachedSchema(schemaKey, matchType);\r\n }\r\n\r\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\r\n return this._internalContext.getSchema(schemaKey, matchType);\r\n }\r\n\r\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaItemKey: SchemaItemKey;\r\n if (typeof schemaNameOrKey === \"string\")\r\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\r\n else\r\n schemaItemKey = schemaNameOrKey;\r\n\r\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\r\n if(mappedKey !== undefined) {\r\n schemaItemKey = mappedKey as SchemaItemKey;\r\n }\r\n\r\n if(itemConstructor === undefined)\r\n return this._internalContext.getSchemaItem(schemaItemKey);\r\n\r\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaMerger.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AA8B,eAAuC,EAAE,cAA2B,EAAE,eAAmB;QACxJ,IAAI,aAA4B,CAAC;QACjC,IAAI,OAAO,eAAe,KAAK,QAAQ;YACrC,aAAa,GAAG,IAAI,aAAa,CAAC,cAAwB,EAAE,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;;YAE5F,aAAa,GAAG,eAAe,CAAC;QAElC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACnE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,aAAa,GAAG,SAA0B,CAAC;QAC7C,CAAC;QAED,IAAI,eAAe,KAAK,SAAS;YAC/B,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAC7E,CAAC;CACF","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\n/** @packageDocumentation\r\n * @module Merging\r\n */\r\n\r\nimport { Schema, SchemaContext, SchemaItem, SchemaItemKey, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"../Editing/Editor\";\r\nimport { SchemaConflictsError } from \"../Differencing/Errors\";\r\nimport { AnySchemaDifference, getSchemaDifferences, type SchemaDifferenceResult } from \"../Differencing/SchemaDifference\";\r\nimport { SchemaMergingVisitor } from \"./SchemaMergingVisitor\";\r\nimport { SchemaMergingWalker } from \"./SchemaMergingWalker\";\r\nimport { SchemaEdits } from \"./Edits/SchemaEdits\";\r\nimport { ECEditingStatus, SchemaEditingError } from \"../Editing/Exception\";\r\nimport { NameMapping } from \"./Edits/NameMapping\";\r\n\r\n/**\r\n * Defines the context of a Schema merging run.\r\n * @internal\r\n */\r\nexport interface SchemaMergeContext {\r\n readonly targetSchema: Schema;\r\n readonly targetSchemaKey: SchemaKey;\r\n readonly sourceSchemaKey: SchemaKey;\r\n readonly editor: SchemaContextEditor;\r\n readonly nameMapping: NameMapping;\r\n}\r\n\r\n/**\r\n * Represents a single merge operation that was executed.\r\n * @internal\r\n */\r\nexport interface SchemaMergeOperation {\r\n readonly change: AnySchemaDifference;\r\n}\r\n\r\n/**\r\n * Represents a merge operation that failed with an error.\r\n * @internal\r\n */\r\nexport interface SchemaMergeFailure extends SchemaMergeOperation {\r\n readonly error: string;\r\n}\r\n\r\n/**\r\n * Report of a schema merge operation containing success/failure details.\r\n * @internal\r\n */\r\nexport interface SchemaMergeReport {\r\n /** Source schema identifier */\r\n readonly sourceSchemaKey: SchemaKey;\r\n /** Target schema identifier */\r\n readonly targetSchemaKey: SchemaKey;\r\n /** Array of successfully merged differences */\r\n readonly successfulOperations: SchemaMergeOperation[];\r\n /** Array of failed merge operations with their errors */\r\n readonly failedOperations: SchemaMergeFailure[];\r\n /** Summary statistics of the merge operation */\r\n readonly mergeStatistics: {\r\n readonly total: number;\r\n readonly succeeded: number;\r\n readonly failed: number;\r\n };\r\n /** Returns true if all operations succeeded */\r\n readonly success: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class SchemaMergeReporter implements SchemaMergeReport {\r\n private readonly _succeeded: SchemaMergeOperation[] = [];\r\n private readonly _failed: SchemaMergeFailure[] = [];\r\n\r\n constructor(\r\n public readonly sourceSchemaKey: SchemaKey,\r\n public readonly targetSchemaKey: SchemaKey,\r\n public readonly totalDifferences: number,\r\n ) { }\r\n\r\n public get successfulOperations(): SchemaMergeOperation[] {\r\n return [...this._succeeded];\r\n }\r\n\r\n public get failedOperations(): SchemaMergeFailure[] {\r\n return [...this._failed];\r\n }\r\n\r\n public get mergeStatistics() {\r\n return {\r\n total: this.totalDifferences,\r\n succeeded: this._succeeded.length,\r\n failed: this._failed.length,\r\n };\r\n }\r\n\r\n public get success(): boolean {\r\n return this._failed.length === 0;\r\n }\r\n\r\n public recordSuccess(change: AnySchemaDifference): void {\r\n this._succeeded.push({ change });\r\n }\r\n\r\n public recordFailure(change: AnySchemaDifference, error: Error): void {\r\n this._failed.push({ change, error: error.message });\r\n }\r\n\r\n public getMergeReport(): SchemaMergeReport {\r\n return {\r\n sourceSchemaKey: this.sourceSchemaKey,\r\n targetSchemaKey: this.targetSchemaKey,\r\n successfulOperations: [...this._succeeded],\r\n failedOperations: [...this._failed],\r\n mergeStatistics: {\r\n total: this.totalDifferences,\r\n succeeded: this._succeeded.length,\r\n failed: this._failed.length,\r\n },\r\n get success() {\r\n return this.failedOperations.length === 0;\r\n },\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Class to merge two schemas together.\r\n * @see [[merge]] or [[mergeSchemas]] to merge two schemas together.\r\n * @beta\r\n */\r\nexport class SchemaMerger {\r\n\r\n private readonly _editingContext: SchemaContext;\r\n private _mergeReporter: SchemaMergeReporter | undefined;\r\n\r\n /**\r\n * Constructs a new instance of the SchemaMerger object.\r\n * @param editingContext The schema contexts that holds the schema to be edited.\r\n */\r\n constructor(editingContext: SchemaContext) {\r\n this._editingContext = editingContext;\r\n }\r\n\r\n /**\r\n * Copy the SchemaItems of the source schemas to the target schema.\r\n * @param targetSchema The schema the SchemaItems gets merged to.\r\n * @param sourceSchema The schema the SchemaItems gets copied from.\r\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\r\n * @returns The merged target schema.\r\n * @alpha\r\n */\r\n public async mergeSchemas(targetSchema: Schema, sourceSchema: Schema, edits?: SchemaEdits): Promise<Schema> {\r\n return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);\r\n }\r\n\r\n /**\r\n * Merges the schema differences into the target schema context.\r\n * @param differenceResult The differences that shall be applied to the target schema.\r\n * @param edits An optional instance of schema edits that shall be applied before the schemas get merged.\r\n * @alpha\r\n */\r\n public async merge(differenceResult: SchemaDifferenceResult, edits?: SchemaEdits): Promise<Schema> {\r\n const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);\r\n const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);\r\n\r\n const nameMapping = new NameMapping();\r\n const editor = new SchemaContextEditor(new MergingSchemaContext(this._editingContext, nameMapping));\r\n\r\n // If schema changes were provided, they'll get applied and a new SchemaDifferenceResult is returned\r\n // to prevent altering the differenceResult the caller passed in.\r\n if (edits) {\r\n await edits.applyTo(differenceResult = { ...differenceResult }, nameMapping);\r\n }\r\n\r\n if (differenceResult.conflicts && differenceResult.conflicts.length > 0) {\r\n throw new SchemaConflictsError(\r\n \"Schema's can't be merged if there are unresolved conflicts.\",\r\n differenceResult.conflicts,\r\n sourceSchemaKey,\r\n targetSchemaKey,\r\n );\r\n }\r\n\r\n const schema = await editor.getSchema(targetSchemaKey).catch((error: Error) => {\r\n if (error instanceof SchemaEditingError && error.errorNumber === ECEditingStatus.SchemaNotFound) {\r\n throw new Error(`The target schema '${targetSchemaKey.name}' could not be found in the editing context.`);\r\n }\r\n throw error;\r\n });\r\n\r\n if (!schema.isDynamic) {\r\n throw new Error(`The target schema '${targetSchemaKey.name}' is not dynamic. Only dynamic schemas are supported for merging.`);\r\n }\r\n\r\n const visitor = new SchemaMergingVisitor({\r\n editor,\r\n targetSchema: schema,\r\n targetSchemaKey,\r\n sourceSchemaKey,\r\n nameMapping,\r\n });\r\n\r\n // Initialize the merge reporter\r\n this._mergeReporter = new SchemaMergeReporter(sourceSchemaKey, targetSchemaKey, differenceResult.differences.length);\r\n visitor.setReporter(this._mergeReporter);\r\n\r\n const walker = new SchemaMergingWalker(visitor);\r\n await walker.traverse(differenceResult.differences, \"add\");\r\n await walker.traverse(differenceResult.differences, \"modify\");\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Gets the merge report for the last merge operation.\r\n * @alpha\r\n */\r\n public getMergeReport(): SchemaMergeReport | undefined {\r\n return this._mergeReporter?.getMergeReport();\r\n }\r\n}\r\n\r\n/**\r\n * SchemaContext implementation that overrides certain methods to allow to apply name mappings\r\n * for certain schema elements during the schema merging process.\r\n *\r\n * @internal\r\n */\r\nclass MergingSchemaContext extends SchemaContext {\r\n private _internalContext: SchemaContext;\r\n private _nameMappings: NameMapping;\r\n\r\n public constructor(internalContext: SchemaContext, nameMapping: NameMapping) {\r\n super();\r\n this._internalContext = internalContext;\r\n this._nameMappings = nameMapping;\r\n }\r\n\r\n public override async getCachedSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\r\n return this._internalContext.getCachedSchema(schemaKey, matchType);\r\n }\r\n\r\n public override async getSchema(schemaKey: SchemaKey, matchType?: SchemaMatchType): Promise<Schema | undefined> {\r\n return this._internalContext.getSchema(schemaKey, matchType);\r\n }\r\n\r\n public override async getSchemaItem<T extends typeof SchemaItem>(schemaNameOrKey: string | SchemaItemKey, itemNameOrCtor?: string | T, itemConstructor?: T): Promise<SchemaItem | InstanceType<T> | undefined> {\r\n let schemaItemKey: SchemaItemKey;\r\n if (typeof schemaNameOrKey === \"string\")\r\n schemaItemKey = new SchemaItemKey(itemNameOrCtor as string, new SchemaKey(schemaNameOrKey));\r\n else\r\n schemaItemKey = schemaNameOrKey;\r\n\r\n const mappedKey = this._nameMappings.resolveItemKey(schemaItemKey);\r\n if (mappedKey !== undefined) {\r\n schemaItemKey = mappedKey as SchemaItemKey;\r\n }\r\n\r\n if (itemConstructor === undefined)\r\n return this._internalContext.getSchemaItem(schemaItemKey);\r\n\r\n return this._internalContext.getSchemaItem(schemaItemKey, itemConstructor);\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnySchemaDifference, ClassPropertyDifference, ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference, EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference, FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference, MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference, StructClassDifference, UnitDifference, UnitSystemDifference } from "../Differencing/SchemaDifference";
|
|
2
2
|
import { SchemaDifferenceVisitor } from "../Differencing/SchemaDifferenceVisitor";
|
|
3
|
-
import { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import { SchemaMergeContext, SchemaMergeReporter } from "./SchemaMerger";
|
|
4
4
|
/**
|
|
5
5
|
* Implementation of ISchemaDifferenceVisitor that can be used to traverse schema
|
|
6
6
|
* differences to call the appropriated merger methods.
|
|
@@ -8,10 +8,21 @@ import { SchemaMergeContext } from "./SchemaMerger";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class SchemaMergingVisitor implements SchemaDifferenceVisitor {
|
|
10
10
|
private readonly _context;
|
|
11
|
+
private _reporter?;
|
|
11
12
|
/**
|
|
12
13
|
* Initializes a new instance of SchemaMergingVisitor class.
|
|
13
14
|
*/
|
|
14
15
|
constructor(context: SchemaMergeContext);
|
|
16
|
+
/**
|
|
17
|
+
* Sets the reporter for tracking merge operations.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
setReporter(reporter: SchemaMergeReporter): void;
|
|
21
|
+
/**
|
|
22
|
+
* Method that wraps the visitor with success/failure tracking.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
private trackOperation;
|
|
15
26
|
/**
|
|
16
27
|
* Shared merging logic for all types of ClassItemDifference union.
|
|
17
28
|
*/
|
|
@@ -115,7 +126,7 @@ export declare class SchemaMergingVisitor implements SchemaDifferenceVisitor {
|
|
|
115
126
|
* Visitor implementation for handling SchemaDifference.
|
|
116
127
|
* @internal
|
|
117
128
|
*/
|
|
118
|
-
visitSchemaDifference(
|
|
129
|
+
visitSchemaDifference(entry: SchemaDifference): Promise<void>;
|
|
119
130
|
/**
|
|
120
131
|
* Shared merging logic for all types of AnySchemaItemDifference union.
|
|
121
132
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingVisitor.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaMergingVisitor.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAIA,OAAO,EACmB,mBAAmB,EAA2B,uBAAuB,EAC7F,kBAAkB,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,qBAAqB,EACpG,0BAA0B,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAC/G,yBAAyB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,0CAA0C,EACvH,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,2BAA2B,EACnG,qCAAqC,EAAE,gCAAgC,EAAE,gBAAgB,EAAE,yBAAyB,EACpH,qBAAqB,EAAE,cAAc,EAAE,oBAAoB,EAC5D,MAAM,kCAAkC,CAAC;AAiB1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAYzE;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,uBAAuB;IAElE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,SAAS,CAAC,CAAsB;IAExC;;OAEG;gBACS,OAAO,EAAE,kBAAkB;IAIvC;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAIvD;;;OAGG;YACW,cAAc;IAc5B;;OAEG;YACW,oBAAoB;IAoClC;;;OAGG;IACU,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9E;;;OAGG;IACU,mCAAmC,CAAC,KA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|
28
|
+
_reporter;
|
|
28
29
|
/**
|
|
29
30
|
* Initializes a new instance of SchemaMergingVisitor class.
|
|
30
31
|
*/
|
|
31
32
|
constructor(context) {
|
|
32
33
|
this._context = context;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets the reporter for tracking merge operations.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
setReporter(reporter) {
|
|
40
|
+
this._reporter = reporter;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Method that wraps the visitor with success/failure tracking.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
async trackOperation(entry, operation) {
|
|
47
|
+
if (!this._reporter) {
|
|
48
|
+
return operation();
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
await operation();
|
|
52
|
+
this._reporter.recordSuccess(entry);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this._reporter.recordFailure(entry, error);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
34
59
|
/**
|
|
35
60
|
* Shared merging logic for all types of ClassItemDifference union.
|
|
36
61
|
*/
|
|
37
62
|
async visitClassDifference(entry, index, array, handler) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
63
|
+
// To add classes a slightly different approach is done. In fact the class entries gets processed
|
|
64
|
+
// two times. The first time, a stub with the bare minimum is added to the schema. The second time,
|
|
65
|
+
// the class gets completed with all properties, mixins, etc...
|
|
66
|
+
if (entry.changeType === "add" && !await this._context.targetSchema.getItem(entry.itemName)) {
|
|
67
|
+
await handler.add(this._context, {
|
|
68
|
+
...entry,
|
|
69
|
+
difference: {
|
|
70
|
+
...entry.difference,
|
|
71
|
+
// Remove everything we want to validate before setting, this is done in the second iteration.
|
|
72
|
+
baseClass: undefined,
|
|
73
|
+
mixins: undefined,
|
|
74
|
+
properties: undefined,
|
|
75
|
+
customAttributes: undefined,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
// Searches for the last class difference and adds the entry after it. That way,
|
|
79
|
+
// the class is completed before class related entries get processed.
|
|
80
|
+
const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;
|
|
81
|
+
array.splice(insertIndex, 0, entry);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Now both a modification change or the second add iteration is a modification of an existing class.
|
|
85
|
+
// So, regardless of the actual change type, modify is called.
|
|
86
|
+
// This is tracked because it's the actual operation that completes the class.
|
|
87
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
88
|
+
add: async (context) => handler.modify(context, entry, toItemKey(context, entry.itemName)),
|
|
65
89
|
modify: handler.modify,
|
|
66
|
-
});
|
|
90
|
+
}));
|
|
67
91
|
}
|
|
68
92
|
/**
|
|
69
93
|
* Visitor implementation for handling ConstantDifference.
|
|
70
94
|
* @internal
|
|
71
95
|
*/
|
|
72
96
|
async visitConstantDifference(entry) {
|
|
73
|
-
return this.visitSchemaItemDifference(entry, {
|
|
97
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
74
98
|
add: addConstant,
|
|
75
99
|
modify: modifyConstant,
|
|
76
|
-
});
|
|
100
|
+
}));
|
|
77
101
|
}
|
|
78
102
|
/**
|
|
79
103
|
* Visitor implementation for handling CustomAttributeClassDifference.
|
|
@@ -90,9 +114,11 @@ export class SchemaMergingVisitor {
|
|
|
90
114
|
* @internal
|
|
91
115
|
*/
|
|
92
116
|
async visitCustomAttributeInstanceDifference(entry) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
return this.trackOperation(entry, async () => {
|
|
118
|
+
switch (entry.changeType) {
|
|
119
|
+
case "add": return addCustomAttribute(this._context, entry);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
96
122
|
}
|
|
97
123
|
/**
|
|
98
124
|
* Visitor implementation for handling EntityClassDifference.
|
|
@@ -109,77 +135,85 @@ export class SchemaMergingVisitor {
|
|
|
109
135
|
* @internal
|
|
110
136
|
*/
|
|
111
137
|
async visitEntityClassMixinDifference(entry) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
138
|
+
return this.trackOperation(entry, async () => {
|
|
139
|
+
switch (entry.changeType) {
|
|
140
|
+
case "add": return addClassMixins(this._context, entry);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
115
143
|
}
|
|
116
144
|
/**
|
|
117
145
|
* Visitor implementation for handling EnumerationDifference.
|
|
118
146
|
* @internal
|
|
119
147
|
*/
|
|
120
148
|
async visitEnumerationDifference(entry) {
|
|
121
|
-
return this.visitSchemaItemDifference(entry, {
|
|
149
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
122
150
|
add: addEnumeration,
|
|
123
151
|
modify: modifyEnumeration,
|
|
124
|
-
});
|
|
152
|
+
}));
|
|
125
153
|
}
|
|
126
154
|
/**
|
|
127
155
|
* Visitor implementation for handling EnumeratorDifference.
|
|
128
156
|
* @internal
|
|
129
157
|
*/
|
|
130
158
|
async visitEnumeratorDifference(entry) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
159
|
+
return this.trackOperation(entry, async () => {
|
|
160
|
+
switch (entry.changeType) {
|
|
161
|
+
case "add": return addEnumerator(this._context, entry);
|
|
162
|
+
case "modify": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
163
|
+
}
|
|
164
|
+
});
|
|
135
165
|
}
|
|
136
166
|
/**
|
|
137
167
|
* Visitor implementation for handling FormatDifference.
|
|
138
168
|
* @internal
|
|
139
169
|
*/
|
|
140
170
|
async visitFormatDifference(entry) {
|
|
141
|
-
return this.visitSchemaItemDifference(entry, {
|
|
171
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
142
172
|
add: addFormat,
|
|
143
173
|
modify: modifyFormat,
|
|
144
|
-
});
|
|
174
|
+
}));
|
|
145
175
|
}
|
|
146
176
|
/**
|
|
147
177
|
* Visitor implementation for handling FormatUnitDifference.
|
|
148
178
|
* @internal
|
|
149
179
|
*/
|
|
150
180
|
async visitFormatUnitDifference(entry) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
return this.trackOperation(entry, async () => {
|
|
182
|
+
switch (entry.changeType) {
|
|
183
|
+
case "modify": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
184
|
+
}
|
|
185
|
+
});
|
|
154
186
|
}
|
|
155
187
|
/**
|
|
156
188
|
* Visitor implementation for handling FormatUnitLabelDifference.
|
|
157
189
|
* @internal
|
|
158
190
|
*/
|
|
159
191
|
async visitFormatUnitLabelDifference(entry) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
192
|
+
return this.trackOperation(entry, async () => {
|
|
193
|
+
switch (entry.changeType) {
|
|
194
|
+
case "modify": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
195
|
+
}
|
|
196
|
+
});
|
|
163
197
|
}
|
|
164
198
|
/**
|
|
165
199
|
* Visitor implementation for handling InvertedUnitDifference.
|
|
166
200
|
* @internal
|
|
167
201
|
*/
|
|
168
202
|
async visitInvertedUnitDifference(entry) {
|
|
169
|
-
return this.visitSchemaItemDifference(entry, {
|
|
203
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
170
204
|
add: addInvertedUnit,
|
|
171
205
|
modify: modifyInvertedUnit,
|
|
172
|
-
});
|
|
206
|
+
}));
|
|
173
207
|
}
|
|
174
208
|
/**
|
|
175
209
|
* Visitor implementation for handling KindOfQuantityDifference.
|
|
176
210
|
* @internal
|
|
177
211
|
*/
|
|
178
212
|
async visitKindOfQuantityDifference(entry) {
|
|
179
|
-
return this.visitSchemaItemDifference(entry, {
|
|
213
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
180
214
|
add: addKindOfQuantity,
|
|
181
215
|
modify: modifyKindOfQuantity,
|
|
182
|
-
});
|
|
216
|
+
}));
|
|
183
217
|
}
|
|
184
218
|
/**
|
|
185
219
|
* Visitor implementation for handling MixinClassDifference.
|
|
@@ -196,27 +230,27 @@ export class SchemaMergingVisitor {
|
|
|
196
230
|
* @internal
|
|
197
231
|
*/
|
|
198
232
|
async visitPhenomenonDifference(entry) {
|
|
199
|
-
return this.visitSchemaItemDifference(entry, {
|
|
233
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
200
234
|
add: addPhenomenon,
|
|
201
235
|
modify: modifyPhenomenon,
|
|
202
|
-
});
|
|
236
|
+
}));
|
|
203
237
|
}
|
|
204
238
|
/**
|
|
205
239
|
* Visitor implementation for handling PropertyCategoryDifference.
|
|
206
240
|
* @internal
|
|
207
241
|
*/
|
|
208
242
|
async visitPropertyCategoryDifference(entry) {
|
|
209
|
-
return this.visitSchemaItemDifference(entry, {
|
|
243
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
210
244
|
add: addPropertyCategory,
|
|
211
245
|
modify: modifyPropertyCategory,
|
|
212
|
-
});
|
|
246
|
+
}));
|
|
213
247
|
}
|
|
214
248
|
/**
|
|
215
249
|
* Visitor implementation for handling ClassPropertyDifference.
|
|
216
250
|
* @internal
|
|
217
251
|
*/
|
|
218
252
|
async visitPropertyDifference(entry) {
|
|
219
|
-
|
|
253
|
+
return this.trackOperation(entry, async () => mergePropertyDifference(this._context, entry));
|
|
220
254
|
}
|
|
221
255
|
/**
|
|
222
256
|
* Visitor implementation for handling RelationshipClassDifference.
|
|
@@ -233,26 +267,31 @@ export class SchemaMergingVisitor {
|
|
|
233
267
|
* @internal
|
|
234
268
|
*/
|
|
235
269
|
async visitRelationshipConstraintClassDifference(entry) {
|
|
236
|
-
|
|
270
|
+
return this.trackOperation(entry, async () => mergeRelationshipClassConstraint(this._context, entry));
|
|
237
271
|
}
|
|
238
272
|
/**
|
|
239
273
|
* Visitor implementation for handling RelationshipConstraintDifference.
|
|
240
274
|
* @internal
|
|
241
275
|
*/
|
|
242
276
|
async visitRelationshipConstraintDifference(entry) {
|
|
243
|
-
|
|
277
|
+
return this.trackOperation(entry, async () => {
|
|
278
|
+
await mergeRelationshipConstraint(this._context, entry);
|
|
279
|
+
});
|
|
244
280
|
}
|
|
245
281
|
/**
|
|
246
282
|
* Visitor implementation for handling SchemaDifference.
|
|
247
283
|
* @internal
|
|
248
284
|
*/
|
|
249
|
-
async visitSchemaDifference(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
285
|
+
async visitSchemaDifference(entry) {
|
|
286
|
+
return this.trackOperation(entry, async () => {
|
|
287
|
+
const { difference } = entry;
|
|
288
|
+
if (difference.label !== undefined) {
|
|
289
|
+
await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);
|
|
290
|
+
}
|
|
291
|
+
if (difference.description !== undefined) {
|
|
292
|
+
await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
256
295
|
}
|
|
257
296
|
/**
|
|
258
297
|
* Shared merging logic for all types of AnySchemaItemDifference union.
|
|
@@ -277,10 +316,12 @@ export class SchemaMergingVisitor {
|
|
|
277
316
|
* @internal
|
|
278
317
|
*/
|
|
279
318
|
async visitSchemaReferenceDifference(entry) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
319
|
+
return this.trackOperation(entry, async () => {
|
|
320
|
+
switch (entry.changeType) {
|
|
321
|
+
case "add": return addSchemaReferences(this._context, entry);
|
|
322
|
+
case "modify": return modifySchemaReferences(this._context, entry);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
284
325
|
}
|
|
285
326
|
/**
|
|
286
327
|
* Visitor implementation for handling StructClassDifference.
|
|
@@ -297,29 +338,31 @@ export class SchemaMergingVisitor {
|
|
|
297
338
|
* @internal
|
|
298
339
|
*/
|
|
299
340
|
async visitUnitDifference(entry) {
|
|
300
|
-
return this.visitSchemaItemDifference(entry, {
|
|
341
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
301
342
|
add: addUnit,
|
|
302
343
|
modify: modifyUnit,
|
|
303
|
-
});
|
|
344
|
+
}));
|
|
304
345
|
}
|
|
305
346
|
/**
|
|
306
347
|
* Visitor implementation for handling UnitSystemDifference.
|
|
307
348
|
* @internal
|
|
308
349
|
*/
|
|
309
350
|
async visitUnitSystemDifference(entry) {
|
|
310
|
-
return this.visitSchemaItemDifference(entry, {
|
|
351
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
311
352
|
add: addUnitSystem,
|
|
312
353
|
modify: modifyUnitSystem,
|
|
313
|
-
});
|
|
354
|
+
}));
|
|
314
355
|
}
|
|
315
356
|
/**
|
|
316
357
|
* Visitor implementation for handling KindOfQuantityPresentationFormatDifference.
|
|
317
358
|
* @internal
|
|
318
359
|
*/
|
|
319
360
|
async visitKindOfQuantityPresentationFormatDifference(entry) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
361
|
+
return this.trackOperation(entry, async () => {
|
|
362
|
+
switch (entry.changeType) {
|
|
363
|
+
case "add": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
364
|
+
}
|
|
365
|
+
});
|
|
323
366
|
}
|
|
324
367
|
}
|
|
325
368
|
/**
|