@itwin/ecschema-editing 4.0.0-dev.7 → 4.0.0-dev.70
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 +11 -1
- package/lib/cjs/Editing/Constants.d.ts +20 -20
- package/lib/cjs/Editing/Constants.js +60 -60
- package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
- package/lib/cjs/Editing/CustomAttributes.js +59 -59
- package/lib/cjs/Editing/ECClasses.d.ts +54 -54
- package/lib/cjs/Editing/ECClasses.js +269 -269
- package/lib/cjs/Editing/Editor.d.ts +112 -112
- package/lib/cjs/Editing/Editor.js +166 -166
- package/lib/cjs/Editing/Entities.d.ts +25 -25
- package/lib/cjs/Editing/Entities.js +116 -116
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +21 -21
- package/lib/cjs/Editing/Enumerations.js +66 -66
- package/lib/cjs/Editing/Formats.d.ts +21 -21
- package/lib/cjs/Editing/Formats.js +61 -61
- package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
- package/lib/cjs/Editing/InvertedUnits.js +82 -82
- package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
- package/lib/cjs/Editing/KindOfQuantities.js +78 -78
- package/lib/cjs/Editing/Mixins.d.ts +22 -22
- package/lib/cjs/Editing/Mixins.js +84 -84
- package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
- package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
- package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
- package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
- package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
- package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
- package/lib/cjs/Editing/Phenomena.d.ts +15 -15
- package/lib/cjs/Editing/Phenomena.js +44 -44
- package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
- package/lib/cjs/Editing/PropertyCategories.js +51 -51
- package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
- package/lib/cjs/Editing/RelationshipClasses.js +68 -68
- package/lib/cjs/Editing/Structs.d.ts +19 -19
- package/lib/cjs/Editing/Structs.js +57 -57
- package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
- package/lib/cjs/Editing/UnitSystems.js +41 -41
- package/lib/cjs/Editing/Units.d.ts +15 -15
- package/lib/cjs/Editing/Units.js +58 -58
- package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
- package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +310 -310
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
- package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
- package/lib/cjs/Validation/ECRules.d.ts +443 -448
- package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
- package/lib/cjs/Validation/ECRules.js +579 -593
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
- package/lib/cjs/Validation/Rules.d.ts +64 -64
- package/lib/cjs/Validation/Rules.d.ts.map +1 -1
- package/lib/cjs/Validation/Rules.js +9 -9
- package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
- package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
- package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
- package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
- package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
- package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
- package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
- package/lib/cjs/Validation/SchemaComparer.js +666 -666
- package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
- package/lib/cjs/Validation/SchemaValidater.js +61 -61
- package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
- package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
- package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
- package/lib/cjs/Validation/SchemaWalker.js +51 -51
- package/lib/cjs/ecschema-editing.d.ts +33 -33
- package/lib/cjs/ecschema-editing.js +58 -54
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +14 -14
|
@@ -1,594 +1,580 @@
|
|
|
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 Validation
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.validateCustomAttributeInstance = exports.mixinAppliedToClassMustDeriveFromConstraint = exports.enumerationTypeUnsupported = exports.abstractConstraintMustExistWithMultipleConstraints = exports.atLeastOneConstraintClassDefined = exports.constraintClassesDeriveFromAbstractContraint = exports.derivedConstraintsMustNarrowBaseConstraints = exports.abstractConstraintMustNarrowBaseConstraints = exports.validateNavigationProperty = exports.incompatibleUnitPropertyOverride = exports.incompatibleTypePropertyOverride = exports.incompatibleValueTypePropertyOverride = exports.
|
|
11
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
-
const Diagnostic_1 = require("./Diagnostic");
|
|
13
|
-
const ruleSetName = "ECObjects";
|
|
14
|
-
function getCode(code) {
|
|
15
|
-
return `${ruleSetName}-${code}`;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The unique diagnostic codes for ECObjects rules.
|
|
19
|
-
*
|
|
20
|
-
* To provide meaning to code values, with anticipation
|
|
21
|
-
* of future rules for all current EC Types, the following
|
|
22
|
-
* value ranges should be used:
|
|
23
|
-
*
|
|
24
|
-
* - Schema: 000-099
|
|
25
|
-
* - Class: 100-199
|
|
26
|
-
* - Constant: 200-299
|
|
27
|
-
* - CustomAttribute 300-399
|
|
28
|
-
* - CustomAttributeClass: 400-499
|
|
29
|
-
* - CustomAttributeContainer: 500-599
|
|
30
|
-
* - EntityClass: 600-699
|
|
31
|
-
* - Enumeration: 700-799
|
|
32
|
-
* - Format: 800-899
|
|
33
|
-
* - InvertedUnit: 900-999
|
|
34
|
-
* - KindOfQuantity: 1000-1099
|
|
35
|
-
* - Mixin: 1100-1199
|
|
36
|
-
* - Phenomenon: 1200-1299
|
|
37
|
-
* - Property: 1300-1399
|
|
38
|
-
* - PropertyCategory: 1400-1499
|
|
39
|
-
* - RelationshipClass: 1500-1599
|
|
40
|
-
* - RelationshipConstraint: 1600-1699
|
|
41
|
-
* - StructClass: 1700-1799
|
|
42
|
-
* - Unit: 1800-1899
|
|
43
|
-
* - UnitSystem: 1900-1999
|
|
44
|
-
* @beta
|
|
45
|
-
*/
|
|
46
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
47
|
-
exports.DiagnosticCodes = {
|
|
48
|
-
// Class Rule Codes (100-199)
|
|
49
|
-
BaseClassIsSealed: getCode(100),
|
|
50
|
-
BaseClassOfDifferentType: getCode(101),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
],
|
|
138
|
-
propertyRules: [
|
|
139
|
-
incompatibleValueTypePropertyOverride,
|
|
140
|
-
incompatibleTypePropertyOverride,
|
|
141
|
-
incompatibleUnitPropertyOverride,
|
|
142
|
-
validateNavigationProperty,
|
|
143
|
-
],
|
|
144
|
-
relationshipRules: [
|
|
145
|
-
abstractConstraintMustNarrowBaseConstraints,
|
|
146
|
-
constraintClassesDeriveFromAbstractContraint,
|
|
147
|
-
derivedConstraintsMustNarrowBaseConstraints,
|
|
148
|
-
],
|
|
149
|
-
relationshipConstraintRules: [
|
|
150
|
-
atLeastOneConstraintClassDefined,
|
|
151
|
-
abstractConstraintMustExistWithMultipleConstraints,
|
|
152
|
-
],
|
|
153
|
-
enumerationRules: [
|
|
154
|
-
enumerationTypeUnsupported,
|
|
155
|
-
],
|
|
156
|
-
entityClassRules: [
|
|
157
|
-
mixinAppliedToClassMustDeriveFromConstraint,
|
|
158
|
-
],
|
|
159
|
-
customAttributeInstanceRules: [
|
|
160
|
-
validateCustomAttributeInstance,
|
|
161
|
-
],
|
|
162
|
-
};
|
|
163
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
164
|
-
/**
|
|
165
|
-
* Validates schema references against multiple EC rules.
|
|
166
|
-
* @param schema The schema to validate.
|
|
167
|
-
* @internal
|
|
168
|
-
*/
|
|
169
|
-
async function* validateSchemaReferences(schema) {
|
|
170
|
-
yield* validateSchemaReferencesSync(schema);
|
|
171
|
-
}
|
|
172
|
-
exports.validateSchemaReferences = validateSchemaReferences;
|
|
173
|
-
/**
|
|
174
|
-
* Validates schema references against multiple EC rules.
|
|
175
|
-
* @param schema The schema to validate.
|
|
176
|
-
* @internal
|
|
177
|
-
*/
|
|
178
|
-
function* validateSchemaReferencesSync(schema) {
|
|
179
|
-
const aliases = new Map();
|
|
180
|
-
for (const schemaRef of schema.references) {
|
|
181
|
-
if (schemaRef.customAttributes && schemaRef.customAttributes.has("CoreCustomAttributes.SupplementalSchema"))
|
|
182
|
-
yield new exports.Diagnostics.SupplementalSchemasCannotBeReferenced(schema, [schema.name, schemaRef.name]);
|
|
183
|
-
if (schema.schemaKey.matches(schemaRef.schemaKey))
|
|
184
|
-
yield new exports.Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, `${schema.name} --> ${schemaRef.name}`]);
|
|
185
|
-
if (aliases.has(schemaRef.alias)) {
|
|
186
|
-
const currentRef = aliases.get(schemaRef.alias);
|
|
187
|
-
yield new exports.Diagnostics.SchemaRefAliasMustBeUnique(schema, [schema.name, schemaRef.alias, currentRef.name, schemaRef.name]);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
aliases.set(schemaRef.alias, schemaRef);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const graph = new ecschema_metadata_1.SchemaGraph(schema);
|
|
194
|
-
const cycles = graph.detectCycles();
|
|
195
|
-
if (cycles) {
|
|
196
|
-
const result = cycles.map((cycle) => `${cycle.schema.name} --> ${cycle.refSchema.name}`).join(", ");
|
|
197
|
-
yield new exports.Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, result]);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
exports.validateSchemaReferencesSync = validateSchemaReferencesSync;
|
|
201
|
-
/**
|
|
202
|
-
* EC Rule: Sealed classes cannot be a base class.
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
205
|
-
async function* baseClassIsSealed(ecClass) {
|
|
206
|
-
if (!ecClass.baseClass)
|
|
207
|
-
return;
|
|
208
|
-
const baseClass = await ecClass.baseClass;
|
|
209
|
-
// return if rule passed
|
|
210
|
-
if (baseClass.modifier !== ecschema_metadata_1.ECClassModifier.Sealed)
|
|
211
|
-
return;
|
|
212
|
-
yield new exports.Diagnostics.BaseClassIsSealed(ecClass, [ecClass.fullName, baseClass.fullName]);
|
|
213
|
-
}
|
|
214
|
-
exports.baseClassIsSealed = baseClassIsSealed;
|
|
215
|
-
/**
|
|
216
|
-
* EC Rule: Base and child class must be of the same type (i.e. Entity, Mixin, Relationship, etc.)
|
|
217
|
-
* @internal
|
|
218
|
-
*/
|
|
219
|
-
async function* baseClassIsOfDifferentType(ecClass) {
|
|
220
|
-
if (!ecClass.baseClass)
|
|
221
|
-
return;
|
|
222
|
-
const baseClass = await ecClass.baseClass;
|
|
223
|
-
// return if rule passed
|
|
224
|
-
if (baseClass.schemaItemType === ecClass.schemaItemType)
|
|
225
|
-
return;
|
|
226
|
-
const itemType = (0, ecschema_metadata_1.schemaItemTypeToString)(baseClass.schemaItemType);
|
|
227
|
-
yield new exports.Diagnostics.BaseClassIsOfDifferentType(ecClass, [ecClass.fullName, baseClass.fullName, itemType]);
|
|
228
|
-
}
|
|
229
|
-
exports.baseClassIsOfDifferentType = baseClassIsOfDifferentType;
|
|
230
|
-
/**
|
|
231
|
-
* EC Rule:
|
|
232
|
-
* @internal
|
|
233
|
-
|
|
234
|
-
async function*
|
|
235
|
-
if (
|
|
236
|
-
return;
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (!
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
*
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
*
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
if (
|
|
459
|
-
return;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
*
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
*
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (
|
|
529
|
-
return;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
async function getAbstractConstraint(constraint) {
|
|
585
|
-
const abstractConstraint = await constraint.abstractConstraint;
|
|
586
|
-
if (abstractConstraint)
|
|
587
|
-
return abstractConstraint;
|
|
588
|
-
const baseRelationship = await constraint.relationshipClass.baseClass;
|
|
589
|
-
if (!baseRelationship)
|
|
590
|
-
return;
|
|
591
|
-
const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;
|
|
592
|
-
return getAbstractConstraint(baseConstraint);
|
|
593
|
-
}
|
|
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 Validation
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.validateCustomAttributeInstance = exports.mixinAppliedToClassMustDeriveFromConstraint = exports.enumerationTypeUnsupported = exports.abstractConstraintMustExistWithMultipleConstraints = exports.atLeastOneConstraintClassDefined = exports.constraintClassesDeriveFromAbstractContraint = exports.derivedConstraintsMustNarrowBaseConstraints = exports.abstractConstraintMustNarrowBaseConstraints = exports.validateNavigationProperty = exports.incompatibleUnitPropertyOverride = exports.incompatibleTypePropertyOverride = exports.incompatibleValueTypePropertyOverride = exports.baseClassIsOfDifferentType = exports.baseClassIsSealed = exports.validateSchemaReferencesSync = exports.validateSchemaReferences = exports.ECRuleSet = exports.Diagnostics = exports.DiagnosticCodes = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const Diagnostic_1 = require("./Diagnostic");
|
|
13
|
+
const ruleSetName = "ECObjects";
|
|
14
|
+
function getCode(code) {
|
|
15
|
+
return `${ruleSetName}-${code}`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The unique diagnostic codes for ECObjects rules.
|
|
19
|
+
*
|
|
20
|
+
* To provide meaning to code values, with anticipation
|
|
21
|
+
* of future rules for all current EC Types, the following
|
|
22
|
+
* value ranges should be used:
|
|
23
|
+
*
|
|
24
|
+
* - Schema: 000-099
|
|
25
|
+
* - Class: 100-199
|
|
26
|
+
* - Constant: 200-299
|
|
27
|
+
* - CustomAttribute 300-399
|
|
28
|
+
* - CustomAttributeClass: 400-499
|
|
29
|
+
* - CustomAttributeContainer: 500-599
|
|
30
|
+
* - EntityClass: 600-699
|
|
31
|
+
* - Enumeration: 700-799
|
|
32
|
+
* - Format: 800-899
|
|
33
|
+
* - InvertedUnit: 900-999
|
|
34
|
+
* - KindOfQuantity: 1000-1099
|
|
35
|
+
* - Mixin: 1100-1199
|
|
36
|
+
* - Phenomenon: 1200-1299
|
|
37
|
+
* - Property: 1300-1399
|
|
38
|
+
* - PropertyCategory: 1400-1499
|
|
39
|
+
* - RelationshipClass: 1500-1599
|
|
40
|
+
* - RelationshipConstraint: 1600-1699
|
|
41
|
+
* - StructClass: 1700-1799
|
|
42
|
+
* - Unit: 1800-1899
|
|
43
|
+
* - UnitSystem: 1900-1999
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
47
|
+
exports.DiagnosticCodes = {
|
|
48
|
+
// Class Rule Codes (100-199)
|
|
49
|
+
BaseClassIsSealed: getCode(100),
|
|
50
|
+
BaseClassOfDifferentType: getCode(101),
|
|
51
|
+
// EC-102 has been deprecated. Leaving the code here to prevent re-use.
|
|
52
|
+
AbstractClassWithNonAbstractBase: getCode(102),
|
|
53
|
+
// CA Container Rule Codes (500-599)
|
|
54
|
+
CustomAttributeNotOfConcreteClass: getCode(500),
|
|
55
|
+
CustomAttributeSchemaMustBeReferenced: getCode(501),
|
|
56
|
+
CustomAttributeClassNotFound: getCode(502),
|
|
57
|
+
// Enumeration Rule Codes (700-799)
|
|
58
|
+
EnumerationTypeUnsupported: getCode(700),
|
|
59
|
+
// Mixin Rule Codes (1100-1199)
|
|
60
|
+
MixinAppliedToClassMustDeriveFromConstraint: getCode(1100),
|
|
61
|
+
// Property Rule Codes (1300-1399)
|
|
62
|
+
IncompatibleValueTypePropertyOverride: getCode(1300),
|
|
63
|
+
IncompatibleTypePropertyOverride: getCode(1301),
|
|
64
|
+
IncompatibleUnitPropertyOverride: getCode(1302),
|
|
65
|
+
// Relationship Rule Codes (1500-1599)
|
|
66
|
+
AbstractConstraintMustNarrowBaseConstraints: getCode(1500),
|
|
67
|
+
DerivedConstraintsMustNarrowBaseConstraints: getCode(1501),
|
|
68
|
+
ConstraintClassesDeriveFromAbstractContraint: getCode(1502),
|
|
69
|
+
// Relationship Constraint Rule Codes (1600-1699)
|
|
70
|
+
AtLeastOneConstraintClassDefined: getCode(1600),
|
|
71
|
+
AbstractConstraintMustExistWithMultipleConstraints: getCode(1601),
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The list of [[IDiagnostic]] implementation classes used by the EC rule implementations.
|
|
75
|
+
* @beta
|
|
76
|
+
*/
|
|
77
|
+
exports.Diagnostics = {
|
|
78
|
+
/** EC-001: Required message parameters: schema name, referenced schema name */
|
|
79
|
+
SupplementalSchemasCannotBeReferenced: (0, Diagnostic_1.createSchemaDiagnosticClass)(getCode(1), "Referenced schema '{1}' of schema '{0}' is a supplemental schema. Supplemental schemas are not allowed to be referenced."),
|
|
80
|
+
/** EC-002: Required message parameters: schema name, reference schema alias, first schema reference name, second schema reference name. */
|
|
81
|
+
SchemaRefAliasMustBeUnique: (0, Diagnostic_1.createSchemaDiagnosticClass)(getCode(2), "Schema '{0}' has multiple schema references ({2}, {3}) with the same alias '{1}', which is not allowed."),
|
|
82
|
+
/** EC-003: Required message parameters: schema name, cycle text */
|
|
83
|
+
ReferenceCyclesNotAllowed: (0, Diagnostic_1.createSchemaDiagnosticClass)(getCode(3), "Schema '{0}' has reference cycles: {1}"),
|
|
84
|
+
/** EC-100: Required message parameters: childClass.FullName, baseClass.FullName */
|
|
85
|
+
BaseClassIsSealed: (0, Diagnostic_1.createClassDiagnosticClass)(exports.DiagnosticCodes.BaseClassIsSealed, "Class '{0}' cannot derive from sealed base class '{1}'."),
|
|
86
|
+
/** EC-101: Required message parameters: childClass.FullName, baseClass.FullName, baseClass.schemaItemType */
|
|
87
|
+
BaseClassIsOfDifferentType: (0, Diagnostic_1.createClassDiagnosticClass)(exports.DiagnosticCodes.BaseClassOfDifferentType, "Class '{0}' cannot derive from base class '{1}' of type '{2}'."),
|
|
88
|
+
/** **DEPRECATED** EC-102: Required message parameters: childClass.FullName, baseClass.FullName */
|
|
89
|
+
AbstractClassWithNonAbstractBase: (0, Diagnostic_1.createClassDiagnosticClass)(exports.DiagnosticCodes.AbstractClassWithNonAbstractBase, "Abstract Class '{0}' cannot derive from base class '{1}' because it is not an abstract class."),
|
|
90
|
+
/** EC-500: Required message parameters: CustomAttribute container name and CustomAttributeClass name. */
|
|
91
|
+
CustomAttributeNotOfConcreteClass: (0, Diagnostic_1.createCustomAttributeContainerDiagnosticClass)(exports.DiagnosticCodes.CustomAttributeNotOfConcreteClass, "The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' which is not a concrete class."),
|
|
92
|
+
/** EC-501: Required message parameters: CustomAttribute container name, CustomAttributeClass name, CustomAttributeClass Schema name. */
|
|
93
|
+
CustomAttributeSchemaMustBeReferenced: (0, Diagnostic_1.createCustomAttributeContainerDiagnosticClass)(exports.DiagnosticCodes.CustomAttributeSchemaMustBeReferenced, "The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' whose schema is not referenced by the container's Schema."),
|
|
94
|
+
/** EC-502: Required message parameters: CustomAttribute container name and CustomAttributeClass name. */
|
|
95
|
+
CustomAttributeClassNotFound: (0, Diagnostic_1.createCustomAttributeContainerDiagnosticClass)(exports.DiagnosticCodes.CustomAttributeClassNotFound, "The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' which cannot be found."),
|
|
96
|
+
/** EC-700: Required message parameters: Enumeration name */
|
|
97
|
+
EnumerationTypeUnsupported: (0, Diagnostic_1.createSchemaItemDiagnosticClass)(exports.DiagnosticCodes.EnumerationTypeUnsupported, "Enumeration '{0}' has invalid primitive type."),
|
|
98
|
+
/** EC-1100: Required message parameters: mixin class fullName, class fullName, applies to constraint class fullName */
|
|
99
|
+
MixinAppliedToClassMustDeriveFromConstraint: (0, Diagnostic_1.createSchemaItemDiagnosticClass)(exports.DiagnosticCodes.MixinAppliedToClassMustDeriveFromConstraint, "Mixin '{0}' cannot be applied to the class '{1}' because it does not satisfy the applies to constraint '{2}'."),
|
|
100
|
+
/** EC-1300: Required message parameters: childClass.FullName, property name, baseClass.FullName, base value type, child value type */
|
|
101
|
+
IncompatibleValueTypePropertyOverride: (0, Diagnostic_1.createPropertyDiagnosticClass)(exports.DiagnosticCodes.IncompatibleValueTypePropertyOverride, "The ECProperty '{0}.{1}' has a base property '{2}.{1}' with a value type of {3} which is incompatible with the value type of {4}."),
|
|
102
|
+
/** EC-1301: Required message parameters: childClass.FullName, property name, baseClass.FullName, base property type, child property type */
|
|
103
|
+
IncompatibleTypePropertyOverride: (0, Diagnostic_1.createPropertyDiagnosticClass)(exports.DiagnosticCodes.IncompatibleTypePropertyOverride, "The ECProperty '{0}.{1}' has a base property '{2}.{1}' with a type of {3} which is incompatible with the type of {4}."),
|
|
104
|
+
/** EC-1302: Required message parameters: childClass.Name, property name, baseClass.Name, baseClass Koq name, baseClass Koq persistence unit name, child class Koq persistence unit name, child class Koq name */
|
|
105
|
+
IncompatibleUnitPropertyOverride: (0, Diagnostic_1.createPropertyDiagnosticClass)(exports.DiagnosticCodes.IncompatibleUnitPropertyOverride, "The ECProperty '{0}.{1}' has a base property '{2}.{1}' with KindOfQuantity '{3}' with persistence unit '{4}' which is not the same as the persistence unit '{5}' of the provided KindOfQuantity '{6}'."),
|
|
106
|
+
/** EC-1303: Required message parameters: property.fullName, navigation relationship.fullName */
|
|
107
|
+
NavigationRelationshipMustBeRoot: (0, Diagnostic_1.createPropertyDiagnosticClass)(getCode(1303), "The referenced relationship '{1}', used in NavigationProperty '{0}' is not the root relationship."),
|
|
108
|
+
/** EC-1304: Required message parameters: property.fullName, navigation relationship.fullName */
|
|
109
|
+
NavigationTargetMustHaveSingularMultiplicity: (0, Diagnostic_1.createPropertyDiagnosticClass)(getCode(1304), "NavigationProperty '{0}' uses the relationship '{1}' that cannot be traversed in the '{2}' direction due to a max multiplicity greater than 1."),
|
|
110
|
+
/** EC-1305: Required message parameters: property.fullName, navigation relationship.fullName */
|
|
111
|
+
NavigationRelationshipAbstractConstraintEntityOrMixin: (0, Diagnostic_1.createPropertyDiagnosticClass)(getCode(1305), "The NavigationProperty '{0}', using the relationship '{1}', points to a RelationshipClass, which is not allowed. NavigationProperties must point to an EntityClass or Mixin."),
|
|
112
|
+
/** EC-1306: Required message parameters: class name, property name, navigation relationship.fullName */
|
|
113
|
+
NavigationClassMustBeAConstraintClassOfRelationship: (0, Diagnostic_1.createPropertyDiagnosticClass)(getCode(1306), "The class '{0}' of NavigationProperty '{1}' is not supported by the {3} constraint of the referenced relationship '{2}'."),
|
|
114
|
+
/** EC-1500: Required message parameters: abstract constraint class name, relationship end (source/target), relationship name, base relationship name */
|
|
115
|
+
AbstractConstraintMustNarrowBaseConstraints: (0, Diagnostic_1.createSchemaItemDiagnosticClass)(exports.DiagnosticCodes.AbstractConstraintMustNarrowBaseConstraints, "The abstract constraint class '{0}' on the {1}-Constraint of '{2}' is not supported by the base class constraint in '{3}'."),
|
|
116
|
+
/** EC-1501: Required message parameters: constraint class name, relationship end (source/target), relationship name, base relationship name */
|
|
117
|
+
DerivedConstraintsMustNarrowBaseConstraints: (0, Diagnostic_1.createSchemaItemDiagnosticClass)(exports.DiagnosticCodes.DerivedConstraintsMustNarrowBaseConstraints, "The constraint class '{0}' on the {1}-Constraint of '{2}' is not supported by the base class constraint in '{3}'."),
|
|
118
|
+
/** EC-1502: Required message parameters: constraint class name, relationship end (source/target), relationship name, abstract constraint class name */
|
|
119
|
+
ConstraintClassesDeriveFromAbstractContraint: (0, Diagnostic_1.createSchemaItemDiagnosticClass)(exports.DiagnosticCodes.ConstraintClassesDeriveFromAbstractContraint, "The constraint class '{0}' on the {1}-Constraint of '{2}' is not derived from the abstract constraint class '{3}'."),
|
|
120
|
+
/** EC-1600: Required message parameters: relationship end (source/target), relationship name */
|
|
121
|
+
AtLeastOneConstraintClassDefined: (0, Diagnostic_1.createRelationshipConstraintDiagnosticClass)(exports.DiagnosticCodes.AtLeastOneConstraintClassDefined, "The {0}-Constraint of '{1}' does not contain any constraint classes."),
|
|
122
|
+
/** EC-1601: Required message parameters: relationship end (source/target), relationship name */
|
|
123
|
+
AbstractConstraintMustExistWithMultipleConstraints: (0, Diagnostic_1.createRelationshipConstraintDiagnosticClass)(exports.DiagnosticCodes.AbstractConstraintMustExistWithMultipleConstraints, "The {0}-Constraint of '{1}' has multiple constraint classes which requires an abstract constraint to be defined."),
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* All schema validation rules that fall under the category of ECObjects.
|
|
127
|
+
* @beta
|
|
128
|
+
*/
|
|
129
|
+
exports.ECRuleSet = {
|
|
130
|
+
name: ruleSetName,
|
|
131
|
+
schemaRules: [
|
|
132
|
+
validateSchemaReferences,
|
|
133
|
+
],
|
|
134
|
+
classRules: [
|
|
135
|
+
baseClassIsSealed,
|
|
136
|
+
baseClassIsOfDifferentType,
|
|
137
|
+
],
|
|
138
|
+
propertyRules: [
|
|
139
|
+
incompatibleValueTypePropertyOverride,
|
|
140
|
+
incompatibleTypePropertyOverride,
|
|
141
|
+
incompatibleUnitPropertyOverride,
|
|
142
|
+
validateNavigationProperty,
|
|
143
|
+
],
|
|
144
|
+
relationshipRules: [
|
|
145
|
+
abstractConstraintMustNarrowBaseConstraints,
|
|
146
|
+
constraintClassesDeriveFromAbstractContraint,
|
|
147
|
+
derivedConstraintsMustNarrowBaseConstraints,
|
|
148
|
+
],
|
|
149
|
+
relationshipConstraintRules: [
|
|
150
|
+
atLeastOneConstraintClassDefined,
|
|
151
|
+
abstractConstraintMustExistWithMultipleConstraints,
|
|
152
|
+
],
|
|
153
|
+
enumerationRules: [
|
|
154
|
+
enumerationTypeUnsupported,
|
|
155
|
+
],
|
|
156
|
+
entityClassRules: [
|
|
157
|
+
mixinAppliedToClassMustDeriveFromConstraint,
|
|
158
|
+
],
|
|
159
|
+
customAttributeInstanceRules: [
|
|
160
|
+
validateCustomAttributeInstance,
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
164
|
+
/**
|
|
165
|
+
* Validates schema references against multiple EC rules.
|
|
166
|
+
* @param schema The schema to validate.
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
async function* validateSchemaReferences(schema) {
|
|
170
|
+
yield* validateSchemaReferencesSync(schema);
|
|
171
|
+
}
|
|
172
|
+
exports.validateSchemaReferences = validateSchemaReferences;
|
|
173
|
+
/**
|
|
174
|
+
* Validates schema references against multiple EC rules.
|
|
175
|
+
* @param schema The schema to validate.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
function* validateSchemaReferencesSync(schema) {
|
|
179
|
+
const aliases = new Map();
|
|
180
|
+
for (const schemaRef of schema.references) {
|
|
181
|
+
if (schemaRef.customAttributes && schemaRef.customAttributes.has("CoreCustomAttributes.SupplementalSchema"))
|
|
182
|
+
yield new exports.Diagnostics.SupplementalSchemasCannotBeReferenced(schema, [schema.name, schemaRef.name]);
|
|
183
|
+
if (schema.schemaKey.matches(schemaRef.schemaKey))
|
|
184
|
+
yield new exports.Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, `${schema.name} --> ${schemaRef.name}`]);
|
|
185
|
+
if (aliases.has(schemaRef.alias)) {
|
|
186
|
+
const currentRef = aliases.get(schemaRef.alias);
|
|
187
|
+
yield new exports.Diagnostics.SchemaRefAliasMustBeUnique(schema, [schema.name, schemaRef.alias, currentRef.name, schemaRef.name]);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
aliases.set(schemaRef.alias, schemaRef);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const graph = new ecschema_metadata_1.SchemaGraph(schema);
|
|
194
|
+
const cycles = graph.detectCycles();
|
|
195
|
+
if (cycles) {
|
|
196
|
+
const result = cycles.map((cycle) => `${cycle.schema.name} --> ${cycle.refSchema.name}`).join(", ");
|
|
197
|
+
yield new exports.Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, result]);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.validateSchemaReferencesSync = validateSchemaReferencesSync;
|
|
201
|
+
/**
|
|
202
|
+
* EC Rule: Sealed classes cannot be a base class.
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
async function* baseClassIsSealed(ecClass) {
|
|
206
|
+
if (!ecClass.baseClass)
|
|
207
|
+
return;
|
|
208
|
+
const baseClass = await ecClass.baseClass;
|
|
209
|
+
// return if rule passed
|
|
210
|
+
if (baseClass.modifier !== ecschema_metadata_1.ECClassModifier.Sealed)
|
|
211
|
+
return;
|
|
212
|
+
yield new exports.Diagnostics.BaseClassIsSealed(ecClass, [ecClass.fullName, baseClass.fullName]);
|
|
213
|
+
}
|
|
214
|
+
exports.baseClassIsSealed = baseClassIsSealed;
|
|
215
|
+
/**
|
|
216
|
+
* EC Rule: Base and child class must be of the same type (i.e. Entity, Mixin, Relationship, etc.)
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
async function* baseClassIsOfDifferentType(ecClass) {
|
|
220
|
+
if (!ecClass.baseClass)
|
|
221
|
+
return;
|
|
222
|
+
const baseClass = await ecClass.baseClass;
|
|
223
|
+
// return if rule passed
|
|
224
|
+
if (baseClass.schemaItemType === ecClass.schemaItemType)
|
|
225
|
+
return;
|
|
226
|
+
const itemType = (0, ecschema_metadata_1.schemaItemTypeToString)(baseClass.schemaItemType);
|
|
227
|
+
yield new exports.Diagnostics.BaseClassIsOfDifferentType(ecClass, [ecClass.fullName, baseClass.fullName, itemType]);
|
|
228
|
+
}
|
|
229
|
+
exports.baseClassIsOfDifferentType = baseClassIsOfDifferentType;
|
|
230
|
+
/**
|
|
231
|
+
* EC Rule: When overriding a class primitive property, the child and base property must be of the same type (string, number, etc...).
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
async function* incompatibleValueTypePropertyOverride(property) {
|
|
235
|
+
if (!property.class.baseClass)
|
|
236
|
+
return;
|
|
237
|
+
const primitiveType = getPrimitiveType(property);
|
|
238
|
+
if (!primitiveType)
|
|
239
|
+
return;
|
|
240
|
+
async function callback(baseClass) {
|
|
241
|
+
const baseProperty = await baseClass.getProperty(property.name);
|
|
242
|
+
if (!baseProperty)
|
|
243
|
+
return;
|
|
244
|
+
// Other rules will catch this if false, but we need to make sure
|
|
245
|
+
// types match for this rule to be valid.
|
|
246
|
+
if (!propertyTypesMatch(property, baseProperty))
|
|
247
|
+
return;
|
|
248
|
+
const baseType = getPrimitiveType(baseProperty);
|
|
249
|
+
// Return if rule passed
|
|
250
|
+
if (!baseType || primitiveType === baseType)
|
|
251
|
+
return;
|
|
252
|
+
return new exports.Diagnostics.IncompatibleValueTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, (0, ecschema_metadata_1.primitiveTypeToString)(baseType), (0, ecschema_metadata_1.primitiveTypeToString)(primitiveType)]);
|
|
253
|
+
}
|
|
254
|
+
for await (const baseClass of property.class.getAllBaseClasses()) {
|
|
255
|
+
const result = await callback(baseClass);
|
|
256
|
+
if (result)
|
|
257
|
+
yield result;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.incompatibleValueTypePropertyOverride = incompatibleValueTypePropertyOverride;
|
|
261
|
+
/**
|
|
262
|
+
* EC Rule: When overriding a class property, the child and base property must be of the same property type (primitive, struct, enumeration, etc...).
|
|
263
|
+
* @internal
|
|
264
|
+
*/
|
|
265
|
+
async function* incompatibleTypePropertyOverride(property) {
|
|
266
|
+
if (!property.class.baseClass)
|
|
267
|
+
return;
|
|
268
|
+
async function callback(baseClass) {
|
|
269
|
+
const baseProperty = await baseClass.getProperty(property.name);
|
|
270
|
+
if (!baseProperty)
|
|
271
|
+
return;
|
|
272
|
+
// Return if rule passed
|
|
273
|
+
if (propertyTypesMatch(property, baseProperty))
|
|
274
|
+
return;
|
|
275
|
+
return new exports.Diagnostics.IncompatibleTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, baseProperty.constructor.name, property.constructor.name]);
|
|
276
|
+
}
|
|
277
|
+
for await (const baseClass of property.class.getAllBaseClasses()) {
|
|
278
|
+
const result = await callback(baseClass);
|
|
279
|
+
if (result)
|
|
280
|
+
yield result;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.incompatibleTypePropertyOverride = incompatibleTypePropertyOverride;
|
|
284
|
+
/**
|
|
285
|
+
* EC Rule: When overriding a kindOfQuantity property, the child and base property units must be the same.
|
|
286
|
+
* @internal
|
|
287
|
+
*/
|
|
288
|
+
async function* incompatibleUnitPropertyOverride(property) {
|
|
289
|
+
if (!property.kindOfQuantity || !property.class.baseClass)
|
|
290
|
+
return;
|
|
291
|
+
async function callback(baseClass) {
|
|
292
|
+
const baseProperty = await baseClass.getProperty(property.name);
|
|
293
|
+
if (!baseProperty || !baseProperty.kindOfQuantity)
|
|
294
|
+
return;
|
|
295
|
+
// Other rules will catch this if false, but we need to make sure
|
|
296
|
+
// types match for this rule to be valid.
|
|
297
|
+
if (!propertyTypesMatch(property, baseProperty))
|
|
298
|
+
return;
|
|
299
|
+
const koq = await property.kindOfQuantity;
|
|
300
|
+
const baseKoq = await baseProperty.kindOfQuantity;
|
|
301
|
+
if (!koq || !baseKoq)
|
|
302
|
+
return;
|
|
303
|
+
const unit = await koq.persistenceUnit;
|
|
304
|
+
const baseUnit = await baseKoq.persistenceUnit;
|
|
305
|
+
if (!unit || !baseUnit)
|
|
306
|
+
return;
|
|
307
|
+
// return if rule passed
|
|
308
|
+
if (unit.key.matches(baseUnit.key))
|
|
309
|
+
return;
|
|
310
|
+
return new exports.Diagnostics.IncompatibleUnitPropertyOverride(property, [
|
|
311
|
+
property.class.fullName,
|
|
312
|
+
property.name,
|
|
313
|
+
baseClass.fullName,
|
|
314
|
+
baseKoq.fullName,
|
|
315
|
+
baseUnit.fullName,
|
|
316
|
+
unit.fullName,
|
|
317
|
+
koq.fullName,
|
|
318
|
+
]);
|
|
319
|
+
}
|
|
320
|
+
for await (const baseClass of property.class.getAllBaseClasses()) {
|
|
321
|
+
const result = await callback(baseClass);
|
|
322
|
+
if (result)
|
|
323
|
+
yield result;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
exports.incompatibleUnitPropertyOverride = incompatibleUnitPropertyOverride;
|
|
327
|
+
/**
|
|
328
|
+
* Validates Navigation Properties. EC Rules: 1303, 1304
|
|
329
|
+
* @internal
|
|
330
|
+
*/
|
|
331
|
+
async function* validateNavigationProperty(property) {
|
|
332
|
+
if (!property.isNavigation())
|
|
333
|
+
return;
|
|
334
|
+
const navProp = property;
|
|
335
|
+
const relationship = await navProp.relationshipClass;
|
|
336
|
+
if (relationship.baseClass)
|
|
337
|
+
yield new exports.Diagnostics.NavigationRelationshipMustBeRoot(property, [property.fullName, relationship.fullName]);
|
|
338
|
+
let thisConstraint;
|
|
339
|
+
let thatConstraint;
|
|
340
|
+
let navigationClassSide;
|
|
341
|
+
if (navProp.direction === ecschema_metadata_1.StrengthDirection.Forward) {
|
|
342
|
+
thisConstraint = relationship.source;
|
|
343
|
+
thatConstraint = relationship.target;
|
|
344
|
+
navigationClassSide = "source";
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
thisConstraint = relationship.target;
|
|
348
|
+
thatConstraint = relationship.source;
|
|
349
|
+
navigationClassSide = "target";
|
|
350
|
+
}
|
|
351
|
+
const thatAbstractConstraint = await thatConstraint.abstractConstraint;
|
|
352
|
+
if (thatAbstractConstraint && thatAbstractConstraint.schemaItemType === ecschema_metadata_1.SchemaItemType.RelationshipClass) {
|
|
353
|
+
yield new exports.Diagnostics.NavigationRelationshipAbstractConstraintEntityOrMixin(property, [property.fullName, relationship.fullName]);
|
|
354
|
+
}
|
|
355
|
+
const isClassSupported = async (ecClass, propertyName, constraintName) => {
|
|
356
|
+
if (constraintName === ecClass.fullName && undefined !== await ecClass.getProperty(propertyName))
|
|
357
|
+
return true;
|
|
358
|
+
const inheritedProp = await ecClass.getInheritedProperty(propertyName);
|
|
359
|
+
if (inheritedProp && constraintName === inheritedProp.class.fullName)
|
|
360
|
+
return true;
|
|
361
|
+
const baseClass = await ecClass.baseClass;
|
|
362
|
+
if (!baseClass)
|
|
363
|
+
return false;
|
|
364
|
+
return isClassSupported(baseClass, propertyName, constraintName);
|
|
365
|
+
};
|
|
366
|
+
let classSupported = false;
|
|
367
|
+
if (thisConstraint.constraintClasses) {
|
|
368
|
+
for (const constraintClass of thisConstraint.constraintClasses) {
|
|
369
|
+
classSupported = await isClassSupported(property.class, property.name, constraintClass.fullName);
|
|
370
|
+
if (classSupported)
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (!classSupported)
|
|
375
|
+
yield new exports.Diagnostics.NavigationClassMustBeAConstraintClassOfRelationship(property, [property.class.name, property.name, relationship.fullName, navigationClassSide]);
|
|
376
|
+
if (thatConstraint.multiplicity === ecschema_metadata_1.RelationshipMultiplicity.oneMany || thatConstraint.multiplicity === ecschema_metadata_1.RelationshipMultiplicity.zeroMany) {
|
|
377
|
+
const direction = (0, ecschema_metadata_1.strengthDirectionToString)(navProp.direction);
|
|
378
|
+
yield new exports.Diagnostics.NavigationTargetMustHaveSingularMultiplicity(property, [property.fullName, relationship.fullName, direction]);
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
exports.validateNavigationProperty = validateNavigationProperty;
|
|
383
|
+
/**
|
|
384
|
+
* EC Rule: When overriding a RelationshipClass, the derived abstract constraint must narrow the base constraint classes.
|
|
385
|
+
* @internal
|
|
386
|
+
*/
|
|
387
|
+
async function* abstractConstraintMustNarrowBaseConstraints(ecClass) {
|
|
388
|
+
if (!ecClass.baseClass)
|
|
389
|
+
return;
|
|
390
|
+
const baseRelationship = await ecClass.baseClass;
|
|
391
|
+
const sourceResult = await applyAbstractConstraintMustNarrowBaseConstraints(ecClass, ecClass.source, baseRelationship);
|
|
392
|
+
if (sourceResult)
|
|
393
|
+
yield sourceResult;
|
|
394
|
+
const targetResult = await applyAbstractConstraintMustNarrowBaseConstraints(ecClass, ecClass.target, baseRelationship);
|
|
395
|
+
if (targetResult)
|
|
396
|
+
yield targetResult;
|
|
397
|
+
}
|
|
398
|
+
exports.abstractConstraintMustNarrowBaseConstraints = abstractConstraintMustNarrowBaseConstraints;
|
|
399
|
+
/**
|
|
400
|
+
* EC Rule: When overriding a RelationshipClass, derived constraint classes must narrow base constraint classes.
|
|
401
|
+
* @internal
|
|
402
|
+
*/
|
|
403
|
+
async function* derivedConstraintsMustNarrowBaseConstraints(ecClass) {
|
|
404
|
+
if (!ecClass.baseClass)
|
|
405
|
+
return;
|
|
406
|
+
const baseRelationship = await ecClass.baseClass;
|
|
407
|
+
const sourceResult = await applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, ecClass.source, baseRelationship);
|
|
408
|
+
if (sourceResult)
|
|
409
|
+
yield sourceResult;
|
|
410
|
+
const targetResult = await applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, ecClass.target, baseRelationship);
|
|
411
|
+
if (targetResult)
|
|
412
|
+
yield targetResult;
|
|
413
|
+
}
|
|
414
|
+
exports.derivedConstraintsMustNarrowBaseConstraints = derivedConstraintsMustNarrowBaseConstraints;
|
|
415
|
+
/**
|
|
416
|
+
* EC Rule: All constraint classes must have a common base class specified in the abstract constraint.
|
|
417
|
+
* @internal
|
|
418
|
+
*/
|
|
419
|
+
async function* constraintClassesDeriveFromAbstractContraint(ecClass) {
|
|
420
|
+
const sourceResult = await applyConstraintClassesDeriveFromAbstractContraint(ecClass, ecClass.source);
|
|
421
|
+
if (sourceResult)
|
|
422
|
+
yield sourceResult;
|
|
423
|
+
const targetResult = await applyConstraintClassesDeriveFromAbstractContraint(ecClass, ecClass.target);
|
|
424
|
+
if (targetResult)
|
|
425
|
+
yield targetResult;
|
|
426
|
+
}
|
|
427
|
+
exports.constraintClassesDeriveFromAbstractContraint = constraintClassesDeriveFromAbstractContraint;
|
|
428
|
+
/**
|
|
429
|
+
* EC Rule: At least on concrete constraint class must be defined in the list of constraint classes.
|
|
430
|
+
* @internal
|
|
431
|
+
*/
|
|
432
|
+
async function* atLeastOneConstraintClassDefined(constraint) {
|
|
433
|
+
if (!constraint.constraintClasses || constraint.constraintClasses.length === 0) {
|
|
434
|
+
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
435
|
+
yield new exports.Diagnostics.AtLeastOneConstraintClassDefined(constraint, [constraintType, constraint.relationshipClass.fullName]);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
exports.atLeastOneConstraintClassDefined = atLeastOneConstraintClassDefined;
|
|
439
|
+
/**
|
|
440
|
+
* EC Rule: If multiple constraints exist, an abstract constraint must be defined.
|
|
441
|
+
* @internal
|
|
442
|
+
*/
|
|
443
|
+
async function* abstractConstraintMustExistWithMultipleConstraints(constraint) {
|
|
444
|
+
if (!constraint.constraintClasses || constraint.constraintClasses.length <= 1) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const abstractConstraint = await getAbstractConstraint(constraint);
|
|
448
|
+
if (abstractConstraint)
|
|
449
|
+
return;
|
|
450
|
+
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
451
|
+
yield new exports.Diagnostics.AbstractConstraintMustExistWithMultipleConstraints(constraint, [constraintType, constraint.relationshipClass.fullName]);
|
|
452
|
+
}
|
|
453
|
+
exports.abstractConstraintMustExistWithMultipleConstraints = abstractConstraintMustExistWithMultipleConstraints;
|
|
454
|
+
function propertyTypesMatch(propertyA, propertyB) {
|
|
455
|
+
return propertyA.constructor.name === propertyB.constructor.name;
|
|
456
|
+
}
|
|
457
|
+
function getPrimitiveType(property) {
|
|
458
|
+
if (property.isPrimitive())
|
|
459
|
+
return property.primitiveType;
|
|
460
|
+
return undefined;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* EC Rule: Enumeration type must be a string or integer
|
|
464
|
+
* @internal
|
|
465
|
+
*/
|
|
466
|
+
async function* enumerationTypeUnsupported(enumeration) {
|
|
467
|
+
const type = enumeration.type;
|
|
468
|
+
if (type === ecschema_metadata_1.PrimitiveType.Integer || type === ecschema_metadata_1.PrimitiveType.String)
|
|
469
|
+
return;
|
|
470
|
+
yield new exports.Diagnostics.EnumerationTypeUnsupported(enumeration, [enumeration.fullName]);
|
|
471
|
+
}
|
|
472
|
+
exports.enumerationTypeUnsupported = enumerationTypeUnsupported;
|
|
473
|
+
/**
|
|
474
|
+
* EC Rule: Mixin applied to class must derived from the Mixin appliesTo constraint.
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
async function* mixinAppliedToClassMustDeriveFromConstraint(entityClass) {
|
|
478
|
+
for (const lazyMixin of entityClass.mixins) {
|
|
479
|
+
const mixin = await lazyMixin;
|
|
480
|
+
if (!mixin.appliesTo)
|
|
481
|
+
continue;
|
|
482
|
+
if (!await entityClass.is(await mixin.appliesTo))
|
|
483
|
+
yield new exports.Diagnostics.MixinAppliedToClassMustDeriveFromConstraint(entityClass, [mixin.fullName, entityClass.fullName, mixin.appliesTo.fullName]);
|
|
484
|
+
}
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
exports.mixinAppliedToClassMustDeriveFromConstraint = mixinAppliedToClassMustDeriveFromConstraint;
|
|
488
|
+
/**
|
|
489
|
+
* Validates a custom attribute instance and yields EC-500, EC-501, and EC-502 rule violations.
|
|
490
|
+
* @internal
|
|
491
|
+
*/
|
|
492
|
+
async function* validateCustomAttributeInstance(container, customAttribute) {
|
|
493
|
+
yield* customAttributeNotOfConcreteClass(container, customAttribute);
|
|
494
|
+
yield* customAttributeSchemaMustBeReferenced(container, customAttribute);
|
|
495
|
+
yield* customAttributeClassMustExist(container, customAttribute);
|
|
496
|
+
}
|
|
497
|
+
exports.validateCustomAttributeInstance = validateCustomAttributeInstance;
|
|
498
|
+
/** EC Rule: CustomAttribute instance must be of a concrete CustomAttributeClass. */
|
|
499
|
+
async function* customAttributeNotOfConcreteClass(container, customAttribute) {
|
|
500
|
+
const schema = container.schema;
|
|
501
|
+
const caClass = await schema.lookupItem(customAttribute.className);
|
|
502
|
+
if (!caClass)
|
|
503
|
+
return;
|
|
504
|
+
if (caClass.modifier !== ecschema_metadata_1.ECClassModifier.Abstract)
|
|
505
|
+
return;
|
|
506
|
+
yield new exports.Diagnostics.CustomAttributeNotOfConcreteClass(container, [container.fullName, caClass.fullName]);
|
|
507
|
+
}
|
|
508
|
+
/** EC Rule: CustomAttribute Schema must be referenced by the container's Schema. */
|
|
509
|
+
async function* customAttributeSchemaMustBeReferenced(container, customAttribute) {
|
|
510
|
+
const schema = container.schema;
|
|
511
|
+
const nameParts = customAttribute.className.split(".");
|
|
512
|
+
if (nameParts.length === 1 || nameParts[0] === schema.name)
|
|
513
|
+
return;
|
|
514
|
+
if (schema.references.some((s) => s.name === nameParts[0]))
|
|
515
|
+
return;
|
|
516
|
+
yield new exports.Diagnostics.CustomAttributeSchemaMustBeReferenced(container, [container.fullName, customAttribute.className]);
|
|
517
|
+
}
|
|
518
|
+
/** EC Rule: CustomAttribute instance class must exist. */
|
|
519
|
+
async function* customAttributeClassMustExist(container, customAttribute) {
|
|
520
|
+
const schema = container.schema;
|
|
521
|
+
const caClass = await schema.lookupItem(customAttribute.className);
|
|
522
|
+
if (!caClass)
|
|
523
|
+
yield new exports.Diagnostics.CustomAttributeClassNotFound(container, [container.fullName, customAttribute.className]);
|
|
524
|
+
}
|
|
525
|
+
async function applyAbstractConstraintMustNarrowBaseConstraints(ecClass, constraint, baseRelationship) {
|
|
526
|
+
const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;
|
|
527
|
+
const abstractConstraint = await constraint.abstractConstraint;
|
|
528
|
+
if (!abstractConstraint)
|
|
529
|
+
return;
|
|
530
|
+
if (await baseConstraint.supportsClass(abstractConstraint))
|
|
531
|
+
return;
|
|
532
|
+
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
533
|
+
return new exports.Diagnostics.AbstractConstraintMustNarrowBaseConstraints(ecClass, [abstractConstraint.fullName, constraintType, constraint.relationshipClass.fullName, baseRelationship.fullName]);
|
|
534
|
+
}
|
|
535
|
+
async function applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, constraint, baseRelationship) {
|
|
536
|
+
const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;
|
|
537
|
+
if (!constraint.constraintClasses)
|
|
538
|
+
return;
|
|
539
|
+
for (const classPromise of constraint.constraintClasses) {
|
|
540
|
+
const constraintClass = await classPromise;
|
|
541
|
+
if (await baseConstraint.supportsClass(constraintClass))
|
|
542
|
+
continue;
|
|
543
|
+
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
544
|
+
return new exports.Diagnostics.DerivedConstraintsMustNarrowBaseConstraints(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, baseRelationship.fullName]);
|
|
545
|
+
}
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
async function applyConstraintClassesDeriveFromAbstractContraint(ecClass, constraint) {
|
|
549
|
+
const abstractConstraint = await getAbstractConstraint(constraint);
|
|
550
|
+
if (!abstractConstraint)
|
|
551
|
+
return;
|
|
552
|
+
if (!constraint.constraintClasses)
|
|
553
|
+
return;
|
|
554
|
+
for (const classPromise of constraint.constraintClasses) {
|
|
555
|
+
const constraintClass = await classPromise;
|
|
556
|
+
if (constraintClass.schemaItemType === ecschema_metadata_1.SchemaItemType.Mixin && abstractConstraint.schemaItemType === ecschema_metadata_1.SchemaItemType.EntityClass) {
|
|
557
|
+
if (!await (constraintClass).applicableTo(abstractConstraint)) {
|
|
558
|
+
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
559
|
+
return new exports.Diagnostics.ConstraintClassesDeriveFromAbstractContraint(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, abstractConstraint.fullName]);
|
|
560
|
+
}
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (!await constraintClass.is(abstractConstraint)) {
|
|
564
|
+
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
565
|
+
return new exports.Diagnostics.ConstraintClassesDeriveFromAbstractContraint(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, abstractConstraint.fullName]);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
async function getAbstractConstraint(constraint) {
|
|
571
|
+
const abstractConstraint = await constraint.abstractConstraint;
|
|
572
|
+
if (abstractConstraint)
|
|
573
|
+
return abstractConstraint;
|
|
574
|
+
const baseRelationship = await constraint.relationshipClass.baseClass;
|
|
575
|
+
if (!baseRelationship)
|
|
576
|
+
return;
|
|
577
|
+
const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;
|
|
578
|
+
return getAbstractConstraint(baseConstraint);
|
|
579
|
+
}
|
|
594
580
|
//# sourceMappingURL=ECRules.js.map
|