@itwin/ecschema-editing 5.7.0-dev.1 → 5.7.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,55 +28,80 @@ const FormatMerger_1 = require("./FormatMerger");
28
28
  */
29
29
  class SchemaMergingVisitor {
30
30
  _context;
31
+ _reporter;
31
32
  /**
32
33
  * Initializes a new instance of SchemaMergingVisitor class.
33
34
  */
34
35
  constructor(context) {
35
36
  this._context = context;
36
37
  }
38
+ /**
39
+ * Sets the reporter for tracking merge operations.
40
+ * @internal
41
+ */
42
+ setReporter(reporter) {
43
+ this._reporter = reporter;
44
+ }
45
+ /**
46
+ * Method that wraps the visitor with success/failure tracking.
47
+ * @internal
48
+ */
49
+ async trackOperation(entry, operation) {
50
+ if (!this._reporter) {
51
+ return operation();
52
+ }
53
+ const startTime = performance.now();
54
+ try {
55
+ await operation();
56
+ this._reporter.recordSuccess(entry, performance.now() - startTime);
57
+ }
58
+ catch (error) {
59
+ this._reporter.recordFailure(entry, performance.now() - startTime, error);
60
+ throw error;
61
+ }
62
+ }
37
63
  /**
38
64
  * Shared merging logic for all types of ClassItemDifference union.
39
65
  */
40
66
  async visitClassDifference(entry, index, array, handler) {
41
- return this.visitSchemaItemDifference(entry, {
42
- add: async (context) => {
43
- // To add classes a slightly different approach is done. In fact the class entries gets processed
44
- // two times. The first time, a stub with the bare minimum is added to the schema. The second time,
45
- // the class gets completed with all properties, mixins, etc...
46
- if (entry.changeType === "add" && !await context.targetSchema.getItem(entry.itemName)) {
47
- await handler.add(this._context, {
48
- ...entry,
49
- difference: {
50
- ...entry.difference,
51
- // Remove everything we want to validate before setting, this is done in the second iteration.
52
- baseClass: undefined,
53
- mixins: undefined,
54
- properties: undefined,
55
- customAttributes: undefined,
56
- },
57
- });
58
- // Searches for the last class difference and adds the entry after it. That way,
59
- // the class is completed before class related entries get processed.
60
- const insertIndex = findIndexOf(array, (e) => !(0, Utils_1.isClassDifference)(e), index) || array.length;
61
- array.splice(insertIndex, 0, entry);
62
- return;
63
- }
64
- // Now both a modification change or the second add iteration is a modification of an existing class.
65
- // So, regardless of the actual change type, modify is called.
66
- return handler.modify(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
67
- },
67
+ // To add classes a slightly different approach is done. In fact the class entries gets processed
68
+ // two times. The first time, a stub with the bare minimum is added to the schema. The second time,
69
+ // the class gets completed with all properties, mixins, etc...
70
+ if (entry.changeType === "add" && !await this._context.targetSchema.getItem(entry.itemName)) {
71
+ await handler.add(this._context, {
72
+ ...entry,
73
+ difference: {
74
+ ...entry.difference,
75
+ // Remove everything we want to validate before setting, this is done in the second iteration.
76
+ baseClass: undefined,
77
+ mixins: undefined,
78
+ properties: undefined,
79
+ customAttributes: undefined,
80
+ },
81
+ });
82
+ // Searches for the last class difference and adds the entry after it. That way,
83
+ // the class is completed before class related entries get processed.
84
+ const insertIndex = findIndexOf(array, (e) => !(0, Utils_1.isClassDifference)(e), index) || array.length;
85
+ array.splice(insertIndex, 0, entry);
86
+ return;
87
+ }
88
+ // Now both a modification change or the second add iteration is a modification of an existing class.
89
+ // So, regardless of the actual change type, modify is called.
90
+ // This is tracked because it's the actual operation that completes the class.
91
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
92
+ add: async (context) => handler.modify(context, entry, (0, Utils_2.toItemKey)(context, entry.itemName)),
68
93
  modify: handler.modify,
69
- });
94
+ }));
70
95
  }
71
96
  /**
72
97
  * Visitor implementation for handling ConstantDifference.
73
98
  * @internal
74
99
  */
75
100
  async visitConstantDifference(entry) {
76
- return this.visitSchemaItemDifference(entry, {
101
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
77
102
  add: ConstantMerger_1.addConstant,
78
103
  modify: ConstantMerger_1.modifyConstant,
79
- });
104
+ }));
80
105
  }
81
106
  /**
82
107
  * Visitor implementation for handling CustomAttributeClassDifference.
@@ -93,9 +118,11 @@ class SchemaMergingVisitor {
93
118
  * @internal
94
119
  */
95
120
  async visitCustomAttributeInstanceDifference(entry) {
96
- switch (entry.changeType) {
97
- case "add": return (0, CustomAttributeMerger_1.addCustomAttribute)(this._context, entry);
98
- }
121
+ return this.trackOperation(entry, async () => {
122
+ switch (entry.changeType) {
123
+ case "add": return (0, CustomAttributeMerger_1.addCustomAttribute)(this._context, entry);
124
+ }
125
+ });
99
126
  }
100
127
  /**
101
128
  * Visitor implementation for handling EntityClassDifference.
@@ -112,77 +139,85 @@ class SchemaMergingVisitor {
112
139
  * @internal
113
140
  */
114
141
  async visitEntityClassMixinDifference(entry) {
115
- switch (entry.changeType) {
116
- case "add": return (0, EntityClassMerger_1.addClassMixins)(this._context, entry);
117
- }
142
+ return this.trackOperation(entry, async () => {
143
+ switch (entry.changeType) {
144
+ case "add": return (0, EntityClassMerger_1.addClassMixins)(this._context, entry);
145
+ }
146
+ });
118
147
  }
119
148
  /**
120
149
  * Visitor implementation for handling EnumerationDifference.
121
150
  * @internal
122
151
  */
123
152
  async visitEnumerationDifference(entry) {
124
- return this.visitSchemaItemDifference(entry, {
153
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
125
154
  add: EnumerationMerger_1.addEnumeration,
126
155
  modify: EnumerationMerger_1.modifyEnumeration,
127
- });
156
+ }));
128
157
  }
129
158
  /**
130
159
  * Visitor implementation for handling EnumeratorDifference.
131
160
  * @internal
132
161
  */
133
162
  async visitEnumeratorDifference(entry) {
134
- switch (entry.changeType) {
135
- case "add": return (0, EnumeratorMerger_1.addEnumerator)(this._context, entry);
136
- case "modify": return (0, EnumeratorMerger_1.modifyEnumerator)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
137
- }
163
+ return this.trackOperation(entry, async () => {
164
+ switch (entry.changeType) {
165
+ case "add": return (0, EnumeratorMerger_1.addEnumerator)(this._context, entry);
166
+ case "modify": return (0, EnumeratorMerger_1.modifyEnumerator)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
167
+ }
168
+ });
138
169
  }
139
170
  /**
140
171
  * Visitor implementation for handling FormatDifference.
141
172
  * @internal
142
173
  */
143
174
  async visitFormatDifference(entry) {
144
- return this.visitSchemaItemDifference(entry, {
175
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
145
176
  add: FormatMerger_1.addFormat,
146
177
  modify: FormatMerger_1.modifyFormat,
147
- });
178
+ }));
148
179
  }
149
180
  /**
150
181
  * Visitor implementation for handling FormatUnitDifference.
151
182
  * @internal
152
183
  */
153
184
  async visitFormatUnitDifference(entry) {
154
- switch (entry.changeType) {
155
- case "modify": return (0, FormatMerger_1.modifyFormatUnit)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
156
- }
185
+ return this.trackOperation(entry, async () => {
186
+ switch (entry.changeType) {
187
+ case "modify": return (0, FormatMerger_1.modifyFormatUnit)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
188
+ }
189
+ });
157
190
  }
158
191
  /**
159
192
  * Visitor implementation for handling FormatUnitLabelDifference.
160
193
  * @internal
161
194
  */
162
195
  async visitFormatUnitLabelDifference(entry) {
163
- switch (entry.changeType) {
164
- case "modify": return (0, FormatMerger_1.modifyFormatUnitLabel)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
165
- }
196
+ return this.trackOperation(entry, async () => {
197
+ switch (entry.changeType) {
198
+ case "modify": return (0, FormatMerger_1.modifyFormatUnitLabel)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
199
+ }
200
+ });
166
201
  }
167
202
  /**
168
203
  * Visitor implementation for handling InvertedUnitDifference.
169
204
  * @internal
170
205
  */
171
206
  async visitInvertedUnitDifference(entry) {
172
- return this.visitSchemaItemDifference(entry, {
207
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
173
208
  add: InvertedUnitMerger_1.addInvertedUnit,
174
209
  modify: InvertedUnitMerger_1.modifyInvertedUnit,
175
- });
210
+ }));
176
211
  }
177
212
  /**
178
213
  * Visitor implementation for handling KindOfQuantityDifference.
179
214
  * @internal
180
215
  */
181
216
  async visitKindOfQuantityDifference(entry) {
182
- return this.visitSchemaItemDifference(entry, {
217
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
183
218
  add: KindOfQuantityMerger_1.addKindOfQuantity,
184
219
  modify: KindOfQuantityMerger_1.modifyKindOfQuantity,
185
- });
220
+ }));
186
221
  }
187
222
  /**
188
223
  * Visitor implementation for handling MixinClassDifference.
@@ -199,27 +234,27 @@ class SchemaMergingVisitor {
199
234
  * @internal
200
235
  */
201
236
  async visitPhenomenonDifference(entry) {
202
- return this.visitSchemaItemDifference(entry, {
237
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
203
238
  add: PhenomenonMerger_1.addPhenomenon,
204
239
  modify: PhenomenonMerger_1.modifyPhenomenon,
205
- });
240
+ }));
206
241
  }
207
242
  /**
208
243
  * Visitor implementation for handling PropertyCategoryDifference.
209
244
  * @internal
210
245
  */
211
246
  async visitPropertyCategoryDifference(entry) {
212
- return this.visitSchemaItemDifference(entry, {
247
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
213
248
  add: PropertyCategoryMerger_1.addPropertyCategory,
214
249
  modify: PropertyCategoryMerger_1.modifyPropertyCategory,
215
- });
250
+ }));
216
251
  }
217
252
  /**
218
253
  * Visitor implementation for handling ClassPropertyDifference.
219
254
  * @internal
220
255
  */
221
256
  async visitPropertyDifference(entry) {
222
- await (0, PropertyMerger_1.mergePropertyDifference)(this._context, entry);
257
+ return this.trackOperation(entry, async () => (0, PropertyMerger_1.mergePropertyDifference)(this._context, entry));
223
258
  }
224
259
  /**
225
260
  * Visitor implementation for handling RelationshipClassDifference.
@@ -236,26 +271,31 @@ class SchemaMergingVisitor {
236
271
  * @internal
237
272
  */
238
273
  async visitRelationshipConstraintClassDifference(entry) {
239
- await (0, RelationshipClassMerger_1.mergeRelationshipClassConstraint)(this._context, entry);
274
+ return this.trackOperation(entry, async () => (0, RelationshipClassMerger_1.mergeRelationshipClassConstraint)(this._context, entry));
240
275
  }
241
276
  /**
242
277
  * Visitor implementation for handling RelationshipConstraintDifference.
243
278
  * @internal
244
279
  */
245
280
  async visitRelationshipConstraintDifference(entry) {
246
- await (0, RelationshipClassMerger_1.mergeRelationshipConstraint)(this._context, entry);
281
+ return this.trackOperation(entry, async () => {
282
+ await (0, RelationshipClassMerger_1.mergeRelationshipConstraint)(this._context, entry);
283
+ });
247
284
  }
248
285
  /**
249
286
  * Visitor implementation for handling SchemaDifference.
250
287
  * @internal
251
288
  */
252
- async visitSchemaDifference({ difference }) {
253
- if (difference.label !== undefined) {
254
- await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);
255
- }
256
- if (difference.description !== undefined) {
257
- await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);
258
- }
289
+ async visitSchemaDifference(entry) {
290
+ return this.trackOperation(entry, async () => {
291
+ const { difference } = entry;
292
+ if (difference.label !== undefined) {
293
+ await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);
294
+ }
295
+ if (difference.description !== undefined) {
296
+ await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);
297
+ }
298
+ });
259
299
  }
260
300
  /**
261
301
  * Shared merging logic for all types of AnySchemaItemDifference union.
@@ -280,10 +320,12 @@ class SchemaMergingVisitor {
280
320
  * @internal
281
321
  */
282
322
  async visitSchemaReferenceDifference(entry) {
283
- switch (entry.changeType) {
284
- case "add": return (0, SchemaReferenceMerger_1.addSchemaReferences)(this._context, entry);
285
- case "modify": return (0, SchemaReferenceMerger_1.modifySchemaReferences)(this._context, entry);
286
- }
323
+ return this.trackOperation(entry, async () => {
324
+ switch (entry.changeType) {
325
+ case "add": return (0, SchemaReferenceMerger_1.addSchemaReferences)(this._context, entry);
326
+ case "modify": return (0, SchemaReferenceMerger_1.modifySchemaReferences)(this._context, entry);
327
+ }
328
+ });
287
329
  }
288
330
  /**
289
331
  * Visitor implementation for handling StructClassDifference.
@@ -300,29 +342,31 @@ class SchemaMergingVisitor {
300
342
  * @internal
301
343
  */
302
344
  async visitUnitDifference(entry) {
303
- return this.visitSchemaItemDifference(entry, {
345
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
304
346
  add: UnitMerger_1.addUnit,
305
347
  modify: UnitMerger_1.modifyUnit,
306
- });
348
+ }));
307
349
  }
308
350
  /**
309
351
  * Visitor implementation for handling UnitSystemDifference.
310
352
  * @internal
311
353
  */
312
354
  async visitUnitSystemDifference(entry) {
313
- return this.visitSchemaItemDifference(entry, {
355
+ return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
314
356
  add: UnitSystemMerger_1.addUnitSystem,
315
357
  modify: UnitSystemMerger_1.modifyUnitSystem,
316
- });
358
+ }));
317
359
  }
318
360
  /**
319
361
  * Visitor implementation for handling KindOfQuantityPresentationFormatDifference.
320
362
  * @internal
321
363
  */
322
364
  async visitKindOfQuantityPresentationFormatDifference(entry) {
323
- switch (entry.changeType) {
324
- case "add": return (0, KindOfQuantityMerger_1.addPresentationFormat)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
325
- }
365
+ return this.trackOperation(entry, async () => {
366
+ switch (entry.changeType) {
367
+ case "add": return (0, KindOfQuantityMerger_1.addPresentationFormat)(this._context, entry, (0, Utils_2.toItemKey)(this._context, entry.itemName));
368
+ }
369
+ });
326
370
  }
327
371
  }
328
372
  exports.SchemaMergingVisitor = SchemaMergingVisitor;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVisitor.ts"],"names":[],"mappings":";;;AAWA,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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AAC;IAED;;;OAGG;IACI,KAAK,CAAC,yBAAyB,CAAC,KAA2B;QAChE,OAAO,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,gCAAa;YAClB,MAAM,EAAE,mCAAgB;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;;MAGE;IACK,KAAK,CAAC,+CAA+C,CAAC,KAAiD;QAC5G,QAAO,KAAK,CAAC,UAAU,EAAE,CAAC;YACxB,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;QAC3G,CAAC;IACH,CAAC;CACF;AAzUD,oDAyUC;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 { 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 } 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 } 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\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 * 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 return this.visitSchemaItemDifference(entry, {\r\n add: async (context) => {\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 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 return handler.modify(this._context, entry, toItemKey(this._context, entry.itemName));\r\n },\r\n modify: handler.modify,\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.visitSchemaItemDifference(entry, {\r\n add: addConstant,\r\n modify: modifyConstant,\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 switch(entry.changeType) {\r\n case \"add\": return addCustomAttribute(this._context, entry);\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 switch(entry.changeType) {\r\n case \"add\": return addClassMixins(this._context, entry);\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.visitSchemaItemDifference(entry, {\r\n add: addEnumeration,\r\n modify: modifyEnumeration,\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 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 * Visitor implementation for handling FormatDifference.\r\n * @internal\r\n */\r\n public async visitFormatDifference(entry: FormatDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addFormat,\r\n modify: modifyFormat,\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 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 * Visitor implementation for handling FormatUnitLabelDifference.\r\n * @internal\r\n */\r\n public async visitFormatUnitLabelDifference(entry: FormatUnitLabelDifference): Promise<void> {\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 * Visitor implementation for handling InvertedUnitDifference.\r\n * @internal\r\n */\r\n public async visitInvertedUnitDifference(entry: InvertedUnitDifference): Promise<void> {\r\n return this.visitSchemaItemDifference(entry, {\r\n add: addInvertedUnit,\r\n modify: modifyInvertedUnit,\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.visitSchemaItemDifference(entry, {\r\n add: addKindOfQuantity,\r\n modify: modifyKindOfQuantity,\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.visitSchemaItemDifference(entry, {\r\n add: addPhenomenon,\r\n modify: modifyPhenomenon,\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.visitSchemaItemDifference(entry, {\r\n add: addPropertyCategory,\r\n modify: modifyPropertyCategory,\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 await mergePropertyDifference(this._context, entry);\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 await mergeRelationshipClassConstraint(this._context, entry);\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 await mergeRelationshipConstraint(this._context, entry);\r\n }\r\n\r\n /**\r\n * Visitor implementation for handling SchemaDifference.\r\n * @internal\r\n */\r\n public async visitSchemaDifference({ difference }: SchemaDifference): Promise<void> {\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 * 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 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 * 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.visitSchemaItemDifference(entry, {\r\n add: addUnit,\r\n modify: modifyUnit,\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.visitSchemaItemDifference(entry, {\r\n add: addUnitSystem,\r\n modify: modifyUnitSystem,\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 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 * 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,WA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C9C,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"]}
@@ -1,7 +1,7 @@
1
1
  import { SchemaDifferenceWalker } from "../Differencing/SchemaDifferenceVisitor";
2
2
  import { AnySchemaDifference, DifferenceType } from "../Differencing/SchemaDifference";
3
3
  /**
4
- * A walker that traverses the schema differences in a certain oder and invokes the appropriate
4
+ * A walker that traverses the schema differences in a certain order and invokes the appropriate
5
5
  * visitor method for each kind of schema difference.
6
6
  * @internal
7
7
  */
@@ -9,7 +9,7 @@ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
9
  const SchemaDifferenceVisitor_1 = require("../Differencing/SchemaDifferenceVisitor");
10
10
  const SchemaDifference_1 = require("../Differencing/SchemaDifference");
11
11
  /**
12
- * A walker that traverses the schema differences in a certain oder and invokes the appropriate
12
+ * A walker that traverses the schema differences in a certain order and invokes the appropriate
13
13
  * visitor method for each kind of schema difference.
14
14
  * @internal
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0D;AAC1D,qFAAiF;AACjF,uEAAqH;AAErH;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,gDAAsB;IAE7D;;;;;;;OAOG;IACa,KAAK,CAAC,QAAQ,CAAC,WAAuC,EAAE,UAA2B;QAEjG,MAAM,YAAY,GAAG,CAAC,UAAsB,EAAE,EAAE;YAC9C,OAAO,CAAC,KAA0B,EAAE,EAAE;gBACpC,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU,IAAI,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;YAC7F,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO,KAAK,CAAC,QAAQ,CAAC;YACpB,wDAAwD;YACxD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,MAAM,CAAC,CAAC;YAC5D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,eAAe,CAAC,CAAC;YAErE,+CAA+C;YAC/C,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,UAAU,CAAC,CAAC;YAC9D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,gBAAgB,CAAC,CAAC;YACpE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,kCAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,UAAU,CAAC,CAAC;YAChE,GAAG,WAAW,CAA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AAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,sBAAsB,CAAC,CAAC;YAC5E,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,mCAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF;AArDD,kDAqDC","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 { SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaDifferenceWalker } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { AnySchemaDifference, DifferenceType, SchemaOtherTypes, SchemaType } from \"../Differencing/SchemaDifference\";\r\n\r\n/**\r\n * A walker that traverses the schema differences in a certain oder and invokes the appropriate\r\n * visitor method for each kind of schema difference.\r\n * @internal\r\n */\r\nexport class SchemaMergingWalker extends SchemaDifferenceWalker {\r\n\r\n /**\r\n * Traverses the schema differences and calls the appropriate method on the visitor.\r\n * This method overrides the derived class method to apply some ordering how the\r\n * differences are traversed.\r\n *\r\n * @param differences The differences to traverse.\r\n * @param changeType Optional type of change to filter by.\r\n */\r\n public override async traverse(differences: Array<AnySchemaDifference>, changeType?: DifferenceType): Promise<void> {\r\n\r\n const filterByType = (schemaType: SchemaType) => {\r\n return (entry: AnySchemaDifference) => {\r\n return entry.schemaType === schemaType && (!changeType || entry.changeType === changeType);\r\n };\r\n };\r\n\r\n return super.traverse([\r\n // First the schema related differences are traversed...\r\n ...differences.filter(filterByType(SchemaOtherTypes.Schema)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.SchemaReference)),\r\n\r\n // Then the schema items (excluding classes)...\r\n ...differences.filter(filterByType(SchemaItemType.UnitSystem)),\r\n ...differences.filter(filterByType(SchemaItemType.PropertyCategory)),\r\n ...differences.filter(filterByType(SchemaItemType.Enumeration)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.Enumerator)),\r\n ...differences.filter(filterByType(SchemaItemType.Phenomenon)),\r\n ...differences.filter(filterByType(SchemaItemType.Unit)),\r\n ...differences.filter(filterByType(SchemaItemType.InvertedUnit)),\r\n ...differences.filter(filterByType(SchemaItemType.Format)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnit)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnitLabel)),\r\n ...differences.filter(filterByType(SchemaItemType.KindOfQuantity)),\r\n ...differences.filter(filterByType(SchemaItemType.Constant)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.KindOfQuantityPresentationFormat)),\r\n\r\n // Followed by classes and class related differences...\r\n ...differences.filter(filterByType(SchemaItemType.CustomAttributeClass)),\r\n ...differences.filter(filterByType(SchemaItemType.Mixin)),\r\n ...differences.filter(filterByType(SchemaItemType.StructClass)),\r\n ...differences.filter(filterByType(SchemaItemType.EntityClass)),\r\n ...differences.filter(filterByType(SchemaItemType.RelationshipClass)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.EntityClassMixin)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraint)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraintClass)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.Property)),\r\n\r\n // And then the custom attributes.\r\n ...differences.filter(filterByType(SchemaOtherTypes.CustomAttributeInstance)),\r\n ]);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0D;AAC1D,qFAAiF;AACjF,uEAAqH;AAErH;;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,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,CAAC;CACF;AArDD,kDAqDC","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 { SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaDifferenceWalker } from \"../Differencing/SchemaDifferenceVisitor\";\r\nimport { AnySchemaDifference, DifferenceType, SchemaOtherTypes, SchemaType } from \"../Differencing/SchemaDifference\";\r\n\r\n/**\r\n * A walker that traverses the schema differences in a certain order and invokes the appropriate\r\n * visitor method for each kind of schema difference.\r\n * @internal\r\n */\r\nexport class SchemaMergingWalker extends SchemaDifferenceWalker {\r\n\r\n /**\r\n * Traverses the schema differences and calls the appropriate method on the visitor.\r\n * This method overrides the derived class method to apply some ordering how the\r\n * differences are traversed.\r\n *\r\n * @param differences The differences to traverse.\r\n * @param changeType Optional type of change to filter by.\r\n */\r\n public override async traverse(differences: Array<AnySchemaDifference>, changeType?: DifferenceType): Promise<void> {\r\n\r\n const filterByType = (schemaType: SchemaType) => {\r\n return (entry: AnySchemaDifference) => {\r\n return entry.schemaType === schemaType && (!changeType || entry.changeType === changeType);\r\n };\r\n };\r\n\r\n return super.traverse([\r\n // First the schema related differences are traversed...\r\n ...differences.filter(filterByType(SchemaOtherTypes.Schema)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.SchemaReference)),\r\n\r\n // Then the schema items (excluding classes)...\r\n ...differences.filter(filterByType(SchemaItemType.UnitSystem)),\r\n ...differences.filter(filterByType(SchemaItemType.PropertyCategory)),\r\n ...differences.filter(filterByType(SchemaItemType.Enumeration)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.Enumerator)),\r\n ...differences.filter(filterByType(SchemaItemType.Phenomenon)),\r\n ...differences.filter(filterByType(SchemaItemType.Unit)),\r\n ...differences.filter(filterByType(SchemaItemType.InvertedUnit)),\r\n ...differences.filter(filterByType(SchemaItemType.Format)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnit)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.FormatUnitLabel)),\r\n ...differences.filter(filterByType(SchemaItemType.KindOfQuantity)),\r\n ...differences.filter(filterByType(SchemaItemType.Constant)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.KindOfQuantityPresentationFormat)),\r\n\r\n // Followed by classes and class related differences...\r\n ...differences.filter(filterByType(SchemaItemType.CustomAttributeClass)),\r\n ...differences.filter(filterByType(SchemaItemType.Mixin)),\r\n ...differences.filter(filterByType(SchemaItemType.StructClass)),\r\n ...differences.filter(filterByType(SchemaItemType.EntityClass)),\r\n ...differences.filter(filterByType(SchemaItemType.RelationshipClass)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.EntityClassMixin)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraint)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.RelationshipConstraintClass)),\r\n ...differences.filter(filterByType(SchemaOtherTypes.Property)),\r\n\r\n // And then the custom attributes.\r\n ...differences.filter(filterByType(SchemaOtherTypes.CustomAttributeInstance)),\r\n ]);\r\n }\r\n}\r\n"]}