@itwin/ecschema-editing 5.7.0-dev.6 → 5.7.0-dev.8
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 +6 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +48 -5
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +75 -14
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js +3 -2
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/esm/Merging/SchemaMerger.d.ts +48 -5
- package/lib/esm/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/esm/Merging/SchemaMerger.js +75 -14
- package/lib/esm/Merging/SchemaMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.js +3 -2
- package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Change Log - @itwin/ecschema-editing
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 05 Feb 2026 16:14:10 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.6.0
|
|
6
|
+
Thu, 05 Feb 2026 16:12:37 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
4
9
|
|
|
5
10
|
## 5.5.2
|
|
6
11
|
Thu, 22 Jan 2026 16:16:54 GMT
|
|
@@ -23,6 +23,7 @@ export interface SchemaMergeContext {
|
|
|
23
23
|
*/
|
|
24
24
|
export interface SchemaMergeOperation {
|
|
25
25
|
readonly change: AnySchemaDifference;
|
|
26
|
+
readonly durationMs: number;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Represents a merge operation that failed with an error.
|
|
@@ -50,6 +51,13 @@ export interface SchemaMergeReport {
|
|
|
50
51
|
readonly succeeded: number;
|
|
51
52
|
readonly failed: number;
|
|
52
53
|
};
|
|
54
|
+
/** Performance metrics of the merge operation */
|
|
55
|
+
readonly performanceMetrics: {
|
|
56
|
+
readonly totalDurationMs: number;
|
|
57
|
+
readonly schemaDifferenceDurationMs: number;
|
|
58
|
+
readonly mergeDurationMs: number;
|
|
59
|
+
readonly averageMergeOpDurationMs: number;
|
|
60
|
+
};
|
|
53
61
|
/** Returns true if all operations succeeded */
|
|
54
62
|
readonly success: boolean;
|
|
55
63
|
}
|
|
@@ -57,12 +65,18 @@ export interface SchemaMergeReport {
|
|
|
57
65
|
* @internal
|
|
58
66
|
*/
|
|
59
67
|
export declare class SchemaMergeReporter implements SchemaMergeReport {
|
|
60
|
-
readonly sourceSchemaKey: SchemaKey;
|
|
61
|
-
readonly targetSchemaKey: SchemaKey;
|
|
62
|
-
readonly totalDifferences: number;
|
|
63
68
|
private readonly _succeeded;
|
|
64
69
|
private readonly _failed;
|
|
70
|
+
private readonly _sourceSchemaKey;
|
|
71
|
+
private readonly _targetSchemaKey;
|
|
72
|
+
private readonly _totalDifferences;
|
|
73
|
+
private _totalDurationMs;
|
|
74
|
+
private _schemaDifferenceDurationMs;
|
|
75
|
+
private _mergeDurationMs;
|
|
76
|
+
private _averageMergeOpDurationMs;
|
|
65
77
|
constructor(sourceSchemaKey: SchemaKey, targetSchemaKey: SchemaKey, totalDifferences: number);
|
|
78
|
+
get sourceSchemaKey(): SchemaKey;
|
|
79
|
+
get targetSchemaKey(): SchemaKey;
|
|
66
80
|
get successfulOperations(): SchemaMergeOperation[];
|
|
67
81
|
get failedOperations(): SchemaMergeFailure[];
|
|
68
82
|
get mergeStatistics(): {
|
|
@@ -70,9 +84,37 @@ export declare class SchemaMergeReporter implements SchemaMergeReport {
|
|
|
70
84
|
succeeded: number;
|
|
71
85
|
failed: number;
|
|
72
86
|
};
|
|
87
|
+
get performanceMetrics(): {
|
|
88
|
+
totalDurationMs: number;
|
|
89
|
+
schemaDifferenceDurationMs: number;
|
|
90
|
+
mergeDurationMs: number;
|
|
91
|
+
averageMergeOpDurationMs: number;
|
|
92
|
+
};
|
|
73
93
|
get success(): boolean;
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Sets the performance metrics for the merge operation.
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
setPerformanceMetrics(metrics: {
|
|
99
|
+
totalDurationMs: number;
|
|
100
|
+
schemaDifferenceDurationMs: number;
|
|
101
|
+
mergeDurationMs: number;
|
|
102
|
+
averageMergeOpDurationMs: number;
|
|
103
|
+
}): void;
|
|
104
|
+
/**
|
|
105
|
+
* Records a successful merge operation.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
recordSuccess(change: AnySchemaDifference, durationMs: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Records a failed merge operation.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
recordFailure(change: AnySchemaDifference, durationMs: number, error: Error): void;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the merge report.
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
76
118
|
getMergeReport(): SchemaMergeReport;
|
|
77
119
|
}
|
|
78
120
|
/**
|
|
@@ -83,6 +125,7 @@ export declare class SchemaMergeReporter implements SchemaMergeReport {
|
|
|
83
125
|
export declare class SchemaMerger {
|
|
84
126
|
private readonly _editingContext;
|
|
85
127
|
private _mergeReporter;
|
|
128
|
+
private _differenceStartTime;
|
|
86
129
|
/**
|
|
87
130
|
* Constructs a new instance of the SchemaMerger object.
|
|
88
131
|
* @param editingContext The schema contexts that holds the schema to be edited.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":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O,CAAC,oBAAoB,CAAa;IAEzC;;;OAGG;gBACS,cAAc,EAAE,aAAa;IAIzC;;;;;;;OAOG;IACU,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAK3G;;;;;OAKG;IACU,KAAK,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAqElG;;;OAGG;IACI,cAAc,IAAI,iBAAiB,GAAG,SAAS;CAGvD"}
|
|
@@ -20,15 +20,25 @@ const NameMapping_1 = require("./Edits/NameMapping");
|
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
class SchemaMergeReporter {
|
|
23
|
-
sourceSchemaKey;
|
|
24
|
-
targetSchemaKey;
|
|
25
|
-
totalDifferences;
|
|
26
23
|
_succeeded = [];
|
|
27
24
|
_failed = [];
|
|
25
|
+
_sourceSchemaKey;
|
|
26
|
+
_targetSchemaKey;
|
|
27
|
+
_totalDifferences;
|
|
28
|
+
_totalDurationMs = 0;
|
|
29
|
+
_schemaDifferenceDurationMs = 0;
|
|
30
|
+
_mergeDurationMs = 0;
|
|
31
|
+
_averageMergeOpDurationMs = 0;
|
|
28
32
|
constructor(sourceSchemaKey, targetSchemaKey, totalDifferences) {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
33
|
+
this._sourceSchemaKey = sourceSchemaKey;
|
|
34
|
+
this._targetSchemaKey = targetSchemaKey;
|
|
35
|
+
this._totalDifferences = totalDifferences;
|
|
36
|
+
}
|
|
37
|
+
get sourceSchemaKey() {
|
|
38
|
+
return this._sourceSchemaKey;
|
|
39
|
+
}
|
|
40
|
+
get targetSchemaKey() {
|
|
41
|
+
return this._targetSchemaKey;
|
|
32
42
|
}
|
|
33
43
|
get successfulOperations() {
|
|
34
44
|
return [...this._succeeded];
|
|
@@ -38,31 +48,67 @@ class SchemaMergeReporter {
|
|
|
38
48
|
}
|
|
39
49
|
get mergeStatistics() {
|
|
40
50
|
return {
|
|
41
|
-
total: this.
|
|
51
|
+
total: this._totalDifferences,
|
|
42
52
|
succeeded: this._succeeded.length,
|
|
43
53
|
failed: this._failed.length,
|
|
44
54
|
};
|
|
45
55
|
}
|
|
56
|
+
get performanceMetrics() {
|
|
57
|
+
return {
|
|
58
|
+
totalDurationMs: this._totalDurationMs,
|
|
59
|
+
schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,
|
|
60
|
+
mergeDurationMs: this._mergeDurationMs,
|
|
61
|
+
averageMergeOpDurationMs: this._averageMergeOpDurationMs,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
46
64
|
get success() {
|
|
47
65
|
return this._failed.length === 0;
|
|
48
66
|
}
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Sets the performance metrics for the merge operation.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
setPerformanceMetrics(metrics) {
|
|
72
|
+
this._totalDurationMs = metrics.totalDurationMs;
|
|
73
|
+
this._schemaDifferenceDurationMs = metrics.schemaDifferenceDurationMs;
|
|
74
|
+
this._mergeDurationMs = metrics.mergeDurationMs;
|
|
75
|
+
this._averageMergeOpDurationMs = metrics.averageMergeOpDurationMs;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Records a successful merge operation.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
recordSuccess(change, durationMs) {
|
|
82
|
+
this._succeeded.push({ change, durationMs });
|
|
51
83
|
}
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Records a failed merge operation.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
recordFailure(change, durationMs, error) {
|
|
89
|
+
this._failed.push({ change, durationMs, error: error.message });
|
|
54
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the merge report.
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
55
95
|
getMergeReport() {
|
|
56
96
|
return {
|
|
57
|
-
sourceSchemaKey: this.
|
|
58
|
-
targetSchemaKey: this.
|
|
97
|
+
sourceSchemaKey: this._sourceSchemaKey,
|
|
98
|
+
targetSchemaKey: this._targetSchemaKey,
|
|
59
99
|
successfulOperations: [...this._succeeded],
|
|
60
100
|
failedOperations: [...this._failed],
|
|
61
101
|
mergeStatistics: {
|
|
62
|
-
total: this.
|
|
102
|
+
total: this._totalDifferences,
|
|
63
103
|
succeeded: this._succeeded.length,
|
|
64
104
|
failed: this._failed.length,
|
|
65
105
|
},
|
|
106
|
+
performanceMetrics: {
|
|
107
|
+
totalDurationMs: this._totalDurationMs,
|
|
108
|
+
schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,
|
|
109
|
+
mergeDurationMs: this._mergeDurationMs,
|
|
110
|
+
averageMergeOpDurationMs: this._averageMergeOpDurationMs,
|
|
111
|
+
},
|
|
66
112
|
get success() {
|
|
67
113
|
return this.failedOperations.length === 0;
|
|
68
114
|
},
|
|
@@ -78,6 +124,7 @@ exports.SchemaMergeReporter = SchemaMergeReporter;
|
|
|
78
124
|
class SchemaMerger {
|
|
79
125
|
_editingContext;
|
|
80
126
|
_mergeReporter;
|
|
127
|
+
_differenceStartTime = 0;
|
|
81
128
|
/**
|
|
82
129
|
* Constructs a new instance of the SchemaMerger object.
|
|
83
130
|
* @param editingContext The schema contexts that holds the schema to be edited.
|
|
@@ -94,6 +141,7 @@ class SchemaMerger {
|
|
|
94
141
|
* @alpha
|
|
95
142
|
*/
|
|
96
143
|
async mergeSchemas(targetSchema, sourceSchema, edits) {
|
|
144
|
+
this._differenceStartTime = performance.now();
|
|
97
145
|
return this.merge(await (0, SchemaDifference_1.getSchemaDifferences)(targetSchema, sourceSchema, edits), edits);
|
|
98
146
|
}
|
|
99
147
|
/**
|
|
@@ -103,6 +151,7 @@ class SchemaMerger {
|
|
|
103
151
|
* @alpha
|
|
104
152
|
*/
|
|
105
153
|
async merge(differenceResult, edits) {
|
|
154
|
+
const mergeStartTime = performance.now();
|
|
106
155
|
const targetSchemaKey = ecschema_metadata_1.SchemaKey.parseString(differenceResult.targetSchemaName);
|
|
107
156
|
const sourceSchemaKey = ecschema_metadata_1.SchemaKey.parseString(differenceResult.sourceSchemaName);
|
|
108
157
|
const nameMapping = new NameMapping_1.NameMapping();
|
|
@@ -137,6 +186,18 @@ class SchemaMerger {
|
|
|
137
186
|
const walker = new SchemaMergingWalker_1.SchemaMergingWalker(visitor);
|
|
138
187
|
await walker.traverse(differenceResult.differences, "add");
|
|
139
188
|
await walker.traverse(differenceResult.differences, "modify");
|
|
189
|
+
const mergeEndTime = performance.now();
|
|
190
|
+
// Calculate performance metrics
|
|
191
|
+
const effectiveStartTime = this._differenceStartTime === 0 ? mergeStartTime : this._differenceStartTime;
|
|
192
|
+
const schemaDifferenceDurationMs = mergeStartTime - effectiveStartTime;
|
|
193
|
+
const mergeDurationMs = mergeEndTime - mergeStartTime;
|
|
194
|
+
const totalDurationMs = mergeEndTime - effectiveStartTime;
|
|
195
|
+
this._mergeReporter.setPerformanceMetrics({
|
|
196
|
+
totalDurationMs,
|
|
197
|
+
schemaDifferenceDurationMs,
|
|
198
|
+
mergeDurationMs,
|
|
199
|
+
averageMergeOpDurationMs: this._mergeReporter.mergeStatistics.total > 0 ? mergeDurationMs / this._mergeReporter.mergeStatistics.total : 0,
|
|
200
|
+
});
|
|
140
201
|
return schema;
|
|
141
202
|
}
|
|
142
203
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAA0H;AAC1H,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AAqDl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,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
|
+
{"version":3,"file":"SchemaMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMerger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwH;AACxH,8CAAwD;AACxD,mDAA8D;AAC9D,uEAA0H;AAC1H,iEAA8D;AAC9D,+DAA4D;AAE5D,oDAA2E;AAC3E,qDAAkD;AA8DlD;;GAEG;AACH,MAAa,mBAAmB;IACb,UAAU,GAA2B,EAAE,CAAC;IACxC,OAAO,GAAyB,EAAE,CAAC;IACnC,gBAAgB,CAAY;IAC5B,gBAAgB,CAAY;IAC5B,iBAAiB,CAAS;IACnC,gBAAgB,GAAW,CAAC,CAAC;IAC7B,2BAA2B,GAAW,CAAC,CAAC;IACxC,gBAAgB,GAAW,CAAC,CAAC;IAC7B,yBAAyB,GAAW,CAAC,CAAC;IAE9C,YACE,eAA0B,EAC1B,eAA0B,EAC1B,gBAAwB;QAExB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,CAAC;IAED,IAAW,eAAe;QACxB,OA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AA0B,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 readonly durationMs: number;\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\r\n /** Performance metrics of the merge operation */\r\n readonly performanceMetrics: {\r\n readonly totalDurationMs: number;\r\n readonly schemaDifferenceDurationMs: number;\r\n readonly mergeDurationMs: number;\r\n readonly averageMergeOpDurationMs: 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 private readonly _sourceSchemaKey: SchemaKey;\r\n private readonly _targetSchemaKey: SchemaKey;\r\n private readonly _totalDifferences: number;\r\n private _totalDurationMs: number = 0;\r\n private _schemaDifferenceDurationMs: number = 0;\r\n private _mergeDurationMs: number = 0;\r\n private _averageMergeOpDurationMs: number = 0;\r\n\r\n constructor(\r\n sourceSchemaKey: SchemaKey,\r\n targetSchemaKey: SchemaKey,\r\n totalDifferences: number,\r\n ) {\r\n this._sourceSchemaKey = sourceSchemaKey;\r\n this._targetSchemaKey = targetSchemaKey;\r\n this._totalDifferences = totalDifferences;\r\n }\r\n\r\n public get sourceSchemaKey(): SchemaKey {\r\n return this._sourceSchemaKey;\r\n }\r\n\r\n public get targetSchemaKey(): SchemaKey {\r\n return this._targetSchemaKey;\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 performanceMetrics() {\r\n return {\r\n totalDurationMs: this._totalDurationMs,\r\n schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,\r\n mergeDurationMs: this._mergeDurationMs,\r\n averageMergeOpDurationMs: this._averageMergeOpDurationMs,\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 /**\r\n * Sets the performance metrics for the merge operation.\r\n * @internal\r\n */\r\n public setPerformanceMetrics(metrics: {\r\n totalDurationMs: number;\r\n schemaDifferenceDurationMs: number;\r\n mergeDurationMs: number;\r\n averageMergeOpDurationMs: number;\r\n }): void {\r\n this._totalDurationMs = metrics.totalDurationMs;\r\n this._schemaDifferenceDurationMs = metrics.schemaDifferenceDurationMs;\r\n this._mergeDurationMs = metrics.mergeDurationMs;\r\n this._averageMergeOpDurationMs = metrics.averageMergeOpDurationMs;\r\n }\r\n\r\n /**\r\n * Records a successful merge operation.\r\n * @internal\r\n */\r\n public recordSuccess(change: AnySchemaDifference, durationMs: number): void {\r\n this._succeeded.push({ change, durationMs });\r\n }\r\n\r\n /**\r\n * Records a failed merge operation.\r\n * @internal\r\n */\r\n public recordFailure(change: AnySchemaDifference, durationMs: number, error: Error): void {\r\n this._failed.push({ change, durationMs, error: error.message });\r\n }\r\n\r\n /**\r\n * Returns the merge report.\r\n * @internal\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 performanceMetrics: {\r\n totalDurationMs: this._totalDurationMs,\r\n schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,\r\n mergeDurationMs: this._mergeDurationMs,\r\n averageMergeOpDurationMs: this._averageMergeOpDurationMs,\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 private _differenceStartTime: number = 0;\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 this._differenceStartTime = performance.now();\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 mergeStartTime = performance.now();\r\n\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 const mergeEndTime = performance.now();\r\n\r\n // Calculate performance metrics\r\n const effectiveStartTime = this._differenceStartTime === 0 ? mergeStartTime : this._differenceStartTime;\r\n const schemaDifferenceDurationMs = mergeStartTime - effectiveStartTime;\r\n const mergeDurationMs = mergeEndTime - mergeStartTime;\r\n const totalDurationMs = mergeEndTime - effectiveStartTime;\r\n\r\n this._mergeReporter.setPerformanceMetrics({\r\n totalDurationMs,\r\n schemaDifferenceDurationMs,\r\n mergeDurationMs,\r\n averageMergeOpDurationMs: this._mergeReporter.mergeStatistics.total > 0 ? mergeDurationMs / this._mergeReporter.mergeStatistics.total : 0,\r\n });\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 +1 @@
|
|
|
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;
|
|
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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AAC,IAAI,CAAC;IAM1G;;;OAGG;IACU,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1E;;OAEG;YACW,yBAAyB;IAevC;;;OAGG;IACU,8BAA8B,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5F;;;OAGG;IACU,0BAA0B,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjI;;;OAGG;IACU,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAStE;;;OAGG;IACU,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IASlF;;;MAGE;IACW,+CAA+C,CAAC,KAAK,EAAE,0CAA0C,GAAG,OAAO,CAAC,IAAI,CAAC;CAO/H"}
|
|
@@ -50,12 +50,13 @@ class SchemaMergingVisitor {
|
|
|
50
50
|
if (!this._reporter) {
|
|
51
51
|
return operation();
|
|
52
52
|
}
|
|
53
|
+
const startTime = performance.now();
|
|
53
54
|
try {
|
|
54
55
|
await operation();
|
|
55
|
-
this._reporter.recordSuccess(entry);
|
|
56
|
+
this._reporter.recordSuccess(entry, performance.now() - startTime);
|
|
56
57
|
}
|
|
57
58
|
catch (error) {
|
|
58
|
-
this._reporter.recordFailure(entry, error);
|
|
59
|
+
this._reporter.recordFailure(entry, performance.now() - startTime, error);
|
|
59
60
|
throw error;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":";;;AAaA,qDAA+D;AAC/D,mEAA6D;AAC7D,6EAAmG;AACnG,2DAAwF;AACxF,2DAAwE;AACxE,yDAAqE;AACr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,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;YAC3C,QAAQ,KAAK,CAAC,UAAU,EAAE,CAAC;gBACzB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAA,4CAAqB,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAA,iBAAS,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9YD,oDA8YC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 {\r\n AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference,\r\n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference,\r\n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference,\r\n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference,\r\n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference,\r\n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference,\r\n StructClassDifference, UnitDifference, UnitSystemDifference\r\n} from \"../Differencing/SchemaDifference\";\r\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\r\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\r\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\r\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\r\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\r\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\r\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\r\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\r\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\r\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\r\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\r\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\r\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\r\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\r\nimport { mergePropertyDifference } from \"./PropertyMerger\";\r\nimport { isClassDifference } from \"../Differencing/Utils\";\r\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext, SchemaMergeReporter } from \"./SchemaMerger\";\r\nimport { toItemKey } from \"./Utils\";\r\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\r\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\r\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\r\n\r\n/** Definition of schema items change type handler array. */\r\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\r\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\r\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\r\n * differences to call the appropriated merger methods.\r\n * @internal\r\n */\r\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\r\n\r\n private readonly _context: SchemaMergeContext;\r\n private _reporter?: SchemaMergeReporter;\r\n\r\n /**\r\n * Initializes a new instance of SchemaMergingVisitor class.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Sets the reporter for tracking merge operations.\r\n * @internal\r\n */\r\n public setReporter(reporter: SchemaMergeReporter): void {\r\n this._reporter = reporter;\r\n }\r\n\r\n /**\r\n * Method that wraps the visitor with success/failure tracking.\r\n * @internal\r\n */\r\n private async trackOperation<T extends AnySchemaDifference>(entry: T, operation: () => Promise<void>): Promise<void> {\r\n if (!this._reporter) {\r\n return operation();\r\n }\r\n\r\n try {\r\n await operation();\r\n this._reporter.recordSuccess(entry);\r\n } catch (error: any) {\r\n this._reporter.recordFailure(entry, error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\r\n // To add classes a slightly different approach is done. In fact the class entries gets processed\r\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\r\n // the class gets completed with all properties, mixins, etc...\r\n if (entry.changeType === \"add\" && !await this._context.targetSchema.getItem(entry.itemName)) {\r\n await handler.add(this._context, {\r\n ...entry,\r\n difference: {\r\n ...entry.difference,\r\n // Remove everything we want to validate before setting, this is done in the second iteration.\r\n baseClass: undefined,\r\n mixins: undefined,\r\n properties: undefined,\r\n customAttributes: undefined,\r\n },\r\n });\r\n\r\n // Searches for the last class difference and adds the entry after it. That way,\r\n // the class is completed before class related entries get processed.\r\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\r\n array.splice(insertIndex, 0, entry);\r\n\r\n return;\r\n }\r\n\r\n // Now both a modification change or the second add iteration is a modification of an existing class.\r\n // So, regardless of the actual change type, modify is called.\r\n // This is tracked because it's the actual operation that completes the class.\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: async (context) => handler.modify(context, entry, toItemKey(context, entry.itemName)),\r\n modify: handler.modify,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ConstantDifference.\r\n * @internal\r\n */\r\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeClassDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addCustomAttributeClass,\r\n modify: modifyCustomAttributeClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addEntityClass,\r\n modify: modifyEntityClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassMixinDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumerationDifference.\r\n * @internal\r\n */\r\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumeratorDifference.\r\n * @internal\r\n */\r\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addEnumerator(this._context, entry);\r\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling MixinClassDifference.\r\n * @internal\r\n */\r\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addMixinClass,\r\n modify: modifyMixinClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PhenomenonDifference.\r\n * @internal\r\n */\r\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PropertyCategoryDifference.\r\n * @internal\r\n */\r\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ClassPropertyDifference.\r\n * @internal\r\n */\r\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergePropertyDifference(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addRelationshipClass,\r\n modify: modifyRelationshipClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergeRelationshipClassConstraint(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n await mergeRelationshipConstraint(this._context, entry);\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference(entry: SchemaDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n const { difference } = entry;\r\n if (difference.label !== undefined) {\r\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\r\n }\r\n if (difference.description !== undefined) {\r\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\r\n switch (entry.changeType) {\r\n case \"add\": {\r\n return handler.add(this._context, entry);\r\n }\r\n case \"modify\": {\r\n if (\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\r\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\r\n }\r\n\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaReferenceDifference.\r\n * @internal\r\n */\r\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addSchemaReferences(this._context, entry);\r\n case \"modify\": return modifySchemaReferences(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling StructClassDifference.\r\n * @internal\r\n */\r\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addStructClass,\r\n modify: modifyStructClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitDifference.\r\n * @internal\r\n */\r\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitSystemDifference.\r\n * @internal\r\n */\r\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\r\n * @param array Array to search.\r\n * @param predicate Function to execute on each value in the array.\r\n * @param fromIndex The index to start the search at.\r\n * @returns An index in the array if an element passes the test; otherwise, false.\r\n */\r\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\r\n for (let i = fromIndex; i < array.length; i++) {\r\n if (predicate(array[i]))\r\n return i;\r\n }\r\n return false;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":";;;AAaA,qDAA+D;AAC/D,mEAA6D;AAC7D,6EAAmG;AACnG,2DAAwF;AACxF,2DAAwE;AACxE,yDAAqE;AACrE,iEAAwG;AACxG,+CAAgE;AAChE,yDAAqE;AACrE,qEAAuF;AACvF,uEAAyJ;AACzJ,mEAAsF;AACtF,2DAAwE;AACxE,yDAAqE;AACrE,qDAA2D;AAC3D,iDAA0D;AAI1D,mCAAoC;AACpC,6CAAmD;AACnD,6DAA2E;AAC3E,iDAAkG;AAQlG;;;;GAIG;AACH,MAAa,oBAAoB;IAEd,QAAQ,CAAqB;IACtC,SAAS,CAAuB;IAExC;;OAEG;IACH,YAAY,OAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,QAA6B;QAC9C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,cAAc,CAAgC,KAAQ,EAAE,SAA8B;QAClG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;QAED,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,MAAM,SAAS,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;QACrE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1E,MA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AAM,EAAE,uBAAU;SACnB,CAAC,CACH,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,yBAAyB,CAAC,KAA2B;QAChE,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAC3C,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YACpC,GAAG,EAAE,gCAAa;YAClB,MAAM,EAAE,mCAAgB;SACzB,CAAC,CACH,CAAC;IACJ,CAAC;IAED;;;MAGE;IACK,KAAK,CAAC,+CAA+C,CAAC,KAAiD;QAC5G,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;YAC3C,QAAQ,KAAK,CAAC,UAAU,EAAE,CAAC;gBACzB,KAAK,KAAK,CAAC,CAAC,OAAO,IAAA,4CAAqB,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAA,iBAAS,EAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/YD,oDA+YC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 {\r\n AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference,\r\n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference,\r\n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference,\r\n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference,\r\n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference,\r\n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference,\r\n StructClassDifference, UnitDifference, UnitSystemDifference\r\n} from \"../Differencing/SchemaDifference\";\r\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\r\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\r\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\r\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\r\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\r\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\r\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\r\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\r\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\r\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\r\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\r\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\r\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\r\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\r\nimport { mergePropertyDifference } from \"./PropertyMerger\";\r\nimport { isClassDifference } from \"../Differencing/Utils\";\r\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext, SchemaMergeReporter } from \"./SchemaMerger\";\r\nimport { toItemKey } from \"./Utils\";\r\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\r\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\r\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\r\n\r\n/** Definition of schema items change type handler array. */\r\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\r\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\r\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\r\n * differences to call the appropriated merger methods.\r\n * @internal\r\n */\r\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\r\n\r\n private readonly _context: SchemaMergeContext;\r\n private _reporter?: SchemaMergeReporter;\r\n\r\n /**\r\n * Initializes a new instance of SchemaMergingVisitor class.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Sets the reporter for tracking merge operations.\r\n * @internal\r\n */\r\n public setReporter(reporter: SchemaMergeReporter): void {\r\n this._reporter = reporter;\r\n }\r\n\r\n /**\r\n * Method that wraps the visitor with success/failure tracking.\r\n * @internal\r\n */\r\n private async trackOperation<T extends AnySchemaDifference>(entry: T, operation: () => Promise<void>): Promise<void> {\r\n if (!this._reporter) {\r\n return operation();\r\n }\r\n\r\n const startTime = performance.now();\r\n try {\r\n await operation();\r\n this._reporter.recordSuccess(entry, performance.now() - startTime);\r\n } catch (error: any) {\r\n this._reporter.recordFailure(entry, performance.now() - startTime, error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\r\n // To add classes a slightly different approach is done. In fact the class entries gets processed\r\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\r\n // the class gets completed with all properties, mixins, etc...\r\n if (entry.changeType === \"add\" && !await this._context.targetSchema.getItem(entry.itemName)) {\r\n await handler.add(this._context, {\r\n ...entry,\r\n difference: {\r\n ...entry.difference,\r\n // Remove everything we want to validate before setting, this is done in the second iteration.\r\n baseClass: undefined,\r\n mixins: undefined,\r\n properties: undefined,\r\n customAttributes: undefined,\r\n },\r\n });\r\n\r\n // Searches for the last class difference and adds the entry after it. That way,\r\n // the class is completed before class related entries get processed.\r\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\r\n array.splice(insertIndex, 0, entry);\r\n\r\n return;\r\n }\r\n\r\n // Now both a modification change or the second add iteration is a modification of an existing class.\r\n // So, regardless of the actual change type, modify is called.\r\n // This is tracked because it's the actual operation that completes the class.\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: async (context) => handler.modify(context, entry, toItemKey(context, entry.itemName)),\r\n modify: handler.modify,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ConstantDifference.\r\n * @internal\r\n */\r\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeClassDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addCustomAttributeClass,\r\n modify: modifyCustomAttributeClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addEntityClass,\r\n modify: modifyEntityClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassMixinDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumerationDifference.\r\n * @internal\r\n */\r\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumeratorDifference.\r\n * @internal\r\n */\r\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addEnumerator(this._context, entry);\r\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling MixinClassDifference.\r\n * @internal\r\n */\r\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addMixinClass,\r\n modify: modifyMixinClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PhenomenonDifference.\r\n * @internal\r\n */\r\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PropertyCategoryDifference.\r\n * @internal\r\n */\r\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ClassPropertyDifference.\r\n * @internal\r\n */\r\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergePropertyDifference(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addRelationshipClass,\r\n modify: modifyRelationshipClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergeRelationshipClassConstraint(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n await mergeRelationshipConstraint(this._context, entry);\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference(entry: SchemaDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n const { difference } = entry;\r\n if (difference.label !== undefined) {\r\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\r\n }\r\n if (difference.description !== undefined) {\r\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\r\n switch (entry.changeType) {\r\n case \"add\": {\r\n return handler.add(this._context, entry);\r\n }\r\n case \"modify\": {\r\n if (\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\r\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\r\n }\r\n\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaReferenceDifference.\r\n * @internal\r\n */\r\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addSchemaReferences(this._context, entry);\r\n case \"modify\": return modifySchemaReferences(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling StructClassDifference.\r\n * @internal\r\n */\r\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addStructClass,\r\n modify: modifyStructClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitDifference.\r\n * @internal\r\n */\r\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitSystemDifference.\r\n * @internal\r\n */\r\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\r\n * @param array Array to search.\r\n * @param predicate Function to execute on each value in the array.\r\n * @param fromIndex The index to start the search at.\r\n * @returns An index in the array if an element passes the test; otherwise, false.\r\n */\r\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\r\n for (let i = fromIndex; i < array.length; i++) {\r\n if (predicate(array[i]))\r\n return i;\r\n }\r\n return false;\r\n}\r\n"]}
|
|
@@ -23,6 +23,7 @@ export interface SchemaMergeContext {
|
|
|
23
23
|
*/
|
|
24
24
|
export interface SchemaMergeOperation {
|
|
25
25
|
readonly change: AnySchemaDifference;
|
|
26
|
+
readonly durationMs: number;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Represents a merge operation that failed with an error.
|
|
@@ -50,6 +51,13 @@ export interface SchemaMergeReport {
|
|
|
50
51
|
readonly succeeded: number;
|
|
51
52
|
readonly failed: number;
|
|
52
53
|
};
|
|
54
|
+
/** Performance metrics of the merge operation */
|
|
55
|
+
readonly performanceMetrics: {
|
|
56
|
+
readonly totalDurationMs: number;
|
|
57
|
+
readonly schemaDifferenceDurationMs: number;
|
|
58
|
+
readonly mergeDurationMs: number;
|
|
59
|
+
readonly averageMergeOpDurationMs: number;
|
|
60
|
+
};
|
|
53
61
|
/** Returns true if all operations succeeded */
|
|
54
62
|
readonly success: boolean;
|
|
55
63
|
}
|
|
@@ -57,12 +65,18 @@ export interface SchemaMergeReport {
|
|
|
57
65
|
* @internal
|
|
58
66
|
*/
|
|
59
67
|
export declare class SchemaMergeReporter implements SchemaMergeReport {
|
|
60
|
-
readonly sourceSchemaKey: SchemaKey;
|
|
61
|
-
readonly targetSchemaKey: SchemaKey;
|
|
62
|
-
readonly totalDifferences: number;
|
|
63
68
|
private readonly _succeeded;
|
|
64
69
|
private readonly _failed;
|
|
70
|
+
private readonly _sourceSchemaKey;
|
|
71
|
+
private readonly _targetSchemaKey;
|
|
72
|
+
private readonly _totalDifferences;
|
|
73
|
+
private _totalDurationMs;
|
|
74
|
+
private _schemaDifferenceDurationMs;
|
|
75
|
+
private _mergeDurationMs;
|
|
76
|
+
private _averageMergeOpDurationMs;
|
|
65
77
|
constructor(sourceSchemaKey: SchemaKey, targetSchemaKey: SchemaKey, totalDifferences: number);
|
|
78
|
+
get sourceSchemaKey(): SchemaKey;
|
|
79
|
+
get targetSchemaKey(): SchemaKey;
|
|
66
80
|
get successfulOperations(): SchemaMergeOperation[];
|
|
67
81
|
get failedOperations(): SchemaMergeFailure[];
|
|
68
82
|
get mergeStatistics(): {
|
|
@@ -70,9 +84,37 @@ export declare class SchemaMergeReporter implements SchemaMergeReport {
|
|
|
70
84
|
succeeded: number;
|
|
71
85
|
failed: number;
|
|
72
86
|
};
|
|
87
|
+
get performanceMetrics(): {
|
|
88
|
+
totalDurationMs: number;
|
|
89
|
+
schemaDifferenceDurationMs: number;
|
|
90
|
+
mergeDurationMs: number;
|
|
91
|
+
averageMergeOpDurationMs: number;
|
|
92
|
+
};
|
|
73
93
|
get success(): boolean;
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Sets the performance metrics for the merge operation.
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
setPerformanceMetrics(metrics: {
|
|
99
|
+
totalDurationMs: number;
|
|
100
|
+
schemaDifferenceDurationMs: number;
|
|
101
|
+
mergeDurationMs: number;
|
|
102
|
+
averageMergeOpDurationMs: number;
|
|
103
|
+
}): void;
|
|
104
|
+
/**
|
|
105
|
+
* Records a successful merge operation.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
recordSuccess(change: AnySchemaDifference, durationMs: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Records a failed merge operation.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
recordFailure(change: AnySchemaDifference, durationMs: number, error: Error): void;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the merge report.
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
76
118
|
getMergeReport(): SchemaMergeReport;
|
|
77
119
|
}
|
|
78
120
|
/**
|
|
@@ -83,6 +125,7 @@ export declare class SchemaMergeReporter implements SchemaMergeReport {
|
|
|
83
125
|
export declare class SchemaMerger {
|
|
84
126
|
private readonly _editingContext;
|
|
85
127
|
private _mergeReporter;
|
|
128
|
+
private _differenceStartTime;
|
|
86
129
|
/**
|
|
87
130
|
* Constructs a new instance of the SchemaMerger object.
|
|
88
131
|
* @param editingContext The schema contexts that holds the schema to be edited.
|
|
@@ -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,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAwB,KAAK,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG1H,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;A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;;;MAMzB;IAED,IAAW,kBAAkB;;;;;MAO5B;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;OAGG;IACI,qBAAqB,CAAC,OAAO,EAAE;QACpC,eAAe,EAAE,MAAM,CAAC;QACxB,0BAA0B,EAAE,MAAM,CAAC;QACnC,eAAe,EAAE,MAAM,CAAC;QACxB,wBAAwB,EAAE,MAAM,CAAC;KAClC,GAAG,IAAI;IAOR;;;OAGG;IACI,aAAa,CAAC,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAI3E;;;OAGG;IACI,aAAa,CAAC,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAIzF;;;OAGG;IACI,cAAc,IAAI,iBAAiB;CAsB3C;AAED;;;;GAIG;AACH,qBAAa,YAAY;IAEvB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgB;IAChD,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,oBAAoB,CAAa;IAEzC;;;OAGG;gBACS,cAAc,EAAE,aAAa;IAIzC;;;;;;;OAOG;IACU,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAK3G;;;;;OAKG;IACU,KAAK,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAqElG;;;OAGG;IACI,cAAc,IAAI,iBAAiB,GAAG,SAAS;CAGvD"}
|
|
@@ -17,15 +17,25 @@ import { NameMapping } from "./Edits/NameMapping";
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export class SchemaMergeReporter {
|
|
20
|
-
sourceSchemaKey;
|
|
21
|
-
targetSchemaKey;
|
|
22
|
-
totalDifferences;
|
|
23
20
|
_succeeded = [];
|
|
24
21
|
_failed = [];
|
|
22
|
+
_sourceSchemaKey;
|
|
23
|
+
_targetSchemaKey;
|
|
24
|
+
_totalDifferences;
|
|
25
|
+
_totalDurationMs = 0;
|
|
26
|
+
_schemaDifferenceDurationMs = 0;
|
|
27
|
+
_mergeDurationMs = 0;
|
|
28
|
+
_averageMergeOpDurationMs = 0;
|
|
25
29
|
constructor(sourceSchemaKey, targetSchemaKey, totalDifferences) {
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
30
|
+
this._sourceSchemaKey = sourceSchemaKey;
|
|
31
|
+
this._targetSchemaKey = targetSchemaKey;
|
|
32
|
+
this._totalDifferences = totalDifferences;
|
|
33
|
+
}
|
|
34
|
+
get sourceSchemaKey() {
|
|
35
|
+
return this._sourceSchemaKey;
|
|
36
|
+
}
|
|
37
|
+
get targetSchemaKey() {
|
|
38
|
+
return this._targetSchemaKey;
|
|
29
39
|
}
|
|
30
40
|
get successfulOperations() {
|
|
31
41
|
return [...this._succeeded];
|
|
@@ -35,31 +45,67 @@ export class SchemaMergeReporter {
|
|
|
35
45
|
}
|
|
36
46
|
get mergeStatistics() {
|
|
37
47
|
return {
|
|
38
|
-
total: this.
|
|
48
|
+
total: this._totalDifferences,
|
|
39
49
|
succeeded: this._succeeded.length,
|
|
40
50
|
failed: this._failed.length,
|
|
41
51
|
};
|
|
42
52
|
}
|
|
53
|
+
get performanceMetrics() {
|
|
54
|
+
return {
|
|
55
|
+
totalDurationMs: this._totalDurationMs,
|
|
56
|
+
schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,
|
|
57
|
+
mergeDurationMs: this._mergeDurationMs,
|
|
58
|
+
averageMergeOpDurationMs: this._averageMergeOpDurationMs,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
43
61
|
get success() {
|
|
44
62
|
return this._failed.length === 0;
|
|
45
63
|
}
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Sets the performance metrics for the merge operation.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
setPerformanceMetrics(metrics) {
|
|
69
|
+
this._totalDurationMs = metrics.totalDurationMs;
|
|
70
|
+
this._schemaDifferenceDurationMs = metrics.schemaDifferenceDurationMs;
|
|
71
|
+
this._mergeDurationMs = metrics.mergeDurationMs;
|
|
72
|
+
this._averageMergeOpDurationMs = metrics.averageMergeOpDurationMs;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Records a successful merge operation.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
recordSuccess(change, durationMs) {
|
|
79
|
+
this._succeeded.push({ change, durationMs });
|
|
48
80
|
}
|
|
49
|
-
|
|
50
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Records a failed merge operation.
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
recordFailure(change, durationMs, error) {
|
|
86
|
+
this._failed.push({ change, durationMs, error: error.message });
|
|
51
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the merge report.
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
52
92
|
getMergeReport() {
|
|
53
93
|
return {
|
|
54
|
-
sourceSchemaKey: this.
|
|
55
|
-
targetSchemaKey: this.
|
|
94
|
+
sourceSchemaKey: this._sourceSchemaKey,
|
|
95
|
+
targetSchemaKey: this._targetSchemaKey,
|
|
56
96
|
successfulOperations: [...this._succeeded],
|
|
57
97
|
failedOperations: [...this._failed],
|
|
58
98
|
mergeStatistics: {
|
|
59
|
-
total: this.
|
|
99
|
+
total: this._totalDifferences,
|
|
60
100
|
succeeded: this._succeeded.length,
|
|
61
101
|
failed: this._failed.length,
|
|
62
102
|
},
|
|
103
|
+
performanceMetrics: {
|
|
104
|
+
totalDurationMs: this._totalDurationMs,
|
|
105
|
+
schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,
|
|
106
|
+
mergeDurationMs: this._mergeDurationMs,
|
|
107
|
+
averageMergeOpDurationMs: this._averageMergeOpDurationMs,
|
|
108
|
+
},
|
|
63
109
|
get success() {
|
|
64
110
|
return this.failedOperations.length === 0;
|
|
65
111
|
},
|
|
@@ -74,6 +120,7 @@ export class SchemaMergeReporter {
|
|
|
74
120
|
export class SchemaMerger {
|
|
75
121
|
_editingContext;
|
|
76
122
|
_mergeReporter;
|
|
123
|
+
_differenceStartTime = 0;
|
|
77
124
|
/**
|
|
78
125
|
* Constructs a new instance of the SchemaMerger object.
|
|
79
126
|
* @param editingContext The schema contexts that holds the schema to be edited.
|
|
@@ -90,6 +137,7 @@ export class SchemaMerger {
|
|
|
90
137
|
* @alpha
|
|
91
138
|
*/
|
|
92
139
|
async mergeSchemas(targetSchema, sourceSchema, edits) {
|
|
140
|
+
this._differenceStartTime = performance.now();
|
|
93
141
|
return this.merge(await getSchemaDifferences(targetSchema, sourceSchema, edits), edits);
|
|
94
142
|
}
|
|
95
143
|
/**
|
|
@@ -99,6 +147,7 @@ export class SchemaMerger {
|
|
|
99
147
|
* @alpha
|
|
100
148
|
*/
|
|
101
149
|
async merge(differenceResult, edits) {
|
|
150
|
+
const mergeStartTime = performance.now();
|
|
102
151
|
const targetSchemaKey = SchemaKey.parseString(differenceResult.targetSchemaName);
|
|
103
152
|
const sourceSchemaKey = SchemaKey.parseString(differenceResult.sourceSchemaName);
|
|
104
153
|
const nameMapping = new NameMapping();
|
|
@@ -133,6 +182,18 @@ export class SchemaMerger {
|
|
|
133
182
|
const walker = new SchemaMergingWalker(visitor);
|
|
134
183
|
await walker.traverse(differenceResult.differences, "add");
|
|
135
184
|
await walker.traverse(differenceResult.differences, "modify");
|
|
185
|
+
const mergeEndTime = performance.now();
|
|
186
|
+
// Calculate performance metrics
|
|
187
|
+
const effectiveStartTime = this._differenceStartTime === 0 ? mergeStartTime : this._differenceStartTime;
|
|
188
|
+
const schemaDifferenceDurationMs = mergeStartTime - effectiveStartTime;
|
|
189
|
+
const mergeDurationMs = mergeEndTime - mergeStartTime;
|
|
190
|
+
const totalDurationMs = mergeEndTime - effectiveStartTime;
|
|
191
|
+
this._mergeReporter.setPerformanceMetrics({
|
|
192
|
+
totalDurationMs,
|
|
193
|
+
schemaDifferenceDurationMs,
|
|
194
|
+
mergeDurationMs,
|
|
195
|
+
averageMergeOpDurationMs: this._mergeReporter.mergeStatistics.total > 0 ? mergeDurationMs / this._mergeReporter.mergeStatistics.total : 0,
|
|
196
|
+
});
|
|
136
197
|
return schema;
|
|
137
198
|
}
|
|
138
199
|
/**
|
|
@@ -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,EAAuB,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AAC1H,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;AAqDlD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAKZ;IACA;IACA;IAND,UAAU,GAA2B,EAAE,CAAC;IACxC,OAAO,GAAyB,EAAE,CAAC;IAEpD,YACkB,eAA0B,EAC1B,eAA0B,EAC1B,gBAAwB;QAFxB,oBAAe,GAAf,eAAe,CAAW;QAC1B,oBAAe,GAAf,eAAe,CAAW;QAC1B,qBAAgB,GAAhB,gBAAgB,CAAQ;IACtC,CAAC;IAEL,IAAW,oBAAoB;QAC7B,OAAO,CAAC,GAAG,IAAI,CAA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,WAAW,CAAC;IACnC,CAAC;IAEe,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA2B;QACrF,OAAO,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrE,CAAC;IAEe,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA2B;QAC/E,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/D,CAAC;IAEe,KAAK,CAAC,aAAa,CAA8B,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
|
+
{"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,EAAuB,oBAAoB,EAA+B,MAAM,kCAAkC,CAAC;AAC1H,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;AA8DlD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IACb,UAAU,GAA2B,EAAE,CAAC;IACxC,OAAO,GAAyB,EAAE,CAAC;IACnC,gBAAgB,CAAY;IAC5B,gBAAgB,CAAY;IAC5B,iBAAiB,CAAS;IACnC,gBAAgB,GAAW,CAAC,CAAC;IAC7B,2BAA2B,GAAW,CAAC,CAAC;IACxC,gBAAgB,GAAW,CAAC,CAAC;IAC7B,yBAAyB,GAAW,CAAC,CAAC;IAE9C,YACE,eAA0B,EAC1B,eAA0B,EAC1B,gBAAwB;QAExB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;IAC5C,CAAC;IAED,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,gBAAg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,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 readonly durationMs: number;\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\r\n /** Performance metrics of the merge operation */\r\n readonly performanceMetrics: {\r\n readonly totalDurationMs: number;\r\n readonly schemaDifferenceDurationMs: number;\r\n readonly mergeDurationMs: number;\r\n readonly averageMergeOpDurationMs: 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 private readonly _sourceSchemaKey: SchemaKey;\r\n private readonly _targetSchemaKey: SchemaKey;\r\n private readonly _totalDifferences: number;\r\n private _totalDurationMs: number = 0;\r\n private _schemaDifferenceDurationMs: number = 0;\r\n private _mergeDurationMs: number = 0;\r\n private _averageMergeOpDurationMs: number = 0;\r\n\r\n constructor(\r\n sourceSchemaKey: SchemaKey,\r\n targetSchemaKey: SchemaKey,\r\n totalDifferences: number,\r\n ) {\r\n this._sourceSchemaKey = sourceSchemaKey;\r\n this._targetSchemaKey = targetSchemaKey;\r\n this._totalDifferences = totalDifferences;\r\n }\r\n\r\n public get sourceSchemaKey(): SchemaKey {\r\n return this._sourceSchemaKey;\r\n }\r\n\r\n public get targetSchemaKey(): SchemaKey {\r\n return this._targetSchemaKey;\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 performanceMetrics() {\r\n return {\r\n totalDurationMs: this._totalDurationMs,\r\n schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,\r\n mergeDurationMs: this._mergeDurationMs,\r\n averageMergeOpDurationMs: this._averageMergeOpDurationMs,\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 /**\r\n * Sets the performance metrics for the merge operation.\r\n * @internal\r\n */\r\n public setPerformanceMetrics(metrics: {\r\n totalDurationMs: number;\r\n schemaDifferenceDurationMs: number;\r\n mergeDurationMs: number;\r\n averageMergeOpDurationMs: number;\r\n }): void {\r\n this._totalDurationMs = metrics.totalDurationMs;\r\n this._schemaDifferenceDurationMs = metrics.schemaDifferenceDurationMs;\r\n this._mergeDurationMs = metrics.mergeDurationMs;\r\n this._averageMergeOpDurationMs = metrics.averageMergeOpDurationMs;\r\n }\r\n\r\n /**\r\n * Records a successful merge operation.\r\n * @internal\r\n */\r\n public recordSuccess(change: AnySchemaDifference, durationMs: number): void {\r\n this._succeeded.push({ change, durationMs });\r\n }\r\n\r\n /**\r\n * Records a failed merge operation.\r\n * @internal\r\n */\r\n public recordFailure(change: AnySchemaDifference, durationMs: number, error: Error): void {\r\n this._failed.push({ change, durationMs, error: error.message });\r\n }\r\n\r\n /**\r\n * Returns the merge report.\r\n * @internal\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 performanceMetrics: {\r\n totalDurationMs: this._totalDurationMs,\r\n schemaDifferenceDurationMs: this._schemaDifferenceDurationMs,\r\n mergeDurationMs: this._mergeDurationMs,\r\n averageMergeOpDurationMs: this._averageMergeOpDurationMs,\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 private _differenceStartTime: number = 0;\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 this._differenceStartTime = performance.now();\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 mergeStartTime = performance.now();\r\n\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 const mergeEndTime = performance.now();\r\n\r\n // Calculate performance metrics\r\n const effectiveStartTime = this._differenceStartTime === 0 ? mergeStartTime : this._differenceStartTime;\r\n const schemaDifferenceDurationMs = mergeStartTime - effectiveStartTime;\r\n const mergeDurationMs = mergeEndTime - mergeStartTime;\r\n const totalDurationMs = mergeEndTime - effectiveStartTime;\r\n\r\n this._mergeReporter.setPerformanceMetrics({\r\n totalDurationMs,\r\n schemaDifferenceDurationMs,\r\n mergeDurationMs,\r\n averageMergeOpDurationMs: this._mergeReporter.mergeStatistics.total > 0 ? mergeDurationMs / this._mergeReporter.mergeStatistics.total : 0,\r\n });\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 +1 @@
|
|
|
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;
|
|
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,E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AE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1E;;OAEG;YACW,yBAAyB;IAevC;;;OAGG;IACU,8BAA8B,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5F;;;OAGG;IACU,0BAA0B,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjI;;;OAGG;IACU,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAStE;;;OAGG;IACU,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IASlF;;;MAGE;IACW,+CAA+C,CAAC,KAAK,EAAE,0CAA0C,GAAG,OAAO,CAAC,IAAI,CAAC;CAO/H"}
|
|
@@ -47,12 +47,13 @@ export class SchemaMergingVisitor {
|
|
|
47
47
|
if (!this._reporter) {
|
|
48
48
|
return operation();
|
|
49
49
|
}
|
|
50
|
+
const startTime = performance.now();
|
|
50
51
|
try {
|
|
51
52
|
await operation();
|
|
52
|
-
this._reporter.recordSuccess(entry);
|
|
53
|
+
this._reporter.recordSuccess(entry, performance.now() - startTime);
|
|
53
54
|
}
|
|
54
55
|
catch (error) {
|
|
55
|
-
this._reporter.recordFailure(entry, error);
|
|
56
|
+
this._reporter.recordFailure(entry, performance.now() - startTime, error);
|
|
56
57
|
throw error;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,0BA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tH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 {\r\n AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference,\r\n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference,\r\n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference,\r\n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference,\r\n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference,\r\n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference,\r\n StructClassDifference, UnitDifference, UnitSystemDifference\r\n} from \"../Differencing/SchemaDifference\";\r\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\r\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\r\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\r\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\r\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\r\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\r\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\r\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\r\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\r\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\r\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\r\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\r\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\r\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\r\nimport { mergePropertyDifference } from \"./PropertyMerger\";\r\nimport { isClassDifference } from \"../Differencing/Utils\";\r\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext, SchemaMergeReporter } from \"./SchemaMerger\";\r\nimport { toItemKey } from \"./Utils\";\r\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\r\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\r\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\r\n\r\n/** Definition of schema items change type handler array. */\r\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\r\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\r\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\r\n * differences to call the appropriated merger methods.\r\n * @internal\r\n */\r\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\r\n\r\n private readonly _context: SchemaMergeContext;\r\n private _reporter?: SchemaMergeReporter;\r\n\r\n /**\r\n * Initializes a new instance of SchemaMergingVisitor class.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Sets the reporter for tracking merge operations.\r\n * @internal\r\n */\r\n public setReporter(reporter: SchemaMergeReporter): void {\r\n this._reporter = reporter;\r\n }\r\n\r\n /**\r\n * Method that wraps the visitor with success/failure tracking.\r\n * @internal\r\n */\r\n private async trackOperation<T extends AnySchemaDifference>(entry: T, operation: () => Promise<void>): Promise<void> {\r\n if (!this._reporter) {\r\n return operation();\r\n }\r\n\r\n try {\r\n await operation();\r\n this._reporter.recordSuccess(entry);\r\n } catch (error: any) {\r\n this._reporter.recordFailure(entry, error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\r\n // To add classes a slightly different approach is done. In fact the class entries gets processed\r\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\r\n // the class gets completed with all properties, mixins, etc...\r\n if (entry.changeType === \"add\" && !await this._context.targetSchema.getItem(entry.itemName)) {\r\n await handler.add(this._context, {\r\n ...entry,\r\n difference: {\r\n ...entry.difference,\r\n // Remove everything we want to validate before setting, this is done in the second iteration.\r\n baseClass: undefined,\r\n mixins: undefined,\r\n properties: undefined,\r\n customAttributes: undefined,\r\n },\r\n });\r\n\r\n // Searches for the last class difference and adds the entry after it. That way,\r\n // the class is completed before class related entries get processed.\r\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\r\n array.splice(insertIndex, 0, entry);\r\n\r\n return;\r\n }\r\n\r\n // Now both a modification change or the second add iteration is a modification of an existing class.\r\n // So, regardless of the actual change type, modify is called.\r\n // This is tracked because it's the actual operation that completes the class.\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: async (context) => handler.modify(context, entry, toItemKey(context, entry.itemName)),\r\n modify: handler.modify,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ConstantDifference.\r\n * @internal\r\n */\r\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeClassDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addCustomAttributeClass,\r\n modify: modifyCustomAttributeClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addEntityClass,\r\n modify: modifyEntityClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassMixinDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumerationDifference.\r\n * @internal\r\n */\r\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumeratorDifference.\r\n * @internal\r\n */\r\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addEnumerator(this._context, entry);\r\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling MixinClassDifference.\r\n * @internal\r\n */\r\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addMixinClass,\r\n modify: modifyMixinClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PhenomenonDifference.\r\n * @internal\r\n */\r\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PropertyCategoryDifference.\r\n * @internal\r\n */\r\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ClassPropertyDifference.\r\n * @internal\r\n */\r\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergePropertyDifference(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addRelationshipClass,\r\n modify: modifyRelationshipClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergeRelationshipClassConstraint(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n await mergeRelationshipConstraint(this._context, entry);\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference(entry: SchemaDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n const { difference } = entry;\r\n if (difference.label !== undefined) {\r\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\r\n }\r\n if (difference.description !== undefined) {\r\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\r\n switch (entry.changeType) {\r\n case \"add\": {\r\n return handler.add(this._context, entry);\r\n }\r\n case \"modify\": {\r\n if (\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\r\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\r\n }\r\n\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaReferenceDifference.\r\n * @internal\r\n */\r\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addSchemaReferences(this._context, entry);\r\n case \"modify\": return modifySchemaReferences(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling StructClassDifference.\r\n * @internal\r\n */\r\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addStructClass,\r\n modify: modifyStructClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitDifference.\r\n * @internal\r\n */\r\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitSystemDifference.\r\n * @internal\r\n */\r\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\r\n * @param array Array to search.\r\n * @param predicate Function to execute on each value in the array.\r\n * @param fromIndex The index to start the search at.\r\n * @returns An index in the array if an element passes the test; otherwise, false.\r\n */\r\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\r\n for (let i = fromIndex; i < array.length; i++) {\r\n if (predicate(array[i]))\r\n return i;\r\n }\r\n return false;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qB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CAAC,KAA4B,EAAE,SAAkD,EAAE,SAAiB;IACtH,KAAK,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 {\r\n AnyClassItemDifference, AnySchemaDifference, AnySchemaItemDifference, ClassPropertyDifference,\r\n ConstantDifference, CustomAttributeClassDifference, CustomAttributeDifference, EntityClassDifference,\r\n EntityClassMixinDifference, EnumerationDifference, EnumeratorDifference, FormatDifference, FormatUnitDifference,\r\n FormatUnitLabelDifference, InvertedUnitDifference, KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference,\r\n MixinClassDifference, PhenomenonDifference, PropertyCategoryDifference, RelationshipClassDifference,\r\n RelationshipConstraintClassDifference, RelationshipConstraintDifference, SchemaDifference, SchemaReferenceDifference,\r\n StructClassDifference, UnitDifference, UnitSystemDifference\r\n} from \"../Differencing/SchemaDifference\";\r\nimport { addConstant, modifyConstant } from \"./ConstantMerger\";\r\nimport { addCustomAttribute } from \"./CustomAttributeMerger\";\r\nimport { addCustomAttributeClass, modifyCustomAttributeClass } from \"./CustomAttributeClassMerger\";\r\nimport { addClassMixins, addEntityClass, modifyEntityClass } from \"./EntityClassMerger\";\r\nimport { addEnumeration, modifyEnumeration } from \"./EnumerationMerger\";\r\nimport { addEnumerator, modifyEnumerator } from \"./EnumeratorMerger\";\r\nimport { addKindOfQuantity, addPresentationFormat, modifyKindOfQuantity } from \"./KindOfQuantityMerger\";\r\nimport { addMixinClass, modifyMixinClass } from \"./MixinMerger\";\r\nimport { addPhenomenon, modifyPhenomenon } from \"./PhenomenonMerger\";\r\nimport { addPropertyCategory, modifyPropertyCategory } from \"./PropertyCategoryMerger\";\r\nimport { addRelationshipClass, mergeRelationshipClassConstraint, mergeRelationshipConstraint, modifyRelationshipClass } from \"./RelationshipClassMerger\";\r\nimport { addSchemaReferences, modifySchemaReferences } from \"./SchemaReferenceMerger\";\r\nimport { addStructClass, modifyStructClass } from \"./StructClassMerger\";\r\nimport { addUnitSystem, modifyUnitSystem } from \"./UnitSystemMerger\";\r\nimport { mergePropertyDifference } from \"./PropertyMerger\";\r\nimport { isClassDifference } from \"../Differencing/Utils\";\r\nimport { SchemaDifferenceVisitor } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaMergeContext, SchemaMergeReporter } from \"./SchemaMerger\";\r\nimport { toItemKey } from \"./Utils\";\r\nimport { addUnit, modifyUnit } from \"./UnitMerger\";\r\nimport { addInvertedUnit, modifyInvertedUnit } from \"./InvertedUnitMerger\";\r\nimport { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from \"./FormatMerger\";\r\n\r\n/** Definition of schema items change type handler array. */\r\ninterface ItemChangeTypeHandler<T extends AnySchemaDifference> {\r\n add: (context: SchemaMergeContext, entry: T) => Promise<void>;\r\n modify: (context: SchemaMergeContext, entry: T, key: SchemaItemKey) => Promise<void>;\r\n}\r\n\r\n/**\r\n * Implementation of ISchemaDifferenceVisitor that can be used to traverse schema\r\n * differences to call the appropriated merger methods.\r\n * @internal\r\n */\r\nexport class SchemaMergingVisitor implements SchemaDifferenceVisitor {\r\n\r\n private readonly _context: SchemaMergeContext;\r\n private _reporter?: SchemaMergeReporter;\r\n\r\n /**\r\n * Initializes a new instance of SchemaMergingVisitor class.\r\n */\r\n constructor(context: SchemaMergeContext) {\r\n this._context = context;\r\n }\r\n\r\n /**\r\n * Sets the reporter for tracking merge operations.\r\n * @internal\r\n */\r\n public setReporter(reporter: SchemaMergeReporter): void {\r\n this._reporter = reporter;\r\n }\r\n\r\n /**\r\n * Method that wraps the visitor with success/failure tracking.\r\n * @internal\r\n */\r\n private async trackOperation<T extends AnySchemaDifference>(entry: T, operation: () => Promise<void>): Promise<void> {\r\n if (!this._reporter) {\r\n return operation();\r\n }\r\n\r\n const startTime = performance.now();\r\n try {\r\n await operation();\r\n this._reporter.recordSuccess(entry, performance.now() - startTime);\r\n } catch (error: any) {\r\n this._reporter.recordFailure(entry, performance.now() - startTime, error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of ClassItemDifference union.\r\n */\r\n private async visitClassDifference<T extends AnyClassItemDifference>(entry: T, index: number, array: AnySchemaDifference[], handler: ItemChangeTypeHandler<T>) {\r\n // To add classes a slightly different approach is done. In fact the class entries gets processed\r\n // two times. The first time, a stub with the bare minimum is added to the schema. The second time,\r\n // the class gets completed with all properties, mixins, etc...\r\n if (entry.changeType === \"add\" && !await this._context.targetSchema.getItem(entry.itemName)) {\r\n await handler.add(this._context, {\r\n ...entry,\r\n difference: {\r\n ...entry.difference,\r\n // Remove everything we want to validate before setting, this is done in the second iteration.\r\n baseClass: undefined,\r\n mixins: undefined,\r\n properties: undefined,\r\n customAttributes: undefined,\r\n },\r\n });\r\n\r\n // Searches for the last class difference and adds the entry after it. That way,\r\n // the class is completed before class related entries get processed.\r\n const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;\r\n array.splice(insertIndex, 0, entry);\r\n\r\n return;\r\n }\r\n\r\n // Now both a modification change or the second add iteration is a modification of an existing class.\r\n // So, regardless of the actual change type, modify is called.\r\n // This is tracked because it's the actual operation that completes the class.\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: async (context) => handler.modify(context, entry, toItemKey(context, entry.itemName)),\r\n modify: handler.modify,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ConstantDifference.\r\n * @internal\r\n */\r\n public async visitConstantDifference(entry: ConstantDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeClassDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeClassDifference(entry: CustomAttributeClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addCustomAttributeClass,\r\n modify: modifyCustomAttributeClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling CustomAttributeDifference.\r\n * @internal\r\n */\r\n public async visitCustomAttributeInstanceDifference(entry: CustomAttributeDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassDifference(entry: EntityClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addEntityClass,\r\n modify: modifyEntityClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EntityClassMixinDifference.\r\n * @internal\r\n */\r\n public async visitEntityClassMixinDifference(entry: EntityClassMixinDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumerationDifference.\r\n * @internal\r\n */\r\n public async visitEnumerationDifference(entry: EnumerationDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling EnumeratorDifference.\r\n * @internal\r\n */\r\n public async visitEnumeratorDifference(entry: EnumeratorDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addEnumerator(this._context, entry);\r\n case \"modify\": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitDifference(entry: FormatUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"modify\": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityDifference(entry: KindOfQuantityDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling MixinClassDifference.\r\n * @internal\r\n */\r\n public async visitMixinDifference(entry: MixinClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addMixinClass,\r\n modify: modifyMixinClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PhenomenonDifference.\r\n * @internal\r\n */\r\n public async visitPhenomenonDifference(entry: PhenomenonDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling PropertyCategoryDifference.\r\n * @internal\r\n */\r\n public async visitPropertyCategoryDifference(entry: PropertyCategoryDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling ClassPropertyDifference.\r\n * @internal\r\n */\r\n public async visitPropertyDifference(entry: ClassPropertyDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergePropertyDifference(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipClassDifference(entry: RelationshipClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addRelationshipClass,\r\n modify: modifyRelationshipClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintClassDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintClassDifference(entry: RelationshipConstraintClassDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n mergeRelationshipClassConstraint(this._context, entry)\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling RelationshipConstraintDifference.\r\n * @internal\r\n */\r\n public async visitRelationshipConstraintDifference(entry: RelationshipConstraintDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n await mergeRelationshipConstraint(this._context, entry);\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference(entry: SchemaDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n const { difference } = entry;\r\n if (difference.label !== undefined) {\r\n await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);\r\n }\r\n if (difference.description !== undefined) {\r\n await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Shared merging logic for all types of AnySchemaItemDifference union.\r\n */\r\n private async visitSchemaItemDifference<T extends AnySchemaItemDifference>(entry: T, handler: ItemChangeTypeHandler<T>) {\r\n switch (entry.changeType) {\r\n case \"add\": {\r\n return handler.add(this._context, entry);\r\n }\r\n case \"modify\": {\r\n if (\"schemaItemType\" in entry.difference && entry.difference.schemaItemType !== entry.schemaType) {\r\n throw new Error(`Changing the type of item '${entry.itemName}' not supported.`);\r\n }\r\n\r\n return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaReferenceDifference.\r\n * @internal\r\n */\r\n public async visitSchemaReferenceDifference(entry: SchemaReferenceDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addSchemaReferences(this._context, entry);\r\n case \"modify\": return modifySchemaReferences(this._context, entry);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling StructClassDifference.\r\n * @internal\r\n */\r\n public async visitStructClassDifference(entry: StructClassDifference, index: number, array: AnySchemaDifference[]): Promise<void> {\r\n return this.visitClassDifference(entry, index, array, {\r\n add: addStructClass,\r\n modify: modifyStructClass,\r\n });\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitDifference.\r\n * @internal\r\n */\r\n public async visitUnitDifference(entry: UnitDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling UnitSystemDifference.\r\n * @internal\r\n */\r\n public async visitUnitSystemDifference(entry: UnitSystemDifference): Promise<void> {\r\n return this.trackOperation(entry, async () =>\r\n this.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.\r\n * @internal\r\n */\r\n public async visitKindOfQuantityPresentationFormatDifference(entry: KindOfQuantityPresentationFormatDifference): Promise<void> {\r\n return this.trackOperation(entry, async () => {\r\n switch (entry.changeType) {\r\n case \"add\": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Helper method to get the index of the first element in the array that satisfies the provided testing function.\r\n * @param array Array to search.\r\n * @param predicate Function to execute on each value in the array.\r\n * @param fromIndex The index to start the search at.\r\n * @returns An index in the array if an element passes the test; otherwise, false.\r\n */\r\nfunction findIndexOf(array: AnySchemaDifference[], predicate: (entry: AnySchemaDifference) => boolean, fromIndex: number) {\r\n for (let i = fromIndex; i < array.length; i++) {\r\n if (predicate(array[i]))\r\n return i;\r\n }\r\n return false;\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/ecschema-editing",
|
|
3
|
-
"version": "5.7.0-dev.
|
|
3
|
+
"version": "5.7.0-dev.8",
|
|
4
4
|
"description": "ECSchema editing and validation API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/ecschema-editing.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"rimraf": "^6.0.1",
|
|
43
43
|
"sinon": "^17.0.2",
|
|
44
44
|
"typescript": "~5.6.2",
|
|
45
|
-
"@itwin/build-tools": "5.7.0-dev.
|
|
46
|
-
"@itwin/core-bentley": "5.7.0-dev.
|
|
47
|
-
"@itwin/
|
|
48
|
-
"@itwin/
|
|
49
|
-
"@itwin/core-
|
|
45
|
+
"@itwin/build-tools": "5.7.0-dev.8",
|
|
46
|
+
"@itwin/core-bentley": "5.7.0-dev.8",
|
|
47
|
+
"@itwin/ecschema-metadata": "5.7.0-dev.8",
|
|
48
|
+
"@itwin/core-common": "5.7.0-dev.8",
|
|
49
|
+
"@itwin/core-quantity": "5.7.0-dev.8"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@itwin/core-bentley": "5.7.0-dev.
|
|
53
|
-
"@itwin/
|
|
54
|
-
"@itwin/
|
|
52
|
+
"@itwin/core-bentley": "5.7.0-dev.8",
|
|
53
|
+
"@itwin/ecschema-metadata": "5.7.0-dev.8",
|
|
54
|
+
"@itwin/core-quantity": "5.7.0-dev.8"
|
|
55
55
|
},
|
|
56
56
|
"nyc": {
|
|
57
57
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|