@itwin/ecschema-editing 5.7.0-dev.1 → 5.7.0-dev.11
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 +108 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +127 -1
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +13 -2
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.js +123 -79
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js +1 -1
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
- package/lib/esm/Merging/SchemaMerger.d.ts +108 -1
- package/lib/esm/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/esm/Merging/SchemaMerger.js +125 -0
- package/lib/esm/Merging/SchemaMerger.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.d.ts +13 -2
- package/lib/esm/Merging/SchemaMergingVisitor.d.ts.map +1 -1
- package/lib/esm/Merging/SchemaMergingVisitor.js +123 -79
- package/lib/esm/Merging/SchemaMergingVisitor.js.map +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.d.ts +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.js +1 -1
- package/lib/esm/Merging/SchemaMergingWalker.js.map +1 -1
- package/package.json +9 -9
|
@@ -25,55 +25,80 @@ import { addFormat, modifyFormat, modifyFormatUnit, modifyFormatUnitLabel } from
|
|
|
25
25
|
*/
|
|
26
26
|
export class SchemaMergingVisitor {
|
|
27
27
|
_context;
|
|
28
|
+
_reporter;
|
|
28
29
|
/**
|
|
29
30
|
* Initializes a new instance of SchemaMergingVisitor class.
|
|
30
31
|
*/
|
|
31
32
|
constructor(context) {
|
|
32
33
|
this._context = context;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets the reporter for tracking merge operations.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
setReporter(reporter) {
|
|
40
|
+
this._reporter = reporter;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Method that wraps the visitor with success/failure tracking.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
async trackOperation(entry, operation) {
|
|
47
|
+
if (!this._reporter) {
|
|
48
|
+
return operation();
|
|
49
|
+
}
|
|
50
|
+
const startTime = performance.now();
|
|
51
|
+
try {
|
|
52
|
+
await operation();
|
|
53
|
+
this._reporter.recordSuccess(entry, performance.now() - startTime);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
this._reporter.recordFailure(entry, performance.now() - startTime, error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
34
60
|
/**
|
|
35
61
|
* Shared merging logic for all types of ClassItemDifference union.
|
|
36
62
|
*/
|
|
37
63
|
async visitClassDifference(entry, index, array, handler) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
64
|
+
// To add classes a slightly different approach is done. In fact the class entries gets processed
|
|
65
|
+
// two times. The first time, a stub with the bare minimum is added to the schema. The second time,
|
|
66
|
+
// the class gets completed with all properties, mixins, etc...
|
|
67
|
+
if (entry.changeType === "add" && !await this._context.targetSchema.getItem(entry.itemName)) {
|
|
68
|
+
await handler.add(this._context, {
|
|
69
|
+
...entry,
|
|
70
|
+
difference: {
|
|
71
|
+
...entry.difference,
|
|
72
|
+
// Remove everything we want to validate before setting, this is done in the second iteration.
|
|
73
|
+
baseClass: undefined,
|
|
74
|
+
mixins: undefined,
|
|
75
|
+
properties: undefined,
|
|
76
|
+
customAttributes: undefined,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
// Searches for the last class difference and adds the entry after it. That way,
|
|
80
|
+
// the class is completed before class related entries get processed.
|
|
81
|
+
const insertIndex = findIndexOf(array, (e) => !isClassDifference(e), index) || array.length;
|
|
82
|
+
array.splice(insertIndex, 0, entry);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Now both a modification change or the second add iteration is a modification of an existing class.
|
|
86
|
+
// So, regardless of the actual change type, modify is called.
|
|
87
|
+
// This is tracked because it's the actual operation that completes the class.
|
|
88
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
89
|
+
add: async (context) => handler.modify(context, entry, toItemKey(context, entry.itemName)),
|
|
65
90
|
modify: handler.modify,
|
|
66
|
-
});
|
|
91
|
+
}));
|
|
67
92
|
}
|
|
68
93
|
/**
|
|
69
94
|
* Visitor implementation for handling ConstantDifference.
|
|
70
95
|
* @internal
|
|
71
96
|
*/
|
|
72
97
|
async visitConstantDifference(entry) {
|
|
73
|
-
return this.visitSchemaItemDifference(entry, {
|
|
98
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
74
99
|
add: addConstant,
|
|
75
100
|
modify: modifyConstant,
|
|
76
|
-
});
|
|
101
|
+
}));
|
|
77
102
|
}
|
|
78
103
|
/**
|
|
79
104
|
* Visitor implementation for handling CustomAttributeClassDifference.
|
|
@@ -90,9 +115,11 @@ export class SchemaMergingVisitor {
|
|
|
90
115
|
* @internal
|
|
91
116
|
*/
|
|
92
117
|
async visitCustomAttributeInstanceDifference(entry) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
return this.trackOperation(entry, async () => {
|
|
119
|
+
switch (entry.changeType) {
|
|
120
|
+
case "add": return addCustomAttribute(this._context, entry);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
96
123
|
}
|
|
97
124
|
/**
|
|
98
125
|
* Visitor implementation for handling EntityClassDifference.
|
|
@@ -109,77 +136,85 @@ export class SchemaMergingVisitor {
|
|
|
109
136
|
* @internal
|
|
110
137
|
*/
|
|
111
138
|
async visitEntityClassMixinDifference(entry) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
return this.trackOperation(entry, async () => {
|
|
140
|
+
switch (entry.changeType) {
|
|
141
|
+
case "add": return addClassMixins(this._context, entry);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
115
144
|
}
|
|
116
145
|
/**
|
|
117
146
|
* Visitor implementation for handling EnumerationDifference.
|
|
118
147
|
* @internal
|
|
119
148
|
*/
|
|
120
149
|
async visitEnumerationDifference(entry) {
|
|
121
|
-
return this.visitSchemaItemDifference(entry, {
|
|
150
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
122
151
|
add: addEnumeration,
|
|
123
152
|
modify: modifyEnumeration,
|
|
124
|
-
});
|
|
153
|
+
}));
|
|
125
154
|
}
|
|
126
155
|
/**
|
|
127
156
|
* Visitor implementation for handling EnumeratorDifference.
|
|
128
157
|
* @internal
|
|
129
158
|
*/
|
|
130
159
|
async visitEnumeratorDifference(entry) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
return this.trackOperation(entry, async () => {
|
|
161
|
+
switch (entry.changeType) {
|
|
162
|
+
case "add": return addEnumerator(this._context, entry);
|
|
163
|
+
case "modify": return modifyEnumerator(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
164
|
+
}
|
|
165
|
+
});
|
|
135
166
|
}
|
|
136
167
|
/**
|
|
137
168
|
* Visitor implementation for handling FormatDifference.
|
|
138
169
|
* @internal
|
|
139
170
|
*/
|
|
140
171
|
async visitFormatDifference(entry) {
|
|
141
|
-
return this.visitSchemaItemDifference(entry, {
|
|
172
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
142
173
|
add: addFormat,
|
|
143
174
|
modify: modifyFormat,
|
|
144
|
-
});
|
|
175
|
+
}));
|
|
145
176
|
}
|
|
146
177
|
/**
|
|
147
178
|
* Visitor implementation for handling FormatUnitDifference.
|
|
148
179
|
* @internal
|
|
149
180
|
*/
|
|
150
181
|
async visitFormatUnitDifference(entry) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
182
|
+
return this.trackOperation(entry, async () => {
|
|
183
|
+
switch (entry.changeType) {
|
|
184
|
+
case "modify": return modifyFormatUnit(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
154
187
|
}
|
|
155
188
|
/**
|
|
156
189
|
* Visitor implementation for handling FormatUnitLabelDifference.
|
|
157
190
|
* @internal
|
|
158
191
|
*/
|
|
159
192
|
async visitFormatUnitLabelDifference(entry) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
193
|
+
return this.trackOperation(entry, async () => {
|
|
194
|
+
switch (entry.changeType) {
|
|
195
|
+
case "modify": return modifyFormatUnitLabel(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
196
|
+
}
|
|
197
|
+
});
|
|
163
198
|
}
|
|
164
199
|
/**
|
|
165
200
|
* Visitor implementation for handling InvertedUnitDifference.
|
|
166
201
|
* @internal
|
|
167
202
|
*/
|
|
168
203
|
async visitInvertedUnitDifference(entry) {
|
|
169
|
-
return this.visitSchemaItemDifference(entry, {
|
|
204
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
170
205
|
add: addInvertedUnit,
|
|
171
206
|
modify: modifyInvertedUnit,
|
|
172
|
-
});
|
|
207
|
+
}));
|
|
173
208
|
}
|
|
174
209
|
/**
|
|
175
210
|
* Visitor implementation for handling KindOfQuantityDifference.
|
|
176
211
|
* @internal
|
|
177
212
|
*/
|
|
178
213
|
async visitKindOfQuantityDifference(entry) {
|
|
179
|
-
return this.visitSchemaItemDifference(entry, {
|
|
214
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
180
215
|
add: addKindOfQuantity,
|
|
181
216
|
modify: modifyKindOfQuantity,
|
|
182
|
-
});
|
|
217
|
+
}));
|
|
183
218
|
}
|
|
184
219
|
/**
|
|
185
220
|
* Visitor implementation for handling MixinClassDifference.
|
|
@@ -196,27 +231,27 @@ export class SchemaMergingVisitor {
|
|
|
196
231
|
* @internal
|
|
197
232
|
*/
|
|
198
233
|
async visitPhenomenonDifference(entry) {
|
|
199
|
-
return this.visitSchemaItemDifference(entry, {
|
|
234
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
200
235
|
add: addPhenomenon,
|
|
201
236
|
modify: modifyPhenomenon,
|
|
202
|
-
});
|
|
237
|
+
}));
|
|
203
238
|
}
|
|
204
239
|
/**
|
|
205
240
|
* Visitor implementation for handling PropertyCategoryDifference.
|
|
206
241
|
* @internal
|
|
207
242
|
*/
|
|
208
243
|
async visitPropertyCategoryDifference(entry) {
|
|
209
|
-
return this.visitSchemaItemDifference(entry, {
|
|
244
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
210
245
|
add: addPropertyCategory,
|
|
211
246
|
modify: modifyPropertyCategory,
|
|
212
|
-
});
|
|
247
|
+
}));
|
|
213
248
|
}
|
|
214
249
|
/**
|
|
215
250
|
* Visitor implementation for handling ClassPropertyDifference.
|
|
216
251
|
* @internal
|
|
217
252
|
*/
|
|
218
253
|
async visitPropertyDifference(entry) {
|
|
219
|
-
|
|
254
|
+
return this.trackOperation(entry, async () => mergePropertyDifference(this._context, entry));
|
|
220
255
|
}
|
|
221
256
|
/**
|
|
222
257
|
* Visitor implementation for handling RelationshipClassDifference.
|
|
@@ -233,26 +268,31 @@ export class SchemaMergingVisitor {
|
|
|
233
268
|
* @internal
|
|
234
269
|
*/
|
|
235
270
|
async visitRelationshipConstraintClassDifference(entry) {
|
|
236
|
-
|
|
271
|
+
return this.trackOperation(entry, async () => mergeRelationshipClassConstraint(this._context, entry));
|
|
237
272
|
}
|
|
238
273
|
/**
|
|
239
274
|
* Visitor implementation for handling RelationshipConstraintDifference.
|
|
240
275
|
* @internal
|
|
241
276
|
*/
|
|
242
277
|
async visitRelationshipConstraintDifference(entry) {
|
|
243
|
-
|
|
278
|
+
return this.trackOperation(entry, async () => {
|
|
279
|
+
await mergeRelationshipConstraint(this._context, entry);
|
|
280
|
+
});
|
|
244
281
|
}
|
|
245
282
|
/**
|
|
246
283
|
* Visitor implementation for handling SchemaDifference.
|
|
247
284
|
* @internal
|
|
248
285
|
*/
|
|
249
|
-
async visitSchemaDifference(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
286
|
+
async visitSchemaDifference(entry) {
|
|
287
|
+
return this.trackOperation(entry, async () => {
|
|
288
|
+
const { difference } = entry;
|
|
289
|
+
if (difference.label !== undefined) {
|
|
290
|
+
await this._context.editor.setDisplayLabel(this._context.targetSchemaKey, difference.label);
|
|
291
|
+
}
|
|
292
|
+
if (difference.description !== undefined) {
|
|
293
|
+
await this._context.editor.setDescription(this._context.targetSchemaKey, difference.description);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
256
296
|
}
|
|
257
297
|
/**
|
|
258
298
|
* Shared merging logic for all types of AnySchemaItemDifference union.
|
|
@@ -277,10 +317,12 @@ export class SchemaMergingVisitor {
|
|
|
277
317
|
* @internal
|
|
278
318
|
*/
|
|
279
319
|
async visitSchemaReferenceDifference(entry) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
320
|
+
return this.trackOperation(entry, async () => {
|
|
321
|
+
switch (entry.changeType) {
|
|
322
|
+
case "add": return addSchemaReferences(this._context, entry);
|
|
323
|
+
case "modify": return modifySchemaReferences(this._context, entry);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
284
326
|
}
|
|
285
327
|
/**
|
|
286
328
|
* Visitor implementation for handling StructClassDifference.
|
|
@@ -297,29 +339,31 @@ export class SchemaMergingVisitor {
|
|
|
297
339
|
* @internal
|
|
298
340
|
*/
|
|
299
341
|
async visitUnitDifference(entry) {
|
|
300
|
-
return this.visitSchemaItemDifference(entry, {
|
|
342
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
301
343
|
add: addUnit,
|
|
302
344
|
modify: modifyUnit,
|
|
303
|
-
});
|
|
345
|
+
}));
|
|
304
346
|
}
|
|
305
347
|
/**
|
|
306
348
|
* Visitor implementation for handling UnitSystemDifference.
|
|
307
349
|
* @internal
|
|
308
350
|
*/
|
|
309
351
|
async visitUnitSystemDifference(entry) {
|
|
310
|
-
return this.visitSchemaItemDifference(entry, {
|
|
352
|
+
return this.trackOperation(entry, async () => this.visitSchemaItemDifference(entry, {
|
|
311
353
|
add: addUnitSystem,
|
|
312
354
|
modify: modifyUnitSystem,
|
|
313
|
-
});
|
|
355
|
+
}));
|
|
314
356
|
}
|
|
315
357
|
/**
|
|
316
358
|
* Visitor implementation for handling KindOfQuantityPresentationFormatDifference.
|
|
317
359
|
* @internal
|
|
318
360
|
*/
|
|
319
361
|
async visitKindOfQuantityPresentationFormatDifference(entry) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
362
|
+
return this.trackOperation(entry, async () => {
|
|
363
|
+
switch (entry.changeType) {
|
|
364
|
+
case "add": return addPresentationFormat(this._context, entry, toItemKey(this._context, entry.itemName));
|
|
365
|
+
}
|
|
366
|
+
});
|
|
323
367
|
}
|
|
324
368
|
}
|
|
325
369
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingVisitor.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingVis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AC,yBAAyB,CAAC,KAAK,EAAE;YAC3C,GAAG,EAAE,aAAa;YAClB,MAAM,EAAE,gBAAgB;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,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;CACF;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,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,qBAAqB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,gCAAgC,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzJ,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACt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,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,aAAa;YAClB,MAAM,EAAE,gBAAgB;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,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;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"]}
|
|
@@ -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
|
|
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
|
*/
|
|
@@ -6,7 +6,7 @@ import { SchemaItemType } from "@itwin/ecschema-metadata";
|
|
|
6
6
|
import { SchemaDifferenceWalker } from "../Differencing/SchemaDifferenceVisitor";
|
|
7
7
|
import { SchemaOtherTypes } from "../Differencing/SchemaDifference";
|
|
8
8
|
/**
|
|
9
|
-
* A walker that traverses the schema differences in a certain
|
|
9
|
+
* A walker that traverses the schema differences in a certain order and invokes the appropriate
|
|
10
10
|
* visitor method for each kind of schema difference.
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yC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;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,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\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
|
|
1
|
+
{"version":3,"file":"SchemaMergingWalker.js","sourceRoot":"","sources":["../../../src/Merging/SchemaMergingWalker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAuC,gBAAgB,EAAc,MAAM,kCAAkC,CAAC;AAErH;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,sBAAsB;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,gBAAgB,CAAC,MAAM,CAAC,CAAC;Y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ACxE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACzD,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAC/D,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YACrE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;YACtE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;YAC5E,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;YACjF,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAE9D,kCAAkC;YAClC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;SAC9E,CAAC,CAAC;IACL,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\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"]}
|
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.11",
|
|
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/core-
|
|
49
|
-
"@itwin/
|
|
45
|
+
"@itwin/build-tools": "5.7.0-dev.11",
|
|
46
|
+
"@itwin/core-bentley": "5.7.0-dev.11",
|
|
47
|
+
"@itwin/ecschema-metadata": "5.7.0-dev.11",
|
|
48
|
+
"@itwin/core-quantity": "5.7.0-dev.11",
|
|
49
|
+
"@itwin/core-common": "5.7.0-dev.11"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@itwin/core-bentley": "5.7.0-dev.
|
|
53
|
-
"@itwin/core-quantity": "5.7.0-dev.
|
|
54
|
-
"@itwin/ecschema-metadata": "5.7.0-dev.
|
|
52
|
+
"@itwin/core-bentley": "5.7.0-dev.11",
|
|
53
|
+
"@itwin/core-quantity": "5.7.0-dev.11",
|
|
54
|
+
"@itwin/ecschema-metadata": "5.7.0-dev.11"
|
|
55
55
|
},
|
|
56
56
|
"nyc": {
|
|
57
57
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|