@itwin/ecschema-editing 4.8.0-dev.37 → 4.8.0-dev.38

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/Differencing/SchemaConflicts.d.ts +2 -0
  3. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  4. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  5. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  6. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +2 -0
  7. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  8. package/lib/cjs/Differencing/Utils.d.ts +11 -1
  9. package/lib/cjs/Differencing/Utils.d.ts.map +1 -1
  10. package/lib/cjs/Differencing/Utils.js +21 -1
  11. package/lib/cjs/Differencing/Utils.js.map +1 -1
  12. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +14 -0
  13. package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -0
  14. package/lib/cjs/Merging/Edits/RenameEditHandler.js +344 -0
  15. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -0
  16. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +78 -0
  17. package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -0
  18. package/lib/cjs/Merging/Edits/SchemaEdits.js +111 -0
  19. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -0
  20. package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts +14 -0
  21. package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts.map +1 -0
  22. package/lib/cjs/Merging/Edits/SkipEditHandler.js +60 -0
  23. package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -0
  24. package/lib/cjs/Merging/SchemaMerger.d.ts +9 -12
  25. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  26. package/lib/cjs/Merging/SchemaMerger.js +40 -37
  27. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  28. package/lib/cjs/ecschema-editing.d.ts +1 -0
  29. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  30. package/lib/cjs/ecschema-editing.js +1 -0
  31. package/lib/cjs/ecschema-editing.js.map +1 -1
  32. package/package.json +9 -9
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Merging
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.applyRenameSchemaItemEdit = exports.applyRenamePropertyEdit = void 0;
11
+ const SchemaDifference_1 = require("../../Differencing/SchemaDifference");
12
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
13
+ const Utils = require("../../Differencing/Utils");
14
+ /**
15
+ * @internal
16
+ */
17
+ function applyRenamePropertyEdit(result, edit) {
18
+ const [itemName, path] = edit.key.split(".");
19
+ let entryIndex = result.differences.findIndex((entry) => {
20
+ return Utils.isClassPropertyDifference(entry) && entry.changeType === "add" && entry.itemName === itemName && entry.path === path;
21
+ });
22
+ if (entryIndex === -1 && result.conflicts) {
23
+ const conflictIndex = result.conflicts.findIndex((entry) => {
24
+ return entry.itemName === itemName && entry.path === path;
25
+ });
26
+ if (conflictIndex > -1) {
27
+ const conflictEntry = result.conflicts[conflictIndex];
28
+ entryIndex = result.differences.push({
29
+ changeType: "add",
30
+ schemaType: SchemaDifference_1.SchemaOtherTypes.Property,
31
+ itemName,
32
+ path,
33
+ difference: conflictEntry.difference,
34
+ }) - 1;
35
+ result.conflicts.splice(conflictIndex, 1);
36
+ }
37
+ }
38
+ const propertyEntry = result.differences[entryIndex];
39
+ if (propertyEntry) {
40
+ propertyEntry.path = edit.value;
41
+ }
42
+ }
43
+ exports.applyRenamePropertyEdit = applyRenamePropertyEdit;
44
+ /**
45
+ * @internal
46
+ */
47
+ function applyRenameSchemaItemEdit(result, edit, postProcessing) {
48
+ let difference = result.differences.find((entry) => {
49
+ return Utils.isSchemaItemDifference(entry) && entry.changeType === "add" && entry.itemName === edit.key;
50
+ });
51
+ if (difference === undefined && result.conflicts) {
52
+ const conflictIndex = result.conflicts.findIndex((entry) => entry.itemName === edit.key && entry.path === undefined);
53
+ if (conflictIndex > -1) {
54
+ const conflictEntry = result.conflicts[conflictIndex];
55
+ result.differences.push(difference = {
56
+ changeType: "add",
57
+ schemaType: conflictEntry.schemaType,
58
+ itemName: edit.value,
59
+ difference: conflictEntry.difference,
60
+ }) - 1;
61
+ result.conflicts.splice(conflictIndex, 1);
62
+ // If item gets added, remove the modify references to this item
63
+ const relatedModifications = [];
64
+ result.differences.forEach((entry, index) => {
65
+ if (Utils.isSchemaItemDifference(entry) && entry.itemName === edit.key) {
66
+ relatedModifications.push(index);
67
+ }
68
+ });
69
+ for (const index of relatedModifications.reverse()) {
70
+ result.differences.splice(index, 1);
71
+ }
72
+ }
73
+ }
74
+ const itemDifference = difference;
75
+ if (itemDifference === undefined) {
76
+ return;
77
+ }
78
+ renameName(itemDifference, edit.key, edit.value);
79
+ postProcessing(() => {
80
+ renameSchemaItem(result, edit, itemDifference.schemaType);
81
+ });
82
+ }
83
+ exports.applyRenameSchemaItemEdit = applyRenameSchemaItemEdit;
84
+ function renameSchemaItem(result, edit, schemaType) {
85
+ const schemaKey = ecschema_metadata_1.SchemaKey.parseString(result.sourceSchemaName);
86
+ const oldKey = new ecschema_metadata_1.SchemaItemKey(edit.key, schemaKey);
87
+ const newKey = new ecschema_metadata_1.SchemaItemKey(edit.value, schemaKey);
88
+ switch (schemaType) {
89
+ case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
90
+ renameCustomAttributeClassName(result, oldKey, newKey);
91
+ break;
92
+ case ecschema_metadata_1.SchemaItemType.EntityClass:
93
+ renameEntityClassName(result, oldKey, newKey);
94
+ break;
95
+ case ecschema_metadata_1.SchemaItemType.Enumeration:
96
+ renameEnumerationName(result, oldKey, newKey);
97
+ break;
98
+ case ecschema_metadata_1.SchemaItemType.Format:
99
+ break;
100
+ case ecschema_metadata_1.SchemaItemType.InvertedUnit:
101
+ break;
102
+ case ecschema_metadata_1.SchemaItemType.KindOfQuantity:
103
+ renameKindOfQuantityName(result, oldKey, newKey);
104
+ break;
105
+ case ecschema_metadata_1.SchemaItemType.Mixin:
106
+ renameMixinName(result, oldKey, newKey);
107
+ break;
108
+ case ecschema_metadata_1.SchemaItemType.Phenomenon:
109
+ renamePhenomenonName(result, oldKey, newKey);
110
+ break;
111
+ case ecschema_metadata_1.SchemaItemType.PropertyCategory:
112
+ renamePropertyCategoryName(result, oldKey, newKey);
113
+ break;
114
+ case ecschema_metadata_1.SchemaItemType.RelationshipClass:
115
+ renameRelationshipClassName(result, oldKey, newKey);
116
+ break;
117
+ case ecschema_metadata_1.SchemaItemType.StructClass:
118
+ renameStructClassName(result, oldKey, newKey);
119
+ break;
120
+ case ecschema_metadata_1.SchemaItemType.Unit:
121
+ break;
122
+ case ecschema_metadata_1.SchemaItemType.UnitSystem:
123
+ break;
124
+ }
125
+ }
126
+ function renameBaseClass(difference, oldKey, newKey) {
127
+ if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {
128
+ difference.baseClass = newKey.fullName;
129
+ }
130
+ }
131
+ function renameName(change, oldName, newName) {
132
+ if (change.itemName === oldName) {
133
+ const schemaItemDifference = change;
134
+ schemaItemDifference.itemName = newName;
135
+ }
136
+ }
137
+ function renameRelationshipConstraint(change, oldKey, newKey) {
138
+ if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
139
+ const constraintProps = [change.difference.source, change.difference.target];
140
+ for (const props of constraintProps) {
141
+ if (props) {
142
+ if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {
143
+ props.abstractConstraint = newKey.fullName;
144
+ }
145
+ if (props.constraintClasses !== undefined) {
146
+ for (let i = 0; i < props.constraintClasses.length; i++) {
147
+ if (oldKey.matchesFullName(props.constraintClasses[i]))
148
+ props.constraintClasses[i] = newKey.fullName;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ else {
155
+ for (let i = 0; i < change.difference.length; i++) {
156
+ if (oldKey.matchesFullName(change.difference[i]))
157
+ change.difference[i] = newKey.fullName;
158
+ }
159
+ }
160
+ }
161
+ function renamePropertyCategoryName({ differences }, oldKey, newKey) {
162
+ for (const entry of differences) {
163
+ if (entry.schemaType === ecschema_metadata_1.SchemaItemType.PropertyCategory) {
164
+ renameName(entry, oldKey.name, newKey.name);
165
+ }
166
+ if (Utils.isClassDifference(entry) && entry.difference.properties) {
167
+ for (const property of entry.difference.properties) {
168
+ if (property.category && oldKey.matchesFullName(property.category)) {
169
+ const props = property;
170
+ props.category = newKey.fullName;
171
+ }
172
+ }
173
+ }
174
+ if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.Property) {
175
+ if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {
176
+ entry.difference.category = newKey.fullName;
177
+ }
178
+ }
179
+ }
180
+ }
181
+ function renameKindOfQuantityName({ differences }, oldKey, newKey) {
182
+ for (const entry of differences) {
183
+ if (Utils.isClassDifference(entry) && entry.difference.properties) {
184
+ for (const property of entry.difference.properties) {
185
+ if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {
186
+ const props = property;
187
+ props.kindOfQuantity = newKey.fullName;
188
+ }
189
+ }
190
+ }
191
+ if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.Property) {
192
+ if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {
193
+ entry.difference.kindOfQuantity = newKey.fullName;
194
+ }
195
+ }
196
+ }
197
+ }
198
+ function renameEnumerationName({ differences }, oldKey, newKey) {
199
+ for (const change of differences) {
200
+ if (Utils.isClassDifference(change) && change.difference.properties) {
201
+ for (const property of change.difference.properties) {
202
+ if (property.type === "PrimitiveProperty" || property.type === "PrimitiveArrayProperty") {
203
+ const props = property;
204
+ if (props.typeName && oldKey.matchesFullName(props.typeName))
205
+ props.typeName = newKey.fullName;
206
+ }
207
+ }
208
+ }
209
+ if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && (change.difference.type === "PrimitiveProperty" || change.difference.type === "PrimitiveArrayProperty")) {
210
+ const props = change.difference;
211
+ if (props.typeName && oldKey.matchesFullName(props.typeName))
212
+ props.typeName = newKey.fullName;
213
+ }
214
+ }
215
+ }
216
+ function renamePhenomenonName({ differences }, oldKey, newKey) {
217
+ for (const entry of differences) {
218
+ if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Constant || entry.schemaType === ecschema_metadata_1.SchemaItemType.Unit) {
219
+ if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))
220
+ entry.difference.phenomenon = newKey.fullName;
221
+ }
222
+ }
223
+ }
224
+ function renameStructClassName({ differences }, oldKey, newKey) {
225
+ for (const change of differences) {
226
+ if (change.schemaType === ecschema_metadata_1.SchemaItemType.StructClass) {
227
+ renameBaseClass(change.difference, oldKey, newKey);
228
+ }
229
+ if (Utils.isClassDifference(change) && change.difference.properties) {
230
+ for (const property of change.difference.properties) {
231
+ if (property.type === "StructProperty" || property.type === "StructArrayProperty") {
232
+ const props = property;
233
+ ;
234
+ if (props.typeName && oldKey.matchesFullName(props.typeName))
235
+ props.typeName = newKey.fullName;
236
+ }
237
+ }
238
+ }
239
+ if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && (change.difference.type === "StructProperty" || change.difference.type === "StructArrayProperty")) {
240
+ const props = change.difference;
241
+ if (props.typeName && oldKey.matchesFullName(props.typeName))
242
+ props.typeName = newKey.fullName;
243
+ }
244
+ }
245
+ }
246
+ function renameCustomAttributeClassName({ differences }, oldKey, newKey) {
247
+ for (const change of differences) {
248
+ if (change.schemaType === ecschema_metadata_1.SchemaItemType.CustomAttributeClass) {
249
+ renameBaseClass(change.difference, oldKey, newKey);
250
+ }
251
+ if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.CustomAttributeInstance) {
252
+ if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {
253
+ change.difference.className = newKey.fullName;
254
+ }
255
+ }
256
+ if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property || Utils.isClassDifference(change)) {
257
+ if (change.difference.customAttributes) {
258
+ for (const customAttribute of change.difference.customAttributes) {
259
+ if (oldKey.matchesFullName(customAttribute.className))
260
+ customAttribute.className = newKey.fullName;
261
+ }
262
+ }
263
+ }
264
+ if (Utils.isClassDifference(change) && change.difference.properties) {
265
+ for (const property of change.difference.properties) {
266
+ if (property.customAttributes) {
267
+ for (const customAttribute of property.customAttributes) {
268
+ if (oldKey.matchesFullName(customAttribute.className))
269
+ customAttribute.className = newKey.fullName;
270
+ }
271
+ }
272
+ }
273
+ }
274
+ // https://github.com/iTwin/itwinjs-core/issues/7020
275
+ /* if (change.schemaType === SchemaItemType.RelationshipClass) {
276
+ const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];
277
+ for (const props of constraintProps) {
278
+ if (props.customAttributes !== undefined) {
279
+ for (const customAttribute of props.customAttributes) {
280
+ if (oldKey.matchesFullName(customAttribute.className))
281
+ customAttribute.className = newKey.fullName;
282
+ }
283
+ }
284
+ }
285
+ } */
286
+ }
287
+ }
288
+ function renameRelationshipClassName({ differences }, oldKey, newKey) {
289
+ for (const change of differences) {
290
+ if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
291
+ renameBaseClass(change.difference, oldKey, newKey);
292
+ }
293
+ if (change.schemaType === SchemaDifference_1.SchemaOtherTypes.Property && change.difference.type === "NavigationProperty") {
294
+ const props = change.difference;
295
+ if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))
296
+ props.relationshipName = newKey.fullName;
297
+ }
298
+ if (Utils.isClassDifference(change) && change.difference.properties) {
299
+ for (const property of change.difference.properties) {
300
+ if (property.type === "NavigationProperty") {
301
+ const props = property;
302
+ if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))
303
+ props.relationshipName = newKey.fullName;
304
+ }
305
+ }
306
+ }
307
+ if (change.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass || change.schemaType === SchemaDifference_1.SchemaOtherTypes.RelationshipConstraintClass) {
308
+ renameRelationshipConstraint(change, oldKey, newKey);
309
+ }
310
+ }
311
+ }
312
+ function renameEntityClassName({ differences }, oldKey, newKey) {
313
+ for (const entry of differences) {
314
+ if (entry.schemaType === ecschema_metadata_1.SchemaItemType.EntityClass) {
315
+ renameName(entry, oldKey.name, newKey.name);
316
+ renameBaseClass(entry.difference, oldKey, newKey);
317
+ }
318
+ if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Mixin) {
319
+ if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))
320
+ entry.difference.appliesTo = newKey.fullName;
321
+ }
322
+ if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {
323
+ renameRelationshipConstraint(entry, oldKey, newKey);
324
+ }
325
+ }
326
+ }
327
+ function renameMixinName({ differences }, oldKey, newKey) {
328
+ for (const entry of differences) {
329
+ if (entry.schemaType === ecschema_metadata_1.SchemaItemType.Mixin) {
330
+ renameBaseClass(entry.difference, oldKey, newKey);
331
+ }
332
+ if (entry.schemaType === SchemaDifference_1.SchemaOtherTypes.EntityClassMixin) {
333
+ for (let i = 0; i < entry.difference.length; i++) {
334
+ if (oldKey.matchesFullName(entry.difference[i])) {
335
+ entry.difference[i] = newKey.fullName;
336
+ }
337
+ }
338
+ }
339
+ if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {
340
+ renameRelationshipConstraint(entry, oldKey, newKey);
341
+ }
342
+ }
343
+ }
344
+ //# sourceMappingURL=RenameEditHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenameEditHandler.js","sour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gB,CAAC,gBAAgB,EAAE,CAAC;YAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,IAAI,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChD,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,6BAA6B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,KAAK,CAAC,EAAE,CAAC;YACvG,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { RenamePropertyEdit, RenameSchemaItemEdit } from \"./SchemaEdits\";\nimport { AnySchemaItemDifference, ClassItemDifference, ClassPropertyDifference, RelationshipClassDifference, RelationshipConstraintClassDifference, SchemaDifferenceResult, SchemaOtherTypes, SchemaType } from \"../../Differencing/SchemaDifference\";\nimport { NavigationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, RelationshipConstraintProps, SchemaItemKey, SchemaItemType, SchemaKey, StructArrayPropertyProps, StructPropertyProps } from \"@itwin/ecschema-metadata\";\nimport * as Utils from \"../../Differencing/Utils\";\n\ntype Editable<T extends object> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * @internal\n */\nexport function applyRenamePropertyEdit(result: SchemaDifferenceResult, edit: RenamePropertyEdit) {\n const [itemName, path] = edit.key.split(\".\") as [string, string];\n\n let entryIndex = result.differences.findIndex((entry) => {\n return Utils.isClassPropertyDifference(entry) && entry.changeType === \"add\" && entry.itemName === itemName && entry.path === path;\n });\n\n if (entryIndex === -1 && result.conflicts) {\n const conflictIndex = result.conflicts.findIndex((entry) => {\n return entry.itemName === itemName && entry.path === path;\n });\n\n if (conflictIndex > -1) {\n const conflictEntry = result.conflicts[conflictIndex];\n entryIndex = result.differences.push({\n changeType: \"add\",\n schemaType: SchemaOtherTypes.Property,\n itemName,\n path,\n difference: conflictEntry.difference,\n } as ClassPropertyDifference) - 1;\n\n result.conflicts.splice(conflictIndex, 1);\n }\n }\n\n const propertyEntry = result.differences[entryIndex] as Editable<ClassPropertyDifference>;\n if (propertyEntry) {\n propertyEntry.path = edit.value;\n }\n}\n\n/**\n * @internal\n */\nexport function applyRenameSchemaItemEdit(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, postProcessing: (cb: () => void) => void) {\n let difference = result.differences.find((entry) => {\n return Utils.isSchemaItemDifference(entry) && entry.changeType === \"add\" && entry.itemName === edit.key;\n });\n\n if (difference === undefined && result.conflicts) {\n const conflictIndex = result.conflicts.findIndex((entry) => entry.itemName === edit.key && entry.path === undefined);\n if (conflictIndex > -1) {\n const conflictEntry = result.conflicts[conflictIndex];\n result.differences.push(difference = {\n changeType: \"add\",\n schemaType: conflictEntry.schemaType,\n itemName: edit.value,\n difference: conflictEntry.difference,\n } as AnySchemaItemDifference) - 1;\n\n result.conflicts.splice(conflictIndex, 1);\n\n // If item gets added, remove the modify references to this item\n const relatedModifications: number[] = [];\n result.differences.forEach((entry, index) => {\n if (Utils.isSchemaItemDifference(entry) && entry.itemName === edit.key) {\n relatedModifications.push(index);\n }\n });\n\n for (const index of relatedModifications.reverse()) {\n result.differences.splice(index, 1);\n }\n }\n }\n\n const itemDifference = difference as AnySchemaItemDifference;\n if (itemDifference === undefined) {\n return;\n }\n\n renameName(itemDifference, edit.key, edit.value);\n\n postProcessing(() => {\n renameSchemaItem(result, edit, itemDifference.schemaType);\n });\n}\n\nfunction renameSchemaItem(result: SchemaDifferenceResult, edit: RenameSchemaItemEdit, schemaType: SchemaType) {\n const schemaKey = SchemaKey.parseString(result.sourceSchemaName);\n const oldKey = new SchemaItemKey(edit.key, schemaKey);\n const newKey = new SchemaItemKey(edit.value, schemaKey);\n\n switch (schemaType) {\n case SchemaItemType.CustomAttributeClass:\n renameCustomAttributeClassName(result, oldKey, newKey);\n break;\n case SchemaItemType.EntityClass:\n renameEntityClassName(result, oldKey, newKey);\n break;\n case SchemaItemType.Enumeration:\n renameEnumerationName(result, oldKey, newKey);\n break;\n case SchemaItemType.Format:\n break;\n case SchemaItemType.InvertedUnit:\n break;\n case SchemaItemType.KindOfQuantity:\n renameKindOfQuantityName(result, oldKey, newKey);\n break;\n case SchemaItemType.Mixin:\n renameMixinName(result, oldKey, newKey);\n break;\n case SchemaItemType.Phenomenon:\n renamePhenomenonName(result, oldKey, newKey);\n break;\n case SchemaItemType.PropertyCategory:\n renamePropertyCategoryName(result, oldKey, newKey);\n break;\n case SchemaItemType.RelationshipClass:\n renameRelationshipClassName(result, oldKey, newKey);\n break;\n case SchemaItemType.StructClass:\n renameStructClassName(result, oldKey, newKey);\n break;\n case SchemaItemType.Unit:\n break;\n case SchemaItemType.UnitSystem:\n break;\n }\n}\n\nfunction renameBaseClass(difference: ClassItemDifference[\"difference\"], oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n if (difference.baseClass && oldKey.matchesFullName(difference.baseClass)) {\n difference.baseClass = newKey.fullName;\n }\n}\n\nfunction renameName(change: AnySchemaItemDifference, oldName: string, newName: string) {\n if (change.itemName === oldName) {\n const schemaItemDifference = change as Editable<AnySchemaItemDifference>;\n schemaItemDifference.itemName = newName;\n }\n}\n\nfunction renameRelationshipConstraint(change: RelationshipClassDifference | RelationshipConstraintClassDifference, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n if (change.schemaType === SchemaItemType.RelationshipClass) {\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\n for (const props of constraintProps) {\n if (props) {\n if (props.abstractConstraint && oldKey.matchesFullName(props.abstractConstraint)) {\n props.abstractConstraint = newKey.fullName;\n }\n if (props.constraintClasses !== undefined) {\n for (let i = 0; i < props.constraintClasses.length; i++) {\n if (oldKey.matchesFullName(props.constraintClasses[i]))\n props.constraintClasses[i] = newKey.fullName;\n }\n }\n }\n }\n } else {\n for (let i = 0; i < change.difference.length; i++) {\n if (oldKey.matchesFullName(change.difference[i]))\n change.difference[i] = newKey.fullName;\n }\n }\n}\n\nfunction renamePropertyCategoryName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const entry of differences) {\n if (entry.schemaType === SchemaItemType.PropertyCategory) {\n renameName(entry, oldKey.name, newKey.name);\n }\n\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\n for (const property of entry.difference.properties) {\n if (property.category && oldKey.matchesFullName(property.category)) {\n const props = property as Editable<typeof property>;\n props.category = newKey.fullName;\n }\n }\n }\n\n if (entry.schemaType === SchemaOtherTypes.Property) {\n if (entry.difference.category && oldKey.matchesFullName(entry.difference.category)) {\n entry.difference.category = newKey.fullName;\n }\n }\n }\n}\n\nfunction renameKindOfQuantityName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const entry of differences) {\n if (Utils.isClassDifference(entry) && entry.difference.properties) {\n for (const property of entry.difference.properties) {\n if (property.kindOfQuantity && oldKey.matchesFullName(property.kindOfQuantity)) {\n const props = property as Editable<typeof property>;\n props.kindOfQuantity = newKey.fullName;\n }\n }\n }\n\n if (entry.schemaType === SchemaOtherTypes.Property) {\n if (entry.difference.kindOfQuantity && oldKey.matchesFullName(entry.difference.kindOfQuantity)) {\n entry.difference.kindOfQuantity = newKey.fullName;\n }\n }\n }\n}\n\nfunction renameEnumerationName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const change of differences) {\n if (Utils.isClassDifference(change) && change.difference.properties) {\n for (const property of change.difference.properties) {\n if (property.type === \"PrimitiveProperty\" || property.type === \"PrimitiveArrayProperty\") {\n const props = property as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\n if (props.typeName && oldKey.matchesFullName(props.typeName))\n props.typeName = newKey.fullName;\n }\n }\n }\n\n if (change.schemaType === SchemaOtherTypes.Property && (\n change.difference.type === \"PrimitiveProperty\" || change.difference.type === \"PrimitiveArrayProperty\"\n )) {\n const props = change.difference as Editable<PrimitivePropertyProps | PrimitiveArrayPropertyProps>;\n if (props.typeName && oldKey.matchesFullName(props.typeName))\n props.typeName = newKey.fullName;\n }\n }\n}\n\nfunction renamePhenomenonName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const entry of differences) {\n if (entry.schemaType === SchemaItemType.Constant || entry.schemaType === SchemaItemType.Unit) {\n if (entry.difference.phenomenon && oldKey.matchesFullName(entry.difference.phenomenon))\n entry.difference.phenomenon = newKey.fullName;\n }\n }\n}\n\nfunction renameStructClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const change of differences) {\n if (change.schemaType === SchemaItemType.StructClass) {\n renameBaseClass(change.difference, oldKey, newKey);\n }\n\n if (Utils.isClassDifference(change) && change.difference.properties) {\n for (const property of change.difference.properties) {\n if (property.type === \"StructProperty\" || property.type === \"StructArrayProperty\") {\n const props = property as Editable<StructPropertyProps | StructArrayPropertyProps>;;\n if (props.typeName && oldKey.matchesFullName(props.typeName))\n props.typeName = newKey.fullName;\n }\n }\n }\n\n if (change.schemaType === SchemaOtherTypes.Property && (\n change.difference.type === \"StructProperty\" || change.difference.type === \"StructArrayProperty\"\n )) {\n const props = change.difference as Editable<StructPropertyProps | StructArrayPropertyProps>;\n if (props.typeName && oldKey.matchesFullName(props.typeName))\n props.typeName = newKey.fullName;\n }\n }\n}\n\nfunction renameCustomAttributeClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const change of differences) {\n if (change.schemaType === SchemaItemType.CustomAttributeClass) {\n renameBaseClass(change.difference, oldKey, newKey);\n }\n\n if (change.schemaType === SchemaOtherTypes.CustomAttributeInstance) {\n if (change.difference.className && oldKey.matchesFullName(change.difference.className)) {\n change.difference.className = newKey.fullName;\n }\n }\n\n if (change.schemaType === SchemaOtherTypes.Property || Utils.isClassDifference(change)) {\n if (change.difference.customAttributes) {\n for (const customAttribute of change.difference.customAttributes) {\n if (oldKey.matchesFullName(customAttribute.className))\n customAttribute.className = newKey.fullName;\n }\n }\n }\n\n if (Utils.isClassDifference(change) && change.difference.properties) {\n for (const property of change.difference.properties) {\n if (property.customAttributes) {\n for (const customAttribute of property.customAttributes) {\n if (oldKey.matchesFullName(customAttribute.className))\n customAttribute.className = newKey.fullName;\n }\n }\n }\n }\n // https://github.com/iTwin/itwinjs-core/issues/7020\n /* if (change.schemaType === SchemaItemType.RelationshipClass) {\n const constraintProps = [change.difference.source, change.difference.target] as Editable<RelationshipConstraintProps>[];\n for (const props of constraintProps) {\n if (props.customAttributes !== undefined) {\n for (const customAttribute of props.customAttributes) {\n if (oldKey.matchesFullName(customAttribute.className))\n customAttribute.className = newKey.fullName;\n }\n }\n }\n } */\n }\n}\n\nfunction renameRelationshipClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const change of differences) {\n if (change.schemaType === SchemaItemType.RelationshipClass) {\n renameBaseClass(change.difference, oldKey, newKey);\n }\n\n if (change.schemaType === SchemaOtherTypes.Property && change.difference.type === \"NavigationProperty\") {\n const props = change.difference as Editable<NavigationPropertyProps>;\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\n props.relationshipName = newKey.fullName;\n }\n\n if (Utils.isClassDifference(change) && change.difference.properties) {\n for (const property of change.difference.properties) {\n if (property.type === \"NavigationProperty\") {\n const props = property as Editable<NavigationPropertyProps>;\n if (props.relationshipName && oldKey.matchesFullName(props.relationshipName))\n props.relationshipName = newKey.fullName;\n }\n }\n }\n\n if (change.schemaType === SchemaItemType.RelationshipClass || change.schemaType === SchemaOtherTypes.RelationshipConstraintClass) {\n renameRelationshipConstraint(change, oldKey, newKey);\n }\n }\n}\n\nfunction renameEntityClassName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const entry of differences) {\n if (entry.schemaType === SchemaItemType.EntityClass) {\n renameName(entry, oldKey.name, newKey.name);\n renameBaseClass(entry.difference, oldKey, newKey);\n }\n\n if (entry.schemaType === SchemaItemType.Mixin) {\n if (entry.difference.appliesTo && oldKey.matchesFullName(entry.difference.appliesTo))\n entry.difference.appliesTo = newKey.fullName;\n }\n\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\n renameRelationshipConstraint(entry, oldKey, newKey);\n }\n }\n}\n\nfunction renameMixinName({ differences }: SchemaDifferenceResult, oldKey: SchemaItemKey, newKey: SchemaItemKey) {\n for (const entry of differences) {\n if (entry.schemaType === SchemaItemType.Mixin) {\n renameBaseClass(entry.difference, oldKey, newKey);\n }\n\n if (entry.schemaType === SchemaOtherTypes.EntityClassMixin) {\n for (let i = 0; i < entry.difference.length; i++) {\n if (oldKey.matchesFullName(entry.difference[i])) {\n entry.difference[i] = newKey.fullName;\n }\n }\n }\n\n if (Utils.isRelationshipClassDifference(entry) || Utils.isRelationshipConstraintClassDifference(entry)) {\n renameRelationshipConstraint(entry, oldKey, newKey);\n }\n }\n}\n"]}
@@ -0,0 +1,78 @@
1
+ /** @packageDocumentation
2
+ * @module Merging
3
+ */
4
+ import type { SchemaDifferenceResult } from "../../Differencing/SchemaDifference";
5
+ /**
6
+ * An enumeration that has all the schema edit names.
7
+ * @alpha
8
+ */
9
+ export declare enum SchemaEditType {
10
+ RenameSchemaItem = "RenameSchemaItem",
11
+ RenameProperty = "RenameProperty",
12
+ Skip = "Skip"
13
+ }
14
+ /**
15
+ * Schema edit entry to rename a schema item.
16
+ * @alpha
17
+ */
18
+ export interface RenameSchemaItemEdit {
19
+ type: SchemaEditType.RenameSchemaItem;
20
+ key: string;
21
+ value: string;
22
+ }
23
+ /**
24
+ * Schema edit entry to rename a property of a class.
25
+ * @alpha
26
+ */
27
+ export interface RenamePropertyEdit {
28
+ type: SchemaEditType.RenameProperty;
29
+ key: string;
30
+ value: string;
31
+ }
32
+ /**
33
+ * Schema edit entry to skip a certain schema element matching the given key.
34
+ * @alpha
35
+ */
36
+ export interface SkipEdit {
37
+ type: SchemaEditType.Skip;
38
+ key: string;
39
+ }
40
+ /**
41
+ * Union for all supported edits that can be applied to a schema.
42
+ * @alpha
43
+ */
44
+ export type AnySchemaEdits = SkipEdit | RenameSchemaItemEdit | RenamePropertyEdit;
45
+ declare abstract class Editor {
46
+ private readonly _edits;
47
+ constructor(edits: Array<AnySchemaEdits>);
48
+ protected add(edit: AnySchemaEdits): void;
49
+ }
50
+ declare class PropertyEditor extends Editor {
51
+ rename(className: string, propertyName: string, newName: string): void;
52
+ skip(className: string, propertyName: string): void;
53
+ }
54
+ declare class ItemEditor extends Editor {
55
+ rename(itemName: string, newName: string): void;
56
+ skip(itemName: string): void;
57
+ }
58
+ /**
59
+ * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class
60
+ * is to support saving of edits and load them again if needed.
61
+ * @alpha
62
+ */
63
+ export declare class SchemaEdits {
64
+ private readonly _edits;
65
+ readonly properties: PropertyEditor;
66
+ readonly items: ItemEditor;
67
+ /**
68
+ * @alpha
69
+ */
70
+ constructor(initialize?: ReadonlyArray<AnySchemaEdits>);
71
+ /**
72
+ * @internal
73
+ */
74
+ applyTo(differenceResult: SchemaDifferenceResult): Promise<void>;
75
+ toJSON(): ReadonlyArray<AnySchemaEdits>;
76
+ }
77
+ export {};
78
+ //# sourceMappingURL=SchemaEdits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaEdits.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SchemaEdits.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,MAAM,CAAwB;IAE/C,SAAgB,UAAU,EAAE,cAAc,CAAC;IAC3C,SAAgB,KAAK,EAAE,UAAU,CAAC;IAElC;;OAEG;gBACS,UAAU,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC;IAWtD;;OAEG;IACU,OAAO,CAAC,gBAAgB,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtE,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC;CAG/C"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Merging
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SchemaEdits = exports.SchemaEditType = void 0;
11
+ const RenameEditHandler_1 = require("./RenameEditHandler");
12
+ const SkipEditHandler_1 = require("./SkipEditHandler");
13
+ /**
14
+ * An enumeration that has all the schema edit names.
15
+ * @alpha
16
+ */
17
+ var SchemaEditType;
18
+ (function (SchemaEditType) {
19
+ SchemaEditType["RenameSchemaItem"] = "RenameSchemaItem";
20
+ SchemaEditType["RenameProperty"] = "RenameProperty";
21
+ SchemaEditType["Skip"] = "Skip";
22
+ })(SchemaEditType || (exports.SchemaEditType = SchemaEditType = {}));
23
+ class Editor {
24
+ constructor(edits) {
25
+ this._edits = edits;
26
+ }
27
+ add(edit) {
28
+ const overrideEntry = this._edits.findIndex((entry) => {
29
+ return entry.type === edit.type && entry.key === edit.key;
30
+ });
31
+ if (overrideEntry > -1) {
32
+ this._edits[overrideEntry] = edit;
33
+ }
34
+ else {
35
+ this._edits.push(edit);
36
+ }
37
+ }
38
+ }
39
+ class PropertyEditor extends Editor {
40
+ rename(className, propertyName, newName) {
41
+ this.add({
42
+ type: SchemaEditType.RenameProperty,
43
+ key: `${className}.${propertyName}`,
44
+ value: newName,
45
+ });
46
+ }
47
+ skip(className, propertyName) {
48
+ this.add({
49
+ type: SchemaEditType.Skip,
50
+ key: `${className}.${propertyName}`,
51
+ });
52
+ }
53
+ }
54
+ class ItemEditor extends Editor {
55
+ rename(itemName, newName) {
56
+ this.add({
57
+ type: SchemaEditType.RenameSchemaItem,
58
+ key: itemName,
59
+ value: newName,
60
+ });
61
+ }
62
+ skip(itemName) {
63
+ this.add({
64
+ type: SchemaEditType.Skip,
65
+ key: itemName,
66
+ });
67
+ }
68
+ }
69
+ /**
70
+ * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class
71
+ * is to support saving of edits and load them again if needed.
72
+ * @alpha
73
+ */
74
+ class SchemaEdits {
75
+ /**
76
+ * @alpha
77
+ */
78
+ constructor(initialize) {
79
+ this._edits = [];
80
+ if (initialize) {
81
+ this._edits.push(...initialize);
82
+ }
83
+ this.items = new ItemEditor(this._edits);
84
+ this.properties = new PropertyEditor(this._edits);
85
+ }
86
+ /**
87
+ * @internal
88
+ */
89
+ async applyTo(differenceResult) {
90
+ const postProcessing = [];
91
+ for (const schemaEdit of this._edits) {
92
+ if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {
93
+ (0, RenameEditHandler_1.applyRenameSchemaItemEdit)(differenceResult, schemaEdit, postProcessing.push.bind(postProcessing));
94
+ }
95
+ if (schemaEdit.type === SchemaEditType.RenameProperty) {
96
+ (0, RenameEditHandler_1.applyRenamePropertyEdit)(differenceResult, schemaEdit);
97
+ }
98
+ if (schemaEdit.type === SchemaEditType.Skip) {
99
+ (0, SkipEditHandler_1.applySkipEdit)(differenceResult, schemaEdit);
100
+ }
101
+ }
102
+ for (const callback of postProcessing) {
103
+ callback();
104
+ }
105
+ }
106
+ toJSON() {
107
+ return this._edits;
108
+ }
109
+ }
110
+ exports.SchemaEdits = SchemaEdits;
111
+ //# sourceMappingURL=SchemaEdits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaEdits.js","sourceRoot":"","sources":["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CAAC;YACD,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAA,+BAAa,EAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AA7CD,kCA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Merging\n */\n\nimport type { SchemaDifferenceResult } from \"../../Differencing/SchemaDifference\";\nimport { applyRenamePropertyEdit, applyRenameSchemaItemEdit } from \"./RenameEditHandler\";\nimport { applySkipEdit } from \"./SkipEditHandler\";\n\n/**\n * An enumeration that has all the schema edit names.\n * @alpha\n */\nexport enum SchemaEditType {\n RenameSchemaItem = \"RenameSchemaItem\",\n RenameProperty = \"RenameProperty\",\n Skip = \"Skip\",\n}\n\n/**\n * Schema edit entry to rename a schema item.\n * @alpha\n */\nexport interface RenameSchemaItemEdit {\n type: SchemaEditType.RenameSchemaItem;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to rename a property of a class.\n * @alpha\n */\nexport interface RenamePropertyEdit {\n type: SchemaEditType.RenameProperty;\n key: string;\n value: string;\n}\n\n/**\n * Schema edit entry to skip a certain schema element matching the given key.\n * @alpha\n */\nexport interface SkipEdit {\n type: SchemaEditType.Skip;\n key: string;\n}\n\n/**\n * Union for all supported edits that can be applied to a schema.\n * @alpha\n */\nexport type AnySchemaEdits =\n SkipEdit |\n RenameSchemaItemEdit |\n RenamePropertyEdit;\n\nabstract class Editor {\n private readonly _edits: Array<AnySchemaEdits>;\n\n constructor(edits: Array<AnySchemaEdits>) {\n this._edits = edits;\n }\n\n protected add(edit: AnySchemaEdits) {\n const overrideEntry = this._edits.findIndex((entry) => {\n return entry.type === edit.type && entry.key === edit.key;\n });\n\n if (overrideEntry > -1) {\n this._edits[overrideEntry] = edit;\n } else {\n this._edits.push(edit);\n }\n }\n}\n\nclass PropertyEditor extends Editor {\n\n public rename(className: string, propertyName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameProperty,\n key: `${className}.${propertyName}`,\n value: newName,\n });\n }\n\n public skip(className: string, propertyName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: `${className}.${propertyName}`,\n });\n }\n}\n\nclass ItemEditor extends Editor {\n public rename(itemName: string, newName: string) {\n this.add({\n type: SchemaEditType.RenameSchemaItem,\n key: itemName,\n value: newName,\n });\n }\n\n public skip(itemName: string) {\n this.add({\n type: SchemaEditType.Skip,\n key: itemName,\n });\n }\n}\n\n/**\n * Defines a set of edits of a schema that can be applied to a schema during merging. The intention of this class\n * is to support saving of edits and load them again if needed.\n * @alpha\n */\nexport class SchemaEdits {\n private readonly _edits: Array<AnySchemaEdits>;\n\n public readonly properties: PropertyEditor;\n public readonly items: ItemEditor;\n\n /**\n * @alpha\n */\n constructor(initialize?: ReadonlyArray<AnySchemaEdits>) {\n this._edits = [];\n\n if (initialize) {\n this._edits.push(...initialize);\n }\n\n this.items = new ItemEditor(this._edits);\n this.properties = new PropertyEditor(this._edits);\n }\n\n /**\n * @internal\n */\n public async applyTo(differenceResult: SchemaDifferenceResult): Promise<void> {\n const postProcessing: Array<() => void> = [];\n for (const schemaEdit of this._edits) {\n if (schemaEdit.type === SchemaEditType.RenameSchemaItem) {\n applyRenameSchemaItemEdit(differenceResult, schemaEdit, postProcessing.push.bind(postProcessing));\n }\n if (schemaEdit.type === SchemaEditType.RenameProperty) {\n applyRenamePropertyEdit(differenceResult, schemaEdit);\n }\n if (schemaEdit.type === SchemaEditType.Skip) {\n applySkipEdit(differenceResult, schemaEdit);\n }\n }\n\n for (const callback of postProcessing) {\n callback();\n }\n }\n\n public toJSON(): ReadonlyArray<AnySchemaEdits> {\n return this._edits;\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /** @packageDocumentation
2
+ * @module Merging
3
+ */
4
+ import type { SchemaDifferenceResult } from "../../Differencing/SchemaDifference";
5
+ import type { SkipEdit } from "./SchemaEdits";
6
+ /**
7
+ * Applies a skip edit to the schema differences. It basically removes all entries that
8
+ * that are associated with the item to skip.
9
+ * @param result The result of a schema differencing run
10
+ * @param edit The skip edit to be applied.
11
+ * @internal
12
+ */
13
+ export declare function applySkipEdit(result: SchemaDifferenceResult, edit: SkipEdit): void;
14
+ //# sourceMappingURL=SkipEditHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkipEditHandler.d.ts","sourceRoot":"","sources":["../../../../src/Merging/Edits/SkipEditHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,QAAQ,QAa3E"}