@itwin/ecschema-editing 4.8.0-dev.4 → 4.8.0-dev.41
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 +48 -1
- package/lib/cjs/Differencing/SchemaConflicts.d.ts +2 -0
- package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +1 -0
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +25 -11
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +10 -119
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js +28 -198
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/Utils.d.ts +110 -0
- package/lib/cjs/Differencing/Utils.d.ts.map +1 -0
- package/lib/cjs/Differencing/Utils.js +185 -0
- package/lib/cjs/Differencing/Utils.js.map +1 -0
- package/lib/cjs/Editing/CustomAttributes.d.ts +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +2 -2
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +0 -7
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +0 -27
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +19 -3
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +48 -3
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts +0 -1
- package/lib/cjs/Editing/Exception.d.ts.map +1 -1
- package/lib/cjs/Editing/Exception.js +0 -1
- package/lib/cjs/Editing/Exception.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +4 -1
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +3 -1
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +2 -0
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.d.ts +1 -0
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts +1 -4
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +4 -5
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +9 -2
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +31 -24
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +2 -2
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +10 -10
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts +14 -0
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -0
- package/lib/cjs/Merging/Edits/RenameEditHandler.js +344 -0
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -0
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts +78 -0
- package/lib/cjs/Merging/Edits/SchemaEdits.d.ts.map +1 -0
- package/lib/cjs/Merging/Edits/SchemaEdits.js +111 -0
- package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -0
- package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts +14 -0
- package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts.map +1 -0
- package/lib/cjs/Merging/Edits/SkipEditHandler.js +60 -0
- package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -0
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +4 -4
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +18 -18
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +9 -12
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +52 -48
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.js +26 -19
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +30 -30
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +76 -53
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +3 -1
- package/lib/cjs/ecschema-editing.d.ts.map +1 -1
- package/lib/cjs/ecschema-editing.js +4 -2
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +9 -9
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
* @module Differencing
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
11
|
-
const SchemaComparer_1 = require("../Validation/SchemaComparer");
|
|
10
|
+
exports.getSchemaDifferences = exports.SchemaOtherTypes = void 0;
|
|
12
11
|
const SchemaDiagnosticVisitor_1 = require("./SchemaDiagnosticVisitor");
|
|
13
|
-
const
|
|
12
|
+
const SchemaComparer_1 = require("../Validation/SchemaComparer");
|
|
14
13
|
/**
|
|
15
14
|
* Defines the SchemaTypes that are not SchemaItems.
|
|
16
15
|
* @alpha
|
|
@@ -27,201 +26,32 @@ var SchemaOtherTypes;
|
|
|
27
26
|
SchemaOtherTypes["EntityClassMixin"] = "EntityClassMixin";
|
|
28
27
|
})(SchemaOtherTypes || (exports.SchemaOtherTypes = SchemaOtherTypes = {}));
|
|
29
28
|
/**
|
|
29
|
+
* Creates a [[SchemaDifferenceResult]] for two given schemas.
|
|
30
|
+
* @param targetSchema The schema the differences gets merged into.
|
|
31
|
+
* @param sourceSchema The schema to get merged in the target.
|
|
32
|
+
* @returns An [[SchemaDifferenceResult]] object.
|
|
30
33
|
* @alpha
|
|
31
34
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
async function fromSchemaChanges(targetSchema, schemaChanges) {
|
|
56
|
-
const visitor = new SchemaDiagnosticVisitor_1.SchemaDiagnosticVisitor();
|
|
57
|
-
for (const diagnostic of schemaChanges.allDiagnostics) {
|
|
58
|
-
visitor.visit(diagnostic);
|
|
59
|
-
}
|
|
60
|
-
const differences = [
|
|
61
|
-
...visitor.schemaDifferences,
|
|
62
|
-
...visitor.schemaItemDifferences,
|
|
63
|
-
...visitor.schemaItemPathDifferences,
|
|
64
|
-
...visitor.customAttributeDifferences,
|
|
65
|
-
];
|
|
66
|
-
return {
|
|
67
|
-
sourceSchemaName: schemaChanges.schema.schemaKey.toString(),
|
|
68
|
-
targetSchemaName: targetSchema.schemaKey.toString(),
|
|
69
|
-
conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,
|
|
70
|
-
differences,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
SchemaDifference.fromSchemaChanges = fromSchemaChanges;
|
|
74
|
-
/**
|
|
75
|
-
* Indicates whether the given difference is type of ConstantDifference.
|
|
76
|
-
* @alpha
|
|
77
|
-
*/
|
|
78
|
-
function isConstantDifference(difference) {
|
|
79
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Constant;
|
|
80
|
-
}
|
|
81
|
-
SchemaDifference.isConstantDifference = isConstantDifference;
|
|
82
|
-
/**
|
|
83
|
-
* Indicates whether the given difference is type of ClassPropertyDifference.
|
|
84
|
-
* @alpha
|
|
85
|
-
*/
|
|
86
|
-
function isClassPropertyDifference(difference) {
|
|
87
|
-
return difference.schemaType === SchemaOtherTypes.Property;
|
|
88
|
-
}
|
|
89
|
-
SchemaDifference.isClassPropertyDifference = isClassPropertyDifference;
|
|
90
|
-
/**
|
|
91
|
-
* Indicates whether the given difference is type of CustomAttributeClassDifference.
|
|
92
|
-
* @alpha
|
|
93
|
-
*/
|
|
94
|
-
function isCustomAttributeClassDifference(difference) {
|
|
95
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.CustomAttributeClass;
|
|
96
|
-
}
|
|
97
|
-
SchemaDifference.isCustomAttributeClassDifference = isCustomAttributeClassDifference;
|
|
98
|
-
/**
|
|
99
|
-
* Indicates whether the given difference is type of CustomAttributeDifference.
|
|
100
|
-
* @alpha
|
|
101
|
-
*/
|
|
102
|
-
function isCustomAttributeDifference(difference) {
|
|
103
|
-
return difference.schemaType === SchemaOtherTypes.CustomAttributeInstance;
|
|
104
|
-
}
|
|
105
|
-
SchemaDifference.isCustomAttributeDifference = isCustomAttributeDifference;
|
|
106
|
-
/**
|
|
107
|
-
* Indicates whether the given difference is type of EntityClassDifference.
|
|
108
|
-
* @alpha
|
|
109
|
-
*/
|
|
110
|
-
function isEntityClassDifference(difference) {
|
|
111
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.EntityClass;
|
|
112
|
-
}
|
|
113
|
-
SchemaDifference.isEntityClassDifference = isEntityClassDifference;
|
|
114
|
-
/**
|
|
115
|
-
* Indicates whether the given difference is type of EntityClassMixinDifference.
|
|
116
|
-
* @alpha
|
|
117
|
-
*/
|
|
118
|
-
function isEntityClassMixinDifference(difference) {
|
|
119
|
-
return difference.schemaType === SchemaOtherTypes.EntityClassMixin;
|
|
120
|
-
}
|
|
121
|
-
SchemaDifference.isEntityClassMixinDifference = isEntityClassMixinDifference;
|
|
122
|
-
/**
|
|
123
|
-
* Indicates whether the given difference is type of EnumerationDifference.
|
|
124
|
-
* @alpha
|
|
125
|
-
*/
|
|
126
|
-
function isEnumerationDifference(difference) {
|
|
127
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Enumeration;
|
|
128
|
-
}
|
|
129
|
-
SchemaDifference.isEnumerationDifference = isEnumerationDifference;
|
|
130
|
-
/**
|
|
131
|
-
* Indicates whether the given difference is type of EnumeratorDifference.
|
|
132
|
-
* @alpha
|
|
133
|
-
*/
|
|
134
|
-
function isEnumeratorDifference(difference) {
|
|
135
|
-
return difference.schemaType === SchemaOtherTypes.Enumerator;
|
|
136
|
-
}
|
|
137
|
-
SchemaDifference.isEnumeratorDifference = isEnumeratorDifference;
|
|
138
|
-
/**
|
|
139
|
-
* Indicates whether the given difference is type of KindOfQuantityDifference.
|
|
140
|
-
* @alpha
|
|
141
|
-
*/
|
|
142
|
-
function isKindOfQuantityDifference(difference) {
|
|
143
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.KindOfQuantity;
|
|
144
|
-
}
|
|
145
|
-
SchemaDifference.isKindOfQuantityDifference = isKindOfQuantityDifference;
|
|
146
|
-
/**
|
|
147
|
-
* Indicates whether the given difference is type of MixinClassDifference.
|
|
148
|
-
* @alpha
|
|
149
|
-
*/
|
|
150
|
-
function isMixinClassDifference(difference) {
|
|
151
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Mixin;
|
|
152
|
-
}
|
|
153
|
-
SchemaDifference.isMixinClassDifference = isMixinClassDifference;
|
|
154
|
-
/**
|
|
155
|
-
* Indicates whether the given difference is type of PhenomenonDifference.
|
|
156
|
-
* @alpha
|
|
157
|
-
*/
|
|
158
|
-
function isPhenomenonDifference(difference) {
|
|
159
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Phenomenon;
|
|
160
|
-
}
|
|
161
|
-
SchemaDifference.isPhenomenonDifference = isPhenomenonDifference;
|
|
162
|
-
/**
|
|
163
|
-
* Indicates whether the given difference is type of PropertyCategoryDifference.
|
|
164
|
-
* @alpha
|
|
165
|
-
*/
|
|
166
|
-
function isPropertyCategoryDifference(difference) {
|
|
167
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.PropertyCategory;
|
|
168
|
-
}
|
|
169
|
-
SchemaDifference.isPropertyCategoryDifference = isPropertyCategoryDifference;
|
|
170
|
-
/**
|
|
171
|
-
* Indicates whether the given difference is type of SchemaDifference.
|
|
172
|
-
* @alpha
|
|
173
|
-
*/
|
|
174
|
-
function isSchemaDifference(difference) {
|
|
175
|
-
return difference.schemaType === SchemaOtherTypes.Schema;
|
|
176
|
-
}
|
|
177
|
-
SchemaDifference.isSchemaDifference = isSchemaDifference;
|
|
178
|
-
/**
|
|
179
|
-
* Indicates whether the given difference is type of SchemaReferenceDifference.
|
|
180
|
-
* @alpha
|
|
181
|
-
*/
|
|
182
|
-
function isSchemaReferenceDifference(difference) {
|
|
183
|
-
return difference.schemaType === SchemaOtherTypes.SchemaReference;
|
|
184
|
-
}
|
|
185
|
-
SchemaDifference.isSchemaReferenceDifference = isSchemaReferenceDifference;
|
|
186
|
-
/**
|
|
187
|
-
* Indicates whether the given difference is type of CustomAttributeDifference.
|
|
188
|
-
* @alpha
|
|
189
|
-
*/
|
|
190
|
-
function isStructClassDifference(difference) {
|
|
191
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.StructClass;
|
|
192
|
-
}
|
|
193
|
-
SchemaDifference.isStructClassDifference = isStructClassDifference;
|
|
194
|
-
/**
|
|
195
|
-
* Indicates whether the given difference is type of UnitSystemDifference.
|
|
196
|
-
* @alpha
|
|
197
|
-
*/
|
|
198
|
-
function isUnitSystemDifference(difference) {
|
|
199
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.UnitSystem;
|
|
200
|
-
}
|
|
201
|
-
SchemaDifference.isUnitSystemDifference = isUnitSystemDifference;
|
|
202
|
-
/**
|
|
203
|
-
* Indicates whether the given difference is type of RelationshipClassDifference.
|
|
204
|
-
* @alpha
|
|
205
|
-
*/
|
|
206
|
-
function isRelationshipClassDifference(difference) {
|
|
207
|
-
return difference.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass;
|
|
208
|
-
}
|
|
209
|
-
SchemaDifference.isRelationshipClassDifference = isRelationshipClassDifference;
|
|
210
|
-
/**
|
|
211
|
-
* Indicates whether the given difference is type of RelationshipConstraintDifference.
|
|
212
|
-
* @alpha
|
|
213
|
-
*/
|
|
214
|
-
function isRelationshipConstraintDifference(difference) {
|
|
215
|
-
return difference.schemaType === SchemaOtherTypes.RelationshipConstraint;
|
|
216
|
-
}
|
|
217
|
-
SchemaDifference.isRelationshipConstraintDifference = isRelationshipConstraintDifference;
|
|
218
|
-
/**
|
|
219
|
-
* Indicates whether the given difference is type of RelationshipConstraintClassDifference.
|
|
220
|
-
* @alpha
|
|
221
|
-
*/
|
|
222
|
-
function isRelationshipConstraintClassDifference(difference) {
|
|
223
|
-
return difference.schemaType === SchemaOtherTypes.RelationshipConstraintClass;
|
|
224
|
-
}
|
|
225
|
-
SchemaDifference.isRelationshipConstraintClassDifference = isRelationshipConstraintClassDifference;
|
|
226
|
-
})(SchemaDifference || (exports.SchemaDifference = SchemaDifference = {}));
|
|
35
|
+
async function getSchemaDifferences(targetSchema, sourceSchema) {
|
|
36
|
+
const changesList = [];
|
|
37
|
+
const schemaComparer = new SchemaComparer_1.SchemaComparer({ report: changesList.push.bind(changesList) });
|
|
38
|
+
await schemaComparer.compareSchemas(sourceSchema, targetSchema);
|
|
39
|
+
const visitor = new SchemaDiagnosticVisitor_1.SchemaDiagnosticVisitor();
|
|
40
|
+
for (const diagnostic of changesList[0].allDiagnostics) {
|
|
41
|
+
visitor.visit(diagnostic);
|
|
42
|
+
}
|
|
43
|
+
const differences = [
|
|
44
|
+
...visitor.schemaDifferences,
|
|
45
|
+
...visitor.schemaItemDifferences,
|
|
46
|
+
...visitor.schemaItemPathDifferences,
|
|
47
|
+
...visitor.customAttributeDifferences,
|
|
48
|
+
];
|
|
49
|
+
return {
|
|
50
|
+
sourceSchemaName: sourceSchema.schemaKey.toString(),
|
|
51
|
+
targetSchemaName: targetSchema.schemaKey.toString(),
|
|
52
|
+
conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,
|
|
53
|
+
differences,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.getSchemaDifferences = getSchemaDifferences;
|
|
227
57
|
//# sourceMappingURL=SchemaDifference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iEAA8D;AAE9D,uEAAoE;AACpE,gEAKkC;AAsBlC;;;GAGG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAA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,KAAK,kCAAc,CAAC,UAAU,CAAC;IAC7D,CAAC;IAFe,uCAAsB,yBAErC,CAAA;IAED;;;OAGG;IACH,SAAgB,6BAA6B,CAAC,UAA+B;QAC3E,OAAO,UAAU,CAAC,UAAU,KAAK,kCAAc,CAAC,iBAAiB,CAAC;IACpE,CAAC;IAFe,8CAA6B,gCAE5C,CAAA;IAED;;;OAGG;IACH,SAAgB,kCAAkC,CAAC,UAA+B;QAChF,OAAO,UAAU,CAAC,UAAU,KAAK,gBAAgB,CAAC,sBAAsB,CAAC;IAC3E,CAAC;IAFe,mDAAkC,qCAEjD,CAAA;IAED;;;OAGG;IACH,SAAgB,uCAAuC,CAAC,UAA+B;QACrF,OAAO,UAAU,CAAC,UAAU,KAAK,gBAAgB,CAAC,2BAA2B,CAAC;IAChF,CAAC;IAFe,wDAAuC,0CAEtD,CAAA;AACH,CAAC,EAnMgB,gBAAgB,gCAAhB,gBAAgB,QAmMhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\r\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\r\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\r\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\r\n} from \"@itwin/ecschema-metadata\";\r\n\r\n/** Utility-Type to remove possible readonly flags on the given type. */\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\r\n * that are not needed for the schema differencing. Also all properties are made mutable\r\n * by removing the readonly flag if present.\r\n */\r\ntype SchemaItemProperties<T extends SchemaItemProps> = {\r\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\r\n};\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @alpha\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines the SchemaTypes that are not SchemaItems.\r\n * @alpha\r\n */\r\nexport enum SchemaOtherTypes {\r\n Schema = \"Schema\",\r\n SchemaReference = \"SchemaReference\",\r\n Property = \"Property\",\r\n Enumerator = \"Enumerator\",\r\n CustomAttributeInstance = \"CustomAttributeInstance\",\r\n RelationshipConstraint = \"RelationshipConstraint\",\r\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\r\n EntityClassMixin = \"EntityClassMixin\",\r\n}\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @alpha\r\n */\r\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport namespace SchemaDifference {\r\n /**\r\n * Creates a [[SchemaDifference]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifference]] object.\r\n * @alpha\r\n */\r\n export async function fromSchemas(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferences> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n return fromSchemaChanges(targetSchema, changesList[0]);\r\n }\r\n\r\n /**\r\n * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.\r\n * @param targetSchema\r\n * @param schemaChanges A changes report of two schemas.\r\n * @returns An [[SchemaDifference]] object.\r\n * @internal\r\n */\r\n export async function fromSchemaChanges(targetSchema: Schema, schemaChanges: SchemaChanges): Promise<SchemaDifferences> {\r\n const visitor = new SchemaDiagnosticVisitor();\r\n for (const diagnostic of schemaChanges.allDiagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n const differences: AnySchemaDifference[] = [\r\n ...visitor.schemaDifferences,\r\n ...visitor.schemaItemDifferences,\r\n ...visitor.schemaItemPathDifferences,\r\n ...visitor.customAttributeDifferences,\r\n ];\r\n\r\n return {\r\n sourceSchemaName: schemaChanges.schema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,\r\n differences,\r\n };\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of ConstantDifference.\r\n * @alpha\r\n */\r\n export function isConstantDifference(difference: AnySchemaDifference): difference is ConstantDifference {\r\n return difference.schemaType === SchemaItemType.Constant;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of ClassPropertyDifference.\r\n * @alpha\r\n */\r\n export function isClassPropertyDifference(difference: AnySchemaDifference): difference is ClassPropertyDifference {\r\n return difference.schemaType === SchemaOtherTypes.Property;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of CustomAttributeClassDifference.\r\n * @alpha\r\n */\r\n export function isCustomAttributeClassDifference(difference: AnySchemaDifference): difference is CustomAttributeClassDifference {\r\n return difference.schemaType === SchemaItemType.CustomAttributeClass;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of CustomAttributeDifference.\r\n * @alpha\r\n */\r\n export function isCustomAttributeDifference(difference: AnySchemaDifference): difference is CustomAttributeDifference {\r\n return difference.schemaType === SchemaOtherTypes.CustomAttributeInstance;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of EntityClassDifference.\r\n * @alpha\r\n */\r\n export function isEntityClassDifference(difference: AnySchemaDifference): difference is EntityClassDifference {\r\n return difference.schemaType === SchemaItemType.EntityClass;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of EntityClassMixinDifference.\r\n * @alpha\r\n */\r\n export function isEntityClassMixinDifference(difference: AnySchemaDifference): difference is EntityClassMixinDifference {\r\n return difference.schemaType === SchemaOtherTypes.EntityClassMixin;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of EnumerationDifference.\r\n * @alpha\r\n */\r\n export function isEnumerationDifference(difference: AnySchemaDifference): difference is EnumerationDifference {\r\n return difference.schemaType === SchemaItemType.Enumeration;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of EnumeratorDifference.\r\n * @alpha\r\n */\r\n export function isEnumeratorDifference(difference: AnySchemaDifference): difference is EnumeratorDifference {\r\n return difference.schemaType === SchemaOtherTypes.Enumerator;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of KindOfQuantityDifference.\r\n * @alpha\r\n */\r\n export function isKindOfQuantityDifference(difference: AnySchemaDifference): difference is KindOfQuantityDifference {\r\n return difference.schemaType === SchemaItemType.KindOfQuantity;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of MixinClassDifference.\r\n * @alpha\r\n */\r\n export function isMixinClassDifference(difference: AnySchemaDifference): difference is MixinClassDifference {\r\n return difference.schemaType === SchemaItemType.Mixin;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of PhenomenonDifference.\r\n * @alpha\r\n */\r\n export function isPhenomenonDifference(difference: AnySchemaDifference): difference is PhenomenonDifference {\r\n return difference.schemaType === SchemaItemType.Phenomenon;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of PropertyCategoryDifference.\r\n * @alpha\r\n */\r\n export function isPropertyCategoryDifference(difference: AnySchemaDifference): difference is PropertyCategoryDifference {\r\n return difference.schemaType === SchemaItemType.PropertyCategory;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of SchemaDifference.\r\n * @alpha\r\n */\r\n export function isSchemaDifference(difference: AnySchemaDifference): difference is SchemaDifference {\r\n return difference.schemaType === SchemaOtherTypes.Schema;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of SchemaReferenceDifference.\r\n * @alpha\r\n */\r\n export function isSchemaReferenceDifference(difference: AnySchemaDifference): difference is SchemaReferenceDifference {\r\n return difference.schemaType === SchemaOtherTypes.SchemaReference;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of CustomAttributeDifference.\r\n * @alpha\r\n */\r\n export function isStructClassDifference(difference: AnySchemaDifference): difference is StructClassDifference {\r\n return difference.schemaType === SchemaItemType.StructClass;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of UnitSystemDifference.\r\n * @alpha\r\n */\r\n export function isUnitSystemDifference(difference: AnySchemaDifference): difference is UnitSystemDifference {\r\n return difference.schemaType === SchemaItemType.UnitSystem;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of RelationshipClassDifference.\r\n * @alpha\r\n */\r\n export function isRelationshipClassDifference(difference: AnySchemaDifference): difference is RelationshipClassDifference {\r\n return difference.schemaType === SchemaItemType.RelationshipClass;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of RelationshipConstraintDifference.\r\n * @alpha\r\n */\r\n export function isRelationshipConstraintDifference(difference: AnySchemaDifference): difference is RelationshipConstraintDifference {\r\n return difference.schemaType === SchemaOtherTypes.RelationshipConstraint;\r\n }\r\n\r\n /**\r\n * Indicates whether the given difference is type of RelationshipConstraintClassDifference.\r\n * @alpha\r\n */\r\n export function isRelationshipConstraintClassDifference(difference: AnySchemaDifference): difference is RelationshipConstraintClassDifference {\r\n return difference.schemaType === SchemaOtherTypes.RelationshipConstraintClass;\r\n }\r\n}\r\n\r\n/**\r\n * Definition of the differences between two Schemas.\r\n * @alpha\r\n */\r\nexport interface SchemaDifferences {\r\n /** Full name of the source schema */\r\n readonly sourceSchemaName: string;\r\n /** Full name of the target schema */\r\n readonly targetSchemaName: string;\r\n\r\n /** List of differences between the compared schemas. */\r\n readonly differences: AnySchemaDifference[];\r\n\r\n /** List of conflicts found while comparing the schemas. */\r\n readonly conflicts?: SchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * Union of all supported schema differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaReferenceDifference |\r\n AnySchemaItemDifference |\r\n AnySchemaItemPathDifference |\r\n CustomAttributeDifference;\r\n\r\n/**\r\n * Differencing entry for changes on a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Schema;\r\n readonly difference: {\r\n label?: string;\r\n description?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Schema References of a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaReferenceDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.SchemaReference;\r\n readonly difference: SchemaReferenceProps;\r\n}\r\n\r\n/**\r\n * Union of all supported schema item differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemDifference =\r\n ClassItemDifference |\r\n ConstantDifference |\r\n EnumerationDifference |\r\n EntityClassMixinDifference |\r\n FormatDifference |\r\n KindOfQuantityDifference |\r\n InvertedUnitDifference |\r\n PhenomenonDifference |\r\n PropertyCategoryDifference |\r\n UnitDifference |\r\n UnitSystemDifference;\r\n\r\n/**\r\n * Union for supported class Schema Items.\r\n * @alpha\r\n */\r\nexport type ClassItemDifference =\r\n EntityClassDifference |\r\n MixinClassDifference |\r\n StructClassDifference |\r\n CustomAttributeClassDifference |\r\n RelationshipClassDifference;\r\n\r\n/**\r\n * Union of all differences that have a path pointing inside a schema item.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemPathDifference =\r\n RelationshipConstraintDifference |\r\n RelationshipConstraintClassDifference |\r\n CustomAttributePropertyDifference |\r\n EnumeratorDifference |\r\n ClassPropertyDifference;\r\n\r\n/**\r\n * Internal base class for all Schema Item differencing entries.\r\n * @alpha\r\n */\r\ninterface SchemaItemDifference<T extends SchemaItemProps> {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly itemName: string;\r\n readonly difference: SchemaItemProperties<T>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Constant Schema Items.\r\n * @alpha\r\n */\r\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\r\n readonly schemaType: SchemaItemType.Constant;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attribute Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\r\n readonly schemaType: SchemaItemType.CustomAttributeClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Entity Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\r\n readonly schemaType: SchemaItemType.EntityClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Enumerator Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\r\n readonly schemaType: SchemaItemType.Enumeration;\r\n}\r\n\r\n/**\r\n * Differencing entry for Kind-Of-Quantities Schema Items.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\r\n readonly schemaType: SchemaItemType.KindOfQuantity;\r\n}\r\n\r\n/**\r\n * Differencing entry for Mixin Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\r\n readonly schemaType: SchemaItemType.Mixin;\r\n}\r\n\r\n/**\r\n * Differencing entry for Phenomenon Schema Items.\r\n * @alpha\r\n */\r\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\r\n readonly schemaType: SchemaItemType.Phenomenon;\r\n}\r\n\r\n/**\r\n * Differencing entry for Property Category Schema Items.\r\n * @alpha\r\n */\r\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\r\n readonly schemaType: SchemaItemType.PropertyCategory;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\r\n readonly schemaType: SchemaItemType.RelationshipClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Struct Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\r\n readonly schemaType: SchemaItemType.StructClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit System Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\r\n readonly schemaType: SchemaItemType.UnitSystem;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\r\n readonly schemaType: SchemaItemType.Unit;\r\n}\r\n\r\n/**\r\n * Differencing entry for Inverted Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\r\n readonly schemaType: SchemaItemType.InvertedUnit;\r\n}\r\n/**\r\n * Differencing entry for Format Schema Items.\r\n * @alpha\r\n */\r\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\r\n readonly schemaType: SchemaItemType.Format;\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Properties.\r\n * @alpha\r\n */\r\nexport interface ClassPropertyDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Property;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyPropertyProps>;\r\n}\r\n\r\n/**\r\n * Union of supported Custom Attribute Differences.\r\n * @alpha\r\n */\r\nexport type CustomAttributeDifference =\r\n CustomAttributeSchemaDifference |\r\n CustomAttributeSchemaItemDifference |\r\n CustomAttributePropertyDifference |\r\n CustomAttributeRelationshipConstraintDifference;\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Schema\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaItemDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"SchemaItem\";\r\n readonly itemName: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Properties.\r\n * @alpha\r\n */\r\nexport interface CustomAttributePropertyDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Property\";\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeRelationshipConstraintDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"RelationshipConstraint\";\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for changed mixins on EntityClasses.\r\n * @alpha\r\n */\r\nexport interface EntityClassMixinDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumeratorDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Enumerator;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\r\n}\r\n\r\n/**\r\n * Differencing entry for constraint classes added to Relationship Constrains.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintClassDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: string[];\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,uEAAoE;AAEpE,iEAA8D;AA4B9D;;;GAGG;AACH,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,uDAAmC,CAAA;IACnC,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,uEAAmD,CAAA;IACnD,qEAAiD,CAAA;IACjD,+EAA2D,CAAA;IAC3D,yDAAqC,CAAA;AACvC,CAAC,EATW,gBAAgB,gCAAhB,gBAAgB,QAS3B;AAiVD;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,YAAoB,EAAE,YAAoB;IACnF,MAAM,WAAW,GAAoB,EAAE,CAAC;IACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1F,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,IAAI,iDAAuB,EAAE,CAAC;IAC9C,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC;QACvD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,WAAW,GAA0B;QACzC,GAAG,OAAO,CAAC,iBAAiB;QAC5B,GAAG,OAAO,CAAC,qBAAqB;QAChC,GAAG,OAAO,CAAC,yBAAyB;QACpC,GAAG,OAAO,CAAC,0BAA0B;KACtC,CAAC;IAEF,OAAO;QACL,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;QACnD,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACvE,WAAW;KACZ,CAAC;AACJ,CAAC;AAvBD,oDAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Differencing\r\n */\r\n\r\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\r\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\r\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\r\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\r\nimport {\r\n AnyEnumerator, AnyPropertyProps, ConstantProps, CustomAttribute,\r\n CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps,\r\n MixinProps, PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, RelationshipConstraintProps,\r\n type Schema, SchemaItemFormatProps, SchemaItemProps, SchemaItemType, SchemaItemUnitProps, SchemaReferenceProps, StructClassProps, UnitSystemProps,\r\n} from \"@itwin/ecschema-metadata\";\r\n\r\n/** Utility-Type to remove possible readonly flags on the given type. */\r\ntype PartialEditable<T> = {\r\n -readonly [P in keyof T]?: T[P];\r\n};\r\n\r\n/**\r\n * Utility-Type to simplify the expected SchemaItem props by omitting the base properties\r\n * that are not needed for the schema differencing. Also all properties are made mutable\r\n * by removing the readonly flag if present.\r\n */\r\ntype SchemaItemProperties<T extends SchemaItemProps> = {\r\n [P in keyof PartialEditable<Omit<T, keyof Omit<SchemaItemProps, \"label\" | \"description\" | \"customAttributes\">>>]: T[P]\r\n};\r\n\r\n/**\r\n * Defines the type of the difference operation.\r\n * @alpha\r\n */\r\nexport type DifferenceType = \"add\" | \"modify\";\r\n\r\n/**\r\n * Defines the SchemaTypes that are not SchemaItems.\r\n * @alpha\r\n */\r\nexport enum SchemaOtherTypes {\r\n Schema = \"Schema\",\r\n SchemaReference = \"SchemaReference\",\r\n Property = \"Property\",\r\n Enumerator = \"Enumerator\",\r\n CustomAttributeInstance = \"CustomAttributeInstance\",\r\n RelationshipConstraint = \"RelationshipConstraint\",\r\n RelationshipConstraintClass = \"RelationshipConstraintClass\",\r\n EntityClassMixin = \"EntityClassMixin\",\r\n}\r\n\r\n/**\r\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\r\n * @alpha\r\n */\r\nexport type SchemaType = SchemaOtherTypes | SchemaItemType;\r\n\r\n/**\r\n * Definition of the difference result between two Schemas.\r\n * @alpha\r\n */\r\nexport interface SchemaDifferenceResult {\r\n /** Full name of the source schema */\r\n readonly sourceSchemaName: string;\r\n /** Full name of the target schema */\r\n readonly targetSchemaName: string;\r\n\r\n /** List of differences between the compared schemas. */\r\n readonly differences: AnySchemaDifference[];\r\n\r\n /** List of conflicts found while comparing the schemas. */\r\n readonly conflicts?: SchemaDifferenceConflict[];\r\n}\r\n\r\n/**\r\n * Union of all supported schema differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaDifference =\r\n SchemaDifference |\r\n SchemaReferenceDifference |\r\n AnySchemaItemDifference |\r\n AnySchemaItemPathDifference |\r\n CustomAttributeDifference;\r\n\r\n/**\r\n * Differencing entry for changes on a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Schema;\r\n readonly difference: {\r\n label?: string;\r\n description?: string;\r\n };\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Schema References of a Schema.\r\n * @alpha\r\n */\r\nexport interface SchemaReferenceDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.SchemaReference;\r\n readonly difference: SchemaReferenceProps;\r\n}\r\n\r\n/**\r\n * Union of all supported schema item differencing types.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemDifference =\r\n ClassItemDifference |\r\n ConstantDifference |\r\n EnumerationDifference |\r\n EntityClassMixinDifference |\r\n FormatDifference |\r\n KindOfQuantityDifference |\r\n InvertedUnitDifference |\r\n PhenomenonDifference |\r\n PropertyCategoryDifference |\r\n UnitDifference |\r\n UnitSystemDifference;\r\n\r\n/**\r\n * Union for supported class Schema Items.\r\n * @alpha\r\n */\r\nexport type ClassItemDifference =\r\n EntityClassDifference |\r\n MixinClassDifference |\r\n StructClassDifference |\r\n CustomAttributeClassDifference |\r\n RelationshipClassDifference;\r\n\r\n/**\r\n * Union of all differences that have a path pointing inside a schema item.\r\n * @alpha\r\n */\r\nexport type AnySchemaItemPathDifference =\r\n RelationshipConstraintDifference |\r\n RelationshipConstraintClassDifference |\r\n CustomAttributePropertyDifference |\r\n EnumeratorDifference |\r\n ClassPropertyDifference;\r\n\r\n/**\r\n * Internal base class for all Schema Item differencing entries.\r\n * @alpha\r\n */\r\ninterface SchemaItemDifference<T extends SchemaItemProps> {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly itemName: string;\r\n readonly difference: SchemaItemProperties<T>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Constant Schema Items.\r\n * @alpha\r\n */\r\nexport interface ConstantDifference extends SchemaItemDifference<ConstantProps> {\r\n readonly schemaType: SchemaItemType.Constant;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attribute Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeClassDifference extends SchemaItemDifference<CustomAttributeClassProps> {\r\n readonly schemaType: SchemaItemType.CustomAttributeClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Entity Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface EntityClassDifference extends SchemaItemDifference<EntityClassProps> {\r\n readonly schemaType: SchemaItemType.EntityClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Enumerator Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumerationDifference extends SchemaItemDifference<EnumerationProps> {\r\n readonly schemaType: SchemaItemType.Enumeration;\r\n}\r\n\r\n/**\r\n * Differencing entry for Kind-Of-Quantities Schema Items.\r\n * @alpha\r\n */\r\nexport interface KindOfQuantityDifference extends SchemaItemDifference<KindOfQuantityProps> {\r\n readonly schemaType: SchemaItemType.KindOfQuantity;\r\n}\r\n\r\n/**\r\n * Differencing entry for Mixin Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface MixinClassDifference extends SchemaItemDifference<MixinProps> {\r\n readonly schemaType: SchemaItemType.Mixin;\r\n}\r\n\r\n/**\r\n * Differencing entry for Phenomenon Schema Items.\r\n * @alpha\r\n */\r\nexport interface PhenomenonDifference extends SchemaItemDifference<PhenomenonProps> {\r\n readonly schemaType: SchemaItemType.Phenomenon;\r\n}\r\n\r\n/**\r\n * Differencing entry for Property Category Schema Items.\r\n * @alpha\r\n */\r\nexport interface PropertyCategoryDifference extends SchemaItemDifference<PropertyCategoryProps> {\r\n readonly schemaType: SchemaItemType.PropertyCategory;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface RelationshipClassDifference extends SchemaItemDifference<RelationshipClassProps> {\r\n readonly schemaType: SchemaItemType.RelationshipClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Struct Class Schema Items.\r\n * @alpha\r\n */\r\nexport interface StructClassDifference extends SchemaItemDifference<StructClassProps> {\r\n readonly schemaType: SchemaItemType.StructClass;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit System Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitSystemDifference extends SchemaItemDifference<UnitSystemProps> {\r\n readonly schemaType: SchemaItemType.UnitSystem;\r\n}\r\n\r\n/**\r\n * Differencing entry for Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface UnitDifference extends SchemaItemDifference<SchemaItemUnitProps> {\r\n readonly schemaType: SchemaItemType.Unit;\r\n}\r\n\r\n/**\r\n * Differencing entry for Inverted Unit Schema Items.\r\n * @alpha\r\n */\r\nexport interface InvertedUnitDifference extends SchemaItemDifference<InvertedUnitProps> {\r\n readonly schemaType: SchemaItemType.InvertedUnit;\r\n}\r\n/**\r\n * Differencing entry for Format Schema Items.\r\n * @alpha\r\n */\r\nexport interface FormatDifference extends SchemaItemDifference<SchemaItemFormatProps> {\r\n readonly schemaType: SchemaItemType.Format;\r\n}\r\n\r\n/**\r\n * Differencing entry for added or changed Properties.\r\n * @alpha\r\n */\r\nexport interface ClassPropertyDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Property;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyPropertyProps>;\r\n}\r\n\r\n/**\r\n * Union of supported Custom Attribute Differences.\r\n * @alpha\r\n */\r\nexport type CustomAttributeDifference =\r\n CustomAttributeSchemaDifference |\r\n CustomAttributeSchemaItemDifference |\r\n CustomAttributePropertyDifference |\r\n CustomAttributeRelationshipConstraintDifference;\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Schema\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Schema Items.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeSchemaItemDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"SchemaItem\";\r\n readonly itemName: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Properties.\r\n * @alpha\r\n */\r\nexport interface CustomAttributePropertyDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"Property\";\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Custom Attributes on Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface CustomAttributeRelationshipConstraintDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.CustomAttributeInstance;\r\n readonly appliedTo: \"RelationshipConstraint\";\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<CustomAttribute>;\r\n}\r\n\r\n/**\r\n * Differencing entry for changed mixins on EntityClasses.\r\n * @alpha\r\n */\r\nexport interface EntityClassMixinDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.EntityClassMixin;\r\n readonly itemName: string;\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Differencing entry for changed Enumerators on Enumerable Schema Items.\r\n * @alpha\r\n */\r\nexport interface EnumeratorDifference {\r\n readonly changeType: \"add\" | \"modify\";\r\n readonly schemaType: SchemaOtherTypes.Enumerator;\r\n readonly itemName: string;\r\n readonly path: string;\r\n readonly difference: PartialEditable<AnyEnumerator>;\r\n}\r\n\r\n/**\r\n * Differencing entry for Relationship Constraints.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintDifference {\r\n readonly changeType: \"modify\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraint;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: PartialEditable<Omit<RelationshipConstraintProps, \"constraintClasses\">>;\r\n}\r\n\r\n/**\r\n * Differencing entry for constraint classes added to Relationship Constrains.\r\n * @alpha\r\n */\r\nexport interface RelationshipConstraintClassDifference {\r\n readonly changeType: \"add\";\r\n readonly schemaType: SchemaOtherTypes.RelationshipConstraintClass;\r\n readonly itemName: string;\r\n readonly path: \"$source\" | \"$target\";\r\n readonly difference: string[];\r\n}\r\n\r\n/**\r\n * Creates a [[SchemaDifferenceResult]] for two given schemas.\r\n * @param targetSchema The schema the differences gets merged into.\r\n * @param sourceSchema The schema to get merged in the target.\r\n * @returns An [[SchemaDifferenceResult]] object.\r\n * @alpha\r\n */\r\nexport async function getSchemaDifferences(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferenceResult> {\r\n const changesList: SchemaChanges[] = [];\r\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\r\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\r\n\r\n const visitor = new SchemaDiagnosticVisitor();\r\n for (const diagnostic of changesList[0].allDiagnostics) {\r\n visitor.visit(diagnostic);\r\n }\r\n\r\n const differences: AnySchemaDifference[] = [\r\n ...visitor.schemaDifferences,\r\n ...visitor.schemaItemDifferences,\r\n ...visitor.schemaItemPathDifferences,\r\n ...visitor.customAttributeDifferences,\r\n ];\r\n\r\n return {\r\n sourceSchemaName: sourceSchema.schemaKey.toString(),\r\n targetSchemaName: targetSchema.schemaKey.toString(),\r\n conflicts: visitor.conflicts.length > 0 ? visitor.conflicts : undefined,\r\n differences,\r\n };\r\n}\r\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Differencing
|
|
3
|
+
*/
|
|
4
|
+
import { type AnySchemaDifference, type AnySchemaItemDifference, type ClassItemDifference, type ClassPropertyDifference, type ConstantDifference, type CustomAttributeClassDifference, type CustomAttributeDifference, type EntityClassDifference, type EntityClassMixinDifference, type EnumerationDifference, type EnumeratorDifference, type KindOfQuantityDifference, type MixinClassDifference, type PhenomenonDifference, type PropertyCategoryDifference, type RelationshipClassDifference, type RelationshipConstraintClassDifference, type RelationshipConstraintDifference, type SchemaDifference, type SchemaReferenceDifference, type StructClassDifference, type UnitSystemDifference } from "./SchemaDifference";
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether the given difference is type of ConstantDifference.
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export declare function isConstantDifference(difference: AnySchemaDifference): difference is ConstantDifference;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the given difference is type of ClassPropertyDifference.
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
export declare function isClassPropertyDifference(difference: AnySchemaDifference): difference is ClassPropertyDifference;
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether the given difference is type of CustomAttributeClassDifference.
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
export declare function isCustomAttributeClassDifference(difference: AnySchemaDifference): difference is CustomAttributeClassDifference;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether the given difference is type of CustomAttributeDifference.
|
|
22
|
+
* @alpha
|
|
23
|
+
*/
|
|
24
|
+
export declare function isCustomAttributeDifference(difference: AnySchemaDifference): difference is CustomAttributeDifference;
|
|
25
|
+
/**
|
|
26
|
+
* Indicates whether the given difference is type of EntityClassDifference.
|
|
27
|
+
* @alpha
|
|
28
|
+
*/
|
|
29
|
+
export declare function isEntityClassDifference(difference: AnySchemaDifference): difference is EntityClassDifference;
|
|
30
|
+
/**
|
|
31
|
+
* Indicates whether the given difference is type of EntityClassMixinDifference.
|
|
32
|
+
* @alpha
|
|
33
|
+
*/
|
|
34
|
+
export declare function isEntityClassMixinDifference(difference: AnySchemaDifference): difference is EntityClassMixinDifference;
|
|
35
|
+
/**
|
|
36
|
+
* Indicates whether the given difference is type of EnumerationDifference.
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
export declare function isEnumerationDifference(difference: AnySchemaDifference): difference is EnumerationDifference;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates whether the given difference is type of EnumeratorDifference.
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export declare function isEnumeratorDifference(difference: AnySchemaDifference): difference is EnumeratorDifference;
|
|
45
|
+
/**
|
|
46
|
+
* Indicates whether the given difference is type of KindOfQuantityDifference.
|
|
47
|
+
* @alpha
|
|
48
|
+
*/
|
|
49
|
+
export declare function isKindOfQuantityDifference(difference: AnySchemaDifference): difference is KindOfQuantityDifference;
|
|
50
|
+
/**
|
|
51
|
+
* Indicates whether the given difference is type of MixinClassDifference.
|
|
52
|
+
* @alpha
|
|
53
|
+
*/
|
|
54
|
+
export declare function isMixinClassDifference(difference: AnySchemaDifference): difference is MixinClassDifference;
|
|
55
|
+
/**
|
|
56
|
+
* Indicates whether the given difference is type of PhenomenonDifference.
|
|
57
|
+
* @alpha
|
|
58
|
+
*/
|
|
59
|
+
export declare function isPhenomenonDifference(difference: AnySchemaDifference): difference is PhenomenonDifference;
|
|
60
|
+
/**
|
|
61
|
+
* Indicates whether the given difference is type of PropertyCategoryDifference.
|
|
62
|
+
* @alpha
|
|
63
|
+
*/
|
|
64
|
+
export declare function isPropertyCategoryDifference(difference: AnySchemaDifference): difference is PropertyCategoryDifference;
|
|
65
|
+
/**
|
|
66
|
+
* Indicates whether the given difference is type of SchemaDifference.
|
|
67
|
+
* @alpha
|
|
68
|
+
*/
|
|
69
|
+
export declare function isSchemaDifference(difference: AnySchemaDifference): difference is SchemaDifference;
|
|
70
|
+
/**
|
|
71
|
+
* Indicates whether the given difference is type of SchemaReferenceDifference.
|
|
72
|
+
* @alpha
|
|
73
|
+
*/
|
|
74
|
+
export declare function isSchemaReferenceDifference(difference: AnySchemaDifference): difference is SchemaReferenceDifference;
|
|
75
|
+
/**
|
|
76
|
+
* Indicates whether the given difference is type of CustomAttributeDifference.
|
|
77
|
+
* @alpha
|
|
78
|
+
*/
|
|
79
|
+
export declare function isStructClassDifference(difference: AnySchemaDifference): difference is StructClassDifference;
|
|
80
|
+
/**
|
|
81
|
+
* Indicates whether the given difference is type of UnitSystemDifference.
|
|
82
|
+
* @alpha
|
|
83
|
+
*/
|
|
84
|
+
export declare function isUnitSystemDifference(difference: AnySchemaDifference): difference is UnitSystemDifference;
|
|
85
|
+
/**
|
|
86
|
+
* Indicates whether the given difference is type of RelationshipClassDifference.
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
export declare function isRelationshipClassDifference(difference: AnySchemaDifference): difference is RelationshipClassDifference;
|
|
90
|
+
/**
|
|
91
|
+
* Indicates whether the given difference is type of RelationshipConstraintDifference.
|
|
92
|
+
* @alpha
|
|
93
|
+
*/
|
|
94
|
+
export declare function isRelationshipConstraintDifference(difference: AnySchemaDifference): difference is RelationshipConstraintDifference;
|
|
95
|
+
/**
|
|
96
|
+
* Indicates whether the given difference is type of RelationshipConstraintClassDifference.
|
|
97
|
+
* @alpha
|
|
98
|
+
*/
|
|
99
|
+
export declare function isRelationshipConstraintClassDifference(difference: AnySchemaDifference): difference is RelationshipConstraintClassDifference;
|
|
100
|
+
/**
|
|
101
|
+
* Indicates whether the given difference is type of AnySchemaItemDifference.
|
|
102
|
+
* @alpha
|
|
103
|
+
*/
|
|
104
|
+
export declare function isSchemaItemDifference(difference: AnySchemaDifference): difference is AnySchemaItemDifference;
|
|
105
|
+
/**
|
|
106
|
+
* Indicates whether the given difference is type of ClassItemDifference.
|
|
107
|
+
* @alpha
|
|
108
|
+
*/
|
|
109
|
+
export declare function isClassDifference(difference: AnySchemaDifference): difference is ClassItemDifference;
|
|
110
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Differencing/Utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,qCAAqC,EAC1C,KAAK,gCAAgC,EACrC,KAAK,gBAAgB,EAErB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,kBAAkB,CAEtG;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,uBAAuB,CAEhH;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,8BAA8B,CAE9H;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,yBAAyB,CAEpH;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAA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C,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,gCAAgC,CAElI;AAED;;;GAGG;AACH,wBAAgB,uCAAuC,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,qCAAqC,CAE5I;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,uBAAuB,CAE7G;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,mBAAmB,GAAG,UAAU,IAAI,mBAAmB,CAMpG"}
|
|
@@ -0,0 +1,185 @@
|
|
|
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 Differencing
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.isClassDifference = exports.isSchemaItemDifference = exports.isRelationshipConstraintClassDifference = exports.isRelationshipConstraintDifference = exports.isRelationshipClassDifference = exports.isUnitSystemDifference = exports.isStructClassDifference = exports.isSchemaReferenceDifference = exports.isSchemaDifference = exports.isPropertyCategoryDifference = exports.isPhenomenonDifference = exports.isMixinClassDifference = exports.isKindOfQuantityDifference = exports.isEnumeratorDifference = exports.isEnumerationDifference = exports.isEntityClassMixinDifference = exports.isEntityClassDifference = exports.isCustomAttributeDifference = exports.isCustomAttributeClassDifference = exports.isClassPropertyDifference = exports.isConstantDifference = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const SchemaDifference_1 = require("./SchemaDifference");
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether the given difference is type of ConstantDifference.
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
function isConstantDifference(difference) {
|
|
18
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Constant;
|
|
19
|
+
}
|
|
20
|
+
exports.isConstantDifference = isConstantDifference;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates whether the given difference is type of ClassPropertyDifference.
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
function isClassPropertyDifference(difference) {
|
|
26
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.Property;
|
|
27
|
+
}
|
|
28
|
+
exports.isClassPropertyDifference = isClassPropertyDifference;
|
|
29
|
+
/**
|
|
30
|
+
* Indicates whether the given difference is type of CustomAttributeClassDifference.
|
|
31
|
+
* @alpha
|
|
32
|
+
*/
|
|
33
|
+
function isCustomAttributeClassDifference(difference) {
|
|
34
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.CustomAttributeClass;
|
|
35
|
+
}
|
|
36
|
+
exports.isCustomAttributeClassDifference = isCustomAttributeClassDifference;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates whether the given difference is type of CustomAttributeDifference.
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
function isCustomAttributeDifference(difference) {
|
|
42
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.CustomAttributeInstance;
|
|
43
|
+
}
|
|
44
|
+
exports.isCustomAttributeDifference = isCustomAttributeDifference;
|
|
45
|
+
/**
|
|
46
|
+
* Indicates whether the given difference is type of EntityClassDifference.
|
|
47
|
+
* @alpha
|
|
48
|
+
*/
|
|
49
|
+
function isEntityClassDifference(difference) {
|
|
50
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.EntityClass;
|
|
51
|
+
}
|
|
52
|
+
exports.isEntityClassDifference = isEntityClassDifference;
|
|
53
|
+
/**
|
|
54
|
+
* Indicates whether the given difference is type of EntityClassMixinDifference.
|
|
55
|
+
* @alpha
|
|
56
|
+
*/
|
|
57
|
+
function isEntityClassMixinDifference(difference) {
|
|
58
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.EntityClassMixin;
|
|
59
|
+
}
|
|
60
|
+
exports.isEntityClassMixinDifference = isEntityClassMixinDifference;
|
|
61
|
+
/**
|
|
62
|
+
* Indicates whether the given difference is type of EnumerationDifference.
|
|
63
|
+
* @alpha
|
|
64
|
+
*/
|
|
65
|
+
function isEnumerationDifference(difference) {
|
|
66
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Enumeration;
|
|
67
|
+
}
|
|
68
|
+
exports.isEnumerationDifference = isEnumerationDifference;
|
|
69
|
+
/**
|
|
70
|
+
* Indicates whether the given difference is type of EnumeratorDifference.
|
|
71
|
+
* @alpha
|
|
72
|
+
*/
|
|
73
|
+
function isEnumeratorDifference(difference) {
|
|
74
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.Enumerator;
|
|
75
|
+
}
|
|
76
|
+
exports.isEnumeratorDifference = isEnumeratorDifference;
|
|
77
|
+
/**
|
|
78
|
+
* Indicates whether the given difference is type of KindOfQuantityDifference.
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
function isKindOfQuantityDifference(difference) {
|
|
82
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.KindOfQuantity;
|
|
83
|
+
}
|
|
84
|
+
exports.isKindOfQuantityDifference = isKindOfQuantityDifference;
|
|
85
|
+
/**
|
|
86
|
+
* Indicates whether the given difference is type of MixinClassDifference.
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
function isMixinClassDifference(difference) {
|
|
90
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Mixin;
|
|
91
|
+
}
|
|
92
|
+
exports.isMixinClassDifference = isMixinClassDifference;
|
|
93
|
+
/**
|
|
94
|
+
* Indicates whether the given difference is type of PhenomenonDifference.
|
|
95
|
+
* @alpha
|
|
96
|
+
*/
|
|
97
|
+
function isPhenomenonDifference(difference) {
|
|
98
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.Phenomenon;
|
|
99
|
+
}
|
|
100
|
+
exports.isPhenomenonDifference = isPhenomenonDifference;
|
|
101
|
+
/**
|
|
102
|
+
* Indicates whether the given difference is type of PropertyCategoryDifference.
|
|
103
|
+
* @alpha
|
|
104
|
+
*/
|
|
105
|
+
function isPropertyCategoryDifference(difference) {
|
|
106
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.PropertyCategory;
|
|
107
|
+
}
|
|
108
|
+
exports.isPropertyCategoryDifference = isPropertyCategoryDifference;
|
|
109
|
+
/**
|
|
110
|
+
* Indicates whether the given difference is type of SchemaDifference.
|
|
111
|
+
* @alpha
|
|
112
|
+
*/
|
|
113
|
+
function isSchemaDifference(difference) {
|
|
114
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.Schema;
|
|
115
|
+
}
|
|
116
|
+
exports.isSchemaDifference = isSchemaDifference;
|
|
117
|
+
/**
|
|
118
|
+
* Indicates whether the given difference is type of SchemaReferenceDifference.
|
|
119
|
+
* @alpha
|
|
120
|
+
*/
|
|
121
|
+
function isSchemaReferenceDifference(difference) {
|
|
122
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.SchemaReference;
|
|
123
|
+
}
|
|
124
|
+
exports.isSchemaReferenceDifference = isSchemaReferenceDifference;
|
|
125
|
+
/**
|
|
126
|
+
* Indicates whether the given difference is type of CustomAttributeDifference.
|
|
127
|
+
* @alpha
|
|
128
|
+
*/
|
|
129
|
+
function isStructClassDifference(difference) {
|
|
130
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.StructClass;
|
|
131
|
+
}
|
|
132
|
+
exports.isStructClassDifference = isStructClassDifference;
|
|
133
|
+
/**
|
|
134
|
+
* Indicates whether the given difference is type of UnitSystemDifference.
|
|
135
|
+
* @alpha
|
|
136
|
+
*/
|
|
137
|
+
function isUnitSystemDifference(difference) {
|
|
138
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.UnitSystem;
|
|
139
|
+
}
|
|
140
|
+
exports.isUnitSystemDifference = isUnitSystemDifference;
|
|
141
|
+
/**
|
|
142
|
+
* Indicates whether the given difference is type of RelationshipClassDifference.
|
|
143
|
+
* @alpha
|
|
144
|
+
*/
|
|
145
|
+
function isRelationshipClassDifference(difference) {
|
|
146
|
+
return difference.schemaType === ecschema_metadata_1.SchemaItemType.RelationshipClass;
|
|
147
|
+
}
|
|
148
|
+
exports.isRelationshipClassDifference = isRelationshipClassDifference;
|
|
149
|
+
/**
|
|
150
|
+
* Indicates whether the given difference is type of RelationshipConstraintDifference.
|
|
151
|
+
* @alpha
|
|
152
|
+
*/
|
|
153
|
+
function isRelationshipConstraintDifference(difference) {
|
|
154
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.RelationshipConstraint;
|
|
155
|
+
}
|
|
156
|
+
exports.isRelationshipConstraintDifference = isRelationshipConstraintDifference;
|
|
157
|
+
/**
|
|
158
|
+
* Indicates whether the given difference is type of RelationshipConstraintClassDifference.
|
|
159
|
+
* @alpha
|
|
160
|
+
*/
|
|
161
|
+
function isRelationshipConstraintClassDifference(difference) {
|
|
162
|
+
return difference.schemaType === SchemaDifference_1.SchemaOtherTypes.RelationshipConstraintClass;
|
|
163
|
+
}
|
|
164
|
+
exports.isRelationshipConstraintClassDifference = isRelationshipConstraintClassDifference;
|
|
165
|
+
/**
|
|
166
|
+
* Indicates whether the given difference is type of AnySchemaItemDifference.
|
|
167
|
+
* @alpha
|
|
168
|
+
*/
|
|
169
|
+
function isSchemaItemDifference(difference) {
|
|
170
|
+
return difference.schemaType in ecschema_metadata_1.SchemaItemType;
|
|
171
|
+
}
|
|
172
|
+
exports.isSchemaItemDifference = isSchemaItemDifference;
|
|
173
|
+
/**
|
|
174
|
+
* Indicates whether the given difference is type of ClassItemDifference.
|
|
175
|
+
* @alpha
|
|
176
|
+
*/
|
|
177
|
+
function isClassDifference(difference) {
|
|
178
|
+
return isStructClassDifference(difference)
|
|
179
|
+
|| isCustomAttributeClassDifference(difference)
|
|
180
|
+
|| isEntityClassDifference(difference)
|
|
181
|
+
|| isMixinClassDifference(difference)
|
|
182
|
+
|| isRelationshipClassDifference(difference);
|
|
183
|
+
}
|
|
184
|
+
exports.isClassDifference = isClassDifference;
|
|
185
|
+
//# sourceMappingURL=Utils.js.map
|