@itwin/ecschema-editing 4.10.0-dev.31 → 4.10.0-dev.32
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/lib/cjs/Differencing/SchemaDifference.js +2 -2
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +1 -2
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/Utils.js +21 -22
- package/lib/cjs/Differencing/Utils.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +1 -2
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +2 -3
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.js +2 -3
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +3 -4
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js +2 -3
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/Edits/SkipEditHandler.js +1 -2
- package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +3 -4
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +2 -3
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.js +2 -3
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +3 -4
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +2 -3
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +2 -3
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js +2 -3
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +2 -3
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +4 -5
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js +2 -3
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.js +2 -3
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js +2 -3
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.js +4 -5
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +9 -9
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js +19 -19
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/package.json +10 -10
|
@@ -7,7 +7,15 @@
|
|
|
7
7
|
* @module Diagnostic
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.CustomAttributeContainerDiagnostic = exports.RelationshipConstraintDiagnostic = exports.PropertyDiagnostic = exports.ClassDiagnostic = exports.SchemaItemDiagnostic = exports.SchemaDiagnostic = exports.BaseDiagnostic = exports.DiagnosticCategory = exports.DiagnosticType = void 0;
|
|
11
|
+
exports.createSchemaDiagnosticClass = createSchemaDiagnosticClass;
|
|
12
|
+
exports.createSchemaItemDiagnosticClass = createSchemaItemDiagnosticClass;
|
|
13
|
+
exports.createClassDiagnosticClass = createClassDiagnosticClass;
|
|
14
|
+
exports.createPropertyDiagnosticClass = createPropertyDiagnosticClass;
|
|
15
|
+
exports.createRelationshipConstraintDiagnosticClass = createRelationshipConstraintDiagnosticClass;
|
|
16
|
+
exports.createCustomAttributeContainerDiagnosticClass = createCustomAttributeContainerDiagnosticClass;
|
|
17
|
+
exports.diagnosticCategoryToString = diagnosticCategoryToString;
|
|
18
|
+
exports.diagnosticTypeToString = diagnosticTypeToString;
|
|
11
19
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
12
20
|
const formatString = (format, ...args) => {
|
|
13
21
|
return format.replace(/{(\d+)}/g, (match, theNumber) => {
|
|
@@ -194,7 +202,6 @@ function createSchemaDiagnosticClass(code, messageText) {
|
|
|
194
202
|
_a.code = code,
|
|
195
203
|
_a;
|
|
196
204
|
}
|
|
197
|
-
exports.createSchemaDiagnosticClass = createSchemaDiagnosticClass;
|
|
198
205
|
/**
|
|
199
206
|
* Helper method for creating [[SchemaItemDiagnostic]] child classes.
|
|
200
207
|
* @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
|
|
@@ -208,7 +215,6 @@ function createSchemaItemDiagnosticClass(code, messageText) {
|
|
|
208
215
|
get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
|
|
209
216
|
};
|
|
210
217
|
}
|
|
211
|
-
exports.createSchemaItemDiagnosticClass = createSchemaItemDiagnosticClass;
|
|
212
218
|
/**
|
|
213
219
|
* Helper method for creating [[ClassDiagnostic]] child classes.
|
|
214
220
|
* @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
|
|
@@ -222,7 +228,6 @@ function createClassDiagnosticClass(code, messageText) {
|
|
|
222
228
|
get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
|
|
223
229
|
};
|
|
224
230
|
}
|
|
225
|
-
exports.createClassDiagnosticClass = createClassDiagnosticClass;
|
|
226
231
|
/**
|
|
227
232
|
* Helper method for creating [[PropertyDiagnostic]] child classes.
|
|
228
233
|
* @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
|
|
@@ -239,7 +244,6 @@ function createPropertyDiagnosticClass(code, messageText) {
|
|
|
239
244
|
_a.code = code,
|
|
240
245
|
_a;
|
|
241
246
|
}
|
|
242
|
-
exports.createPropertyDiagnosticClass = createPropertyDiagnosticClass;
|
|
243
247
|
/**
|
|
244
248
|
* Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.
|
|
245
249
|
* @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.
|
|
@@ -253,7 +257,6 @@ function createRelationshipConstraintDiagnosticClass(code, messageText) {
|
|
|
253
257
|
get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
|
|
254
258
|
};
|
|
255
259
|
}
|
|
256
|
-
exports.createRelationshipConstraintDiagnosticClass = createRelationshipConstraintDiagnosticClass;
|
|
257
260
|
/**
|
|
258
261
|
* Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.
|
|
259
262
|
* @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.
|
|
@@ -267,7 +270,6 @@ function createCustomAttributeContainerDiagnosticClass(code, messageText) {
|
|
|
267
270
|
get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
|
|
268
271
|
};
|
|
269
272
|
}
|
|
270
|
-
exports.createCustomAttributeContainerDiagnosticClass = createCustomAttributeContainerDiagnosticClass;
|
|
271
273
|
/** @beta */
|
|
272
274
|
function diagnosticCategoryToString(category) {
|
|
273
275
|
switch (category) {
|
|
@@ -281,7 +283,6 @@ function diagnosticCategoryToString(category) {
|
|
|
281
283
|
return "Suggestion";
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
|
-
exports.diagnosticCategoryToString = diagnosticCategoryToString;
|
|
285
286
|
/** @beta */
|
|
286
287
|
function diagnosticTypeToString(type) {
|
|
287
288
|
switch (type) {
|
|
@@ -299,7 +300,6 @@ function diagnosticTypeToString(type) {
|
|
|
299
300
|
return "SchemaItem";
|
|
300
301
|
}
|
|
301
302
|
}
|
|
302
|
-
exports.diagnosticTypeToString = diagnosticTypeToString;
|
|
303
303
|
function validateCode(code) {
|
|
304
304
|
const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;
|
|
305
305
|
const parts = code.split("-");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,iDAAiD;AAEjD,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,GAAG,IAAc,EAAE,EAAE;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACrD,OAAO,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,WAAW;YAC3C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACjB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;GAGG;AACH,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,mDAAI,CAAA;IACJ,uDAAM,CAAA;IACN,+DAAU,CAAA;IACV,2DAAQ,CAAA;IACR,2FAAwB,CAAA;IACxB,uFAAsB,CAAA;AACxB,CAAC,EAPW,cAAc,8BAAd,cAAc,QAOzB;AAED;;;GAGG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iEAAO,CAAA;IACP,6DAAK,CAAA;IACL,uEAAU,CAAA;IACV,iEAAO,CAAA;AACT,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B;AA6BD;;;GAGG;AACH,MAAsB,cAAc;IAClC;;;;;OAKG;IACH,YAAY,YAAkB,EAAE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,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Diagnostic\r\n */\r\n\r\nimport { AnyClass, AnyECType, AnyProperty, CustomAttributeContainerProps, RelationshipConstraint, Schema, SchemaItem } from \"@itwin/ecschema-metadata\";\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow */\r\n\r\nconst formatString = (format: string, ...args: string[]) => {\r\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\r\n return typeof args[theNumber] !== \"undefined\"\r\n ? args[theNumber]\r\n : match;\r\n });\r\n};\r\n\r\n/**\r\n * Defines the possible diagnostic types.\r\n * @beta\r\n */\r\nexport enum DiagnosticType {\r\n None,\r\n Schema, // eslint-disable-line @typescript-eslint/no-shadow\r\n SchemaItem, // eslint-disable-line @typescript-eslint/no-shadow\r\n Property,\r\n CustomAttributeContainer,\r\n RelationshipConstraint, // eslint-disable-line @typescript-eslint/no-shadow\r\n}\r\n\r\n/**\r\n * Defines the possible diagnostic categories.\r\n * @beta\r\n */\r\nexport enum DiagnosticCategory {\r\n Warning,\r\n Error,\r\n Suggestion,\r\n Message,\r\n}\r\n\r\n/**\r\n * The interface implemented by all diagnostics used during schema validation.\r\n * @beta\r\n */\r\nexport interface IDiagnostic<TYPE extends AnyECType, ARGS extends any[]> {\r\n /** The diagnostic category (error, warning, etc...). Value is static across all instances. */\r\n category: DiagnosticCategory;\r\n /** The unique string identifier of the diagnostic in the format '<ruleSetName>:<number>. Value is static across all instances. */\r\n code: string;\r\n /** The context type of diagnostic (schema, schema item, property, etc...). Value is static across all instances. */\r\n diagnosticType: DiagnosticType;\r\n /** The unformatted message text associated with the diagnostic. Value is static across all instances. */\r\n messageText: string;\r\n /** The arguments used when formatted the diagnostic instance's message. */\r\n messageArgs?: ARGS;\r\n /** The EC object associated with the diagnostic instance. */\r\n ecDefinition: TYPE;\r\n /** The schema where the diagnostic originated. */\r\n schema: Schema;\r\n}\r\n\r\n/**\r\n * Type which encapsulates all possible diagnostics.\r\n * @beta\r\n */\r\nexport type AnyDiagnostic = IDiagnostic<AnyECType, any[]>;\r\n\r\n/**\r\n * The abstract base class for all [[IDiagnostic]] implementations.\r\n * @beta\r\n */\r\nexport abstract class BaseDiagnostic<TYPE extends AnyECType, ARGS extends any[]> implements IDiagnostic<TYPE, ARGS> {\r\n /**\r\n * Initializes a new BaseDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecDefinition: TYPE, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n this.ecDefinition = ecDefinition;\r\n this.messageArgs = messageArgs;\r\n this.category = category;\r\n }\r\n\r\n /** Gets the unique string identifier for the diagnostic in the format '<ruleSetName>:<number>'. */\r\n public abstract get code(): string;\r\n /** Gets the context type of the diagnostic (schema, schema item, property, etc...) */\r\n public abstract get diagnosticType(): DiagnosticType;\r\n /** Gets the message associated with the diagnostic. */\r\n public abstract get messageText(): string;\r\n /** Gets the schema where the diagnostic originated. */\r\n public abstract get schema(): Schema;\r\n\r\n /** The EC object to associate with the diagnostic. */\r\n public ecDefinition: TYPE;\r\n /** The arguments used when formatting the diagnostic message. */\r\n public messageArgs?: ARGS;\r\n /** The diagnostic category is of the type DiagnosticCategory; which is defined as an enumeration above. */\r\n public category: DiagnosticCategory;\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class SchemaDiagnostic<ARGS extends any[]> extends BaseDiagnostic<Schema, ARGS> {\r\n public static diagnosticType = DiagnosticType.SchemaItem;\r\n\r\n /**\r\n * Initializes a new SchemaDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(schema: Schema, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(schema, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Schema; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class SchemaItemDiagnostic<TYPE extends SchemaItem, ARGS extends any[]> extends BaseDiagnostic<TYPE, ARGS> {\r\n public static diagnosticType = DiagnosticType.SchemaItem;\r\n /**\r\n * Initializes a new SchemaItemDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecDefinition: SchemaItem, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(ecDefinition as TYPE, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.SchemaItem; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class ClassDiagnostic<ARGS extends any[]> extends SchemaItemDiagnostic<AnyClass, ARGS> {\r\n /**\r\n * Initializes a new ClassDiagnostic.\r\n * @param ecClass The class to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecClass: AnyClass, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(ecClass, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public override get schema(): Schema { return this.ecDefinition.schema; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class PropertyDiagnostic<ARGS extends any[]> extends BaseDiagnostic<AnyProperty, ARGS> {\r\n /**\r\n * Initializes a new PropertyDiagnostic.\r\n * @param property The property to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(property: AnyProperty, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(property, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Property; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class RelationshipConstraintDiagnostic<ARGS extends any[]> extends BaseDiagnostic<RelationshipConstraint, ARGS> {\r\n /**\r\n * Initializes a new RelationshipConstraintDiagnostic.\r\n * @param constraint The Relationship Constraint to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(constraint: RelationshipConstraint, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(constraint, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.RelationshipConstraint; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class CustomAttributeContainerDiagnostic<ARGS extends any[]> extends BaseDiagnostic<CustomAttributeContainerProps, ARGS> {\r\n /**\r\n * Initializes a new CustomAttributeContainerDiagnostic.\r\n * @param constraint The Custom Attribute Container to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(container: CustomAttributeContainerProps, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(container, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.CustomAttributeContainer; }\r\n}\r\n\r\n/**\r\n * Helper method for creating [[SchemaDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createSchemaDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends SchemaDiagnostic<ARGS> {\r\n public static code = code;\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[SchemaItemDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createSchemaItemDiagnosticClass<ITEM extends SchemaItem, ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends SchemaItemDiagnostic<ITEM, ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[ClassDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createClassDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends ClassDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[PropertyDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createPropertyDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends PropertyDiagnostic<ARGS> {\r\n public static code = code;\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createRelationshipConstraintDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends RelationshipConstraintDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.\r\n * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createCustomAttributeContainerDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends CustomAttributeContainerDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/** @beta */\r\nexport function diagnosticCategoryToString(category: DiagnosticCategory) {\r\n switch (category) {\r\n case DiagnosticCategory.Error:\r\n return \"Error\";\r\n case DiagnosticCategory.Warning:\r\n return \"Warning\";\r\n case DiagnosticCategory.Message:\r\n return \"Message\";\r\n case DiagnosticCategory.Suggestion:\r\n return \"Suggestion\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function diagnosticTypeToString(type: DiagnosticType) {\r\n switch (type) {\r\n case DiagnosticType.CustomAttributeContainer:\r\n return \"CustomAttributeContainer\";\r\n case DiagnosticType.None:\r\n return \"None\";\r\n case DiagnosticType.Property:\r\n return \"Property\";\r\n case DiagnosticType.RelationshipConstraint:\r\n return \"RelationshipConstraint\";\r\n case DiagnosticType.Schema:\r\n return \"Schema\";\r\n case DiagnosticType.SchemaItem:\r\n return \"SchemaItem\";\r\n }\r\n}\r\n\r\nfunction validateCode(code: string) {\r\n const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;\r\n const parts = code.split(\"-\");\r\n if (parts.length !== 2)\r\n throw new Error(msg);\r\n\r\n if (isNaN(Number(parts[1])))\r\n throw new Error(msg);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA6OH,kEAOC;AAQD,0EAMC;AAQD,gEAMC;AAQD,sEAOC;AAQD,kGAMC;AAQD,sGAMC;AAGD,gEAWC;AAGD,wDAeC;AAvVD,iDAA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B;IACzD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,cAAc,CAAC,wBAAwB;YAC1C,OAAO,0BAA0B,CAAC;QACpC,KAAK,cAAc,CAAC,IAAI;YACtB,OAAO,MAAM,CAAC;QAChB,KAAK,cAAc,CAAC,QAAQ;YAC1B,OAAO,UAAU,CAAC;QACpB,KAAK,cAAc,CAAC,sBAAsB;YACxC,OAAO,wBAAwB,CAAC;QAClC,KAAK,cAAc,CAAC,MAAM;YACxB,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc,CAAC,UAAU;YAC5B,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,GAAG,GAAG,mBAAmB,IAAI,0DAA0D,CAAC;IAC9F,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvB,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Diagnostic\r\n */\r\n\r\nimport { AnyClass, AnyECType, AnyProperty, CustomAttributeContainerProps, RelationshipConstraint, Schema, SchemaItem } from \"@itwin/ecschema-metadata\";\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow */\r\n\r\nconst formatString = (format: string, ...args: string[]) => {\r\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\r\n return typeof args[theNumber] !== \"undefined\"\r\n ? args[theNumber]\r\n : match;\r\n });\r\n};\r\n\r\n/**\r\n * Defines the possible diagnostic types.\r\n * @beta\r\n */\r\nexport enum DiagnosticType {\r\n None,\r\n Schema, // eslint-disable-line @typescript-eslint/no-shadow\r\n SchemaItem, // eslint-disable-line @typescript-eslint/no-shadow\r\n Property,\r\n CustomAttributeContainer,\r\n RelationshipConstraint, // eslint-disable-line @typescript-eslint/no-shadow\r\n}\r\n\r\n/**\r\n * Defines the possible diagnostic categories.\r\n * @beta\r\n */\r\nexport enum DiagnosticCategory {\r\n Warning,\r\n Error,\r\n Suggestion,\r\n Message,\r\n}\r\n\r\n/**\r\n * The interface implemented by all diagnostics used during schema validation.\r\n * @beta\r\n */\r\nexport interface IDiagnostic<TYPE extends AnyECType, ARGS extends any[]> {\r\n /** The diagnostic category (error, warning, etc...). Value is static across all instances. */\r\n category: DiagnosticCategory;\r\n /** The unique string identifier of the diagnostic in the format '<ruleSetName>:<number>. Value is static across all instances. */\r\n code: string;\r\n /** The context type of diagnostic (schema, schema item, property, etc...). Value is static across all instances. */\r\n diagnosticType: DiagnosticType;\r\n /** The unformatted message text associated with the diagnostic. Value is static across all instances. */\r\n messageText: string;\r\n /** The arguments used when formatted the diagnostic instance's message. */\r\n messageArgs?: ARGS;\r\n /** The EC object associated with the diagnostic instance. */\r\n ecDefinition: TYPE;\r\n /** The schema where the diagnostic originated. */\r\n schema: Schema;\r\n}\r\n\r\n/**\r\n * Type which encapsulates all possible diagnostics.\r\n * @beta\r\n */\r\nexport type AnyDiagnostic = IDiagnostic<AnyECType, any[]>;\r\n\r\n/**\r\n * The abstract base class for all [[IDiagnostic]] implementations.\r\n * @beta\r\n */\r\nexport abstract class BaseDiagnostic<TYPE extends AnyECType, ARGS extends any[]> implements IDiagnostic<TYPE, ARGS> {\r\n /**\r\n * Initializes a new BaseDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecDefinition: TYPE, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n this.ecDefinition = ecDefinition;\r\n this.messageArgs = messageArgs;\r\n this.category = category;\r\n }\r\n\r\n /** Gets the unique string identifier for the diagnostic in the format '<ruleSetName>:<number>'. */\r\n public abstract get code(): string;\r\n /** Gets the context type of the diagnostic (schema, schema item, property, etc...) */\r\n public abstract get diagnosticType(): DiagnosticType;\r\n /** Gets the message associated with the diagnostic. */\r\n public abstract get messageText(): string;\r\n /** Gets the schema where the diagnostic originated. */\r\n public abstract get schema(): Schema;\r\n\r\n /** The EC object to associate with the diagnostic. */\r\n public ecDefinition: TYPE;\r\n /** The arguments used when formatting the diagnostic message. */\r\n public messageArgs?: ARGS;\r\n /** The diagnostic category is of the type DiagnosticCategory; which is defined as an enumeration above. */\r\n public category: DiagnosticCategory;\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class SchemaDiagnostic<ARGS extends any[]> extends BaseDiagnostic<Schema, ARGS> {\r\n public static diagnosticType = DiagnosticType.SchemaItem;\r\n\r\n /**\r\n * Initializes a new SchemaDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(schema: Schema, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(schema, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Schema; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class SchemaItemDiagnostic<TYPE extends SchemaItem, ARGS extends any[]> extends BaseDiagnostic<TYPE, ARGS> {\r\n public static diagnosticType = DiagnosticType.SchemaItem;\r\n /**\r\n * Initializes a new SchemaItemDiagnostic.\r\n * @param ecDefinition The EC object to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecDefinition: SchemaItem, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(ecDefinition as TYPE, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.SchemaItem; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class ClassDiagnostic<ARGS extends any[]> extends SchemaItemDiagnostic<AnyClass, ARGS> {\r\n /**\r\n * Initializes a new ClassDiagnostic.\r\n * @param ecClass The class to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(ecClass: AnyClass, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(ecClass, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public override get schema(): Schema { return this.ecDefinition.schema; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class PropertyDiagnostic<ARGS extends any[]> extends BaseDiagnostic<AnyProperty, ARGS> {\r\n /**\r\n * Initializes a new PropertyDiagnostic.\r\n * @param property The property to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(property: AnyProperty, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(property, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Property; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class RelationshipConstraintDiagnostic<ARGS extends any[]> extends BaseDiagnostic<RelationshipConstraint, ARGS> {\r\n /**\r\n * Initializes a new RelationshipConstraintDiagnostic.\r\n * @param constraint The Relationship Constraint to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(constraint: RelationshipConstraint, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(constraint, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.RelationshipConstraint; }\r\n}\r\n\r\n/**\r\n * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.\r\n * @beta\r\n */\r\nexport abstract class CustomAttributeContainerDiagnostic<ARGS extends any[]> extends BaseDiagnostic<CustomAttributeContainerProps, ARGS> {\r\n /**\r\n * Initializes a new CustomAttributeContainerDiagnostic.\r\n * @param constraint The Custom Attribute Container to associate with the diagnostic.\r\n * @param messageArgs The arguments used when formatting the diagnostic message.\r\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\r\n */\r\n constructor(container: CustomAttributeContainerProps, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\r\n super(container, messageArgs, category);\r\n }\r\n\r\n /** Gets the schema where the diagnostic originated. */\r\n public get schema(): Schema { return this.ecDefinition.schema; }\r\n\r\n /** Gets the DiagnosticType. */\r\n public get diagnosticType(): DiagnosticType { return DiagnosticType.CustomAttributeContainer; }\r\n}\r\n\r\n/**\r\n * Helper method for creating [[SchemaDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createSchemaDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends SchemaDiagnostic<ARGS> {\r\n public static code = code;\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[SchemaItemDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createSchemaItemDiagnosticClass<ITEM extends SchemaItem, ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends SchemaItemDiagnostic<ITEM, ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[ClassDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createClassDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends ClassDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[PropertyDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createPropertyDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends PropertyDiagnostic<ARGS> {\r\n public static code = code;\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.\r\n * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createRelationshipConstraintDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends RelationshipConstraintDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/**\r\n * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.\r\n * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\r\n * @param messageText The message to associate with the diagnostic class.\r\n * @beta\r\n */\r\nexport function createCustomAttributeContainerDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\r\n validateCode(code);\r\n return class extends CustomAttributeContainerDiagnostic<ARGS> {\r\n public get code(): string { return code; }\r\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\r\n };\r\n}\r\n\r\n/** @beta */\r\nexport function diagnosticCategoryToString(category: DiagnosticCategory) {\r\n switch (category) {\r\n case DiagnosticCategory.Error:\r\n return \"Error\";\r\n case DiagnosticCategory.Warning:\r\n return \"Warning\";\r\n case DiagnosticCategory.Message:\r\n return \"Message\";\r\n case DiagnosticCategory.Suggestion:\r\n return \"Suggestion\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function diagnosticTypeToString(type: DiagnosticType) {\r\n switch (type) {\r\n case DiagnosticType.CustomAttributeContainer:\r\n return \"CustomAttributeContainer\";\r\n case DiagnosticType.None:\r\n return \"None\";\r\n case DiagnosticType.Property:\r\n return \"Property\";\r\n case DiagnosticType.RelationshipConstraint:\r\n return \"RelationshipConstraint\";\r\n case DiagnosticType.Schema:\r\n return \"Schema\";\r\n case DiagnosticType.SchemaItem:\r\n return \"SchemaItem\";\r\n }\r\n}\r\n\r\nfunction validateCode(code: string) {\r\n const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;\r\n const parts = code.split(\"-\");\r\n if (parts.length !== 2)\r\n throw new Error(msg);\r\n\r\n if (isNaN(Number(parts[1])))\r\n throw new Error(msg);\r\n}\r\n"]}
|
|
@@ -7,7 +7,25 @@
|
|
|
7
7
|
* @module Validation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.ECRuleSet = exports.Diagnostics = exports.DiagnosticCodes = void 0;
|
|
11
|
+
exports.validateSchemaReferences = validateSchemaReferences;
|
|
12
|
+
exports.validateSchemaReferencesSync = validateSchemaReferencesSync;
|
|
13
|
+
exports.baseClassIsSealed = baseClassIsSealed;
|
|
14
|
+
exports.baseClassIsOfDifferentType = baseClassIsOfDifferentType;
|
|
15
|
+
exports.incompatibleValueTypePropertyOverride = incompatibleValueTypePropertyOverride;
|
|
16
|
+
exports.incompatibleTypePropertyOverride = incompatibleTypePropertyOverride;
|
|
17
|
+
exports.incompatibleUnitPropertyOverride = incompatibleUnitPropertyOverride;
|
|
18
|
+
exports.validateNavigationProperty = validateNavigationProperty;
|
|
19
|
+
exports.validateRelationship = validateRelationship;
|
|
20
|
+
exports.abstractConstraintMustNarrowBaseConstraints = abstractConstraintMustNarrowBaseConstraints;
|
|
21
|
+
exports.derivedConstraintsMustNarrowBaseConstraints = derivedConstraintsMustNarrowBaseConstraints;
|
|
22
|
+
exports.constraintClassesDeriveFromAbstractConstraint = constraintClassesDeriveFromAbstractConstraint;
|
|
23
|
+
exports.validateRelationshipConstraint = validateRelationshipConstraint;
|
|
24
|
+
exports.atLeastOneConstraintClassDefined = atLeastOneConstraintClassDefined;
|
|
25
|
+
exports.abstractConstraintMustExistWithMultipleConstraints = abstractConstraintMustExistWithMultipleConstraints;
|
|
26
|
+
exports.enumerationTypeUnsupported = enumerationTypeUnsupported;
|
|
27
|
+
exports.mixinAppliedToClassMustDeriveFromConstraint = mixinAppliedToClassMustDeriveFromConstraint;
|
|
28
|
+
exports.validateCustomAttributeInstance = validateCustomAttributeInstance;
|
|
11
29
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
30
|
const Diagnostic_1 = require("./Diagnostic");
|
|
13
31
|
const ruleSetName = "ECObjects";
|
|
@@ -169,7 +187,6 @@ exports.ECRuleSet = {
|
|
|
169
187
|
async function* validateSchemaReferences(schema) {
|
|
170
188
|
yield* validateSchemaReferencesSync(schema);
|
|
171
189
|
}
|
|
172
|
-
exports.validateSchemaReferences = validateSchemaReferences;
|
|
173
190
|
/**
|
|
174
191
|
* Validates schema references against multiple EC rules.
|
|
175
192
|
* @param schema The schema to validate.
|
|
@@ -197,7 +214,6 @@ function* validateSchemaReferencesSync(schema) {
|
|
|
197
214
|
yield new exports.Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, result]);
|
|
198
215
|
}
|
|
199
216
|
}
|
|
200
|
-
exports.validateSchemaReferencesSync = validateSchemaReferencesSync;
|
|
201
217
|
/**
|
|
202
218
|
* EC Rule: Sealed classes cannot be a base class.
|
|
203
219
|
* @internal
|
|
@@ -211,7 +227,6 @@ async function* baseClassIsSealed(ecClass) {
|
|
|
211
227
|
return;
|
|
212
228
|
yield new exports.Diagnostics.BaseClassIsSealed(ecClass, [ecClass.fullName, baseClass.fullName]);
|
|
213
229
|
}
|
|
214
|
-
exports.baseClassIsSealed = baseClassIsSealed;
|
|
215
230
|
/**
|
|
216
231
|
* EC Rule: Base and child class must be of the same type (i.e. Entity, Mixin, Relationship, etc.)
|
|
217
232
|
* @internal
|
|
@@ -226,7 +241,6 @@ async function* baseClassIsOfDifferentType(ecClass) {
|
|
|
226
241
|
const itemType = baseClass.schemaItemType;
|
|
227
242
|
yield new exports.Diagnostics.BaseClassIsOfDifferentType(ecClass, [ecClass.fullName, baseClass.fullName, itemType]);
|
|
228
243
|
}
|
|
229
|
-
exports.baseClassIsOfDifferentType = baseClassIsOfDifferentType;
|
|
230
244
|
/**
|
|
231
245
|
* EC Rule: When overriding a class primitive property, the child and base property must be of the same type (string, number, etc...).
|
|
232
246
|
* @internal
|
|
@@ -257,7 +271,6 @@ async function* incompatibleValueTypePropertyOverride(property) {
|
|
|
257
271
|
yield result;
|
|
258
272
|
}
|
|
259
273
|
}
|
|
260
|
-
exports.incompatibleValueTypePropertyOverride = incompatibleValueTypePropertyOverride;
|
|
261
274
|
/**
|
|
262
275
|
* EC Rule: When overriding a class property, the child and base property must be of the same property type (primitive, struct, enumeration, etc...).
|
|
263
276
|
* @internal
|
|
@@ -280,7 +293,6 @@ async function* incompatibleTypePropertyOverride(property) {
|
|
|
280
293
|
yield result;
|
|
281
294
|
}
|
|
282
295
|
}
|
|
283
|
-
exports.incompatibleTypePropertyOverride = incompatibleTypePropertyOverride;
|
|
284
296
|
/**
|
|
285
297
|
* EC Rule: When overriding a kindOfQuantity property, the child and base property units must be the same.
|
|
286
298
|
* @internal
|
|
@@ -323,7 +335,6 @@ async function* incompatibleUnitPropertyOverride(property) {
|
|
|
323
335
|
yield result;
|
|
324
336
|
}
|
|
325
337
|
}
|
|
326
|
-
exports.incompatibleUnitPropertyOverride = incompatibleUnitPropertyOverride;
|
|
327
338
|
/**
|
|
328
339
|
* Validates Navigation Properties. EC Rules: 1303, 1304
|
|
329
340
|
* @internal
|
|
@@ -379,7 +390,6 @@ async function* validateNavigationProperty(property) {
|
|
|
379
390
|
}
|
|
380
391
|
return;
|
|
381
392
|
}
|
|
382
|
-
exports.validateNavigationProperty = validateNavigationProperty;
|
|
383
393
|
/**
|
|
384
394
|
* Validates a Relationship class and yields EC-1500, EC-1501, and EC-1502 rule violations.
|
|
385
395
|
* @internal
|
|
@@ -389,7 +399,6 @@ async function* validateRelationship(ecClass) {
|
|
|
389
399
|
yield* derivedConstraintsMustNarrowBaseConstraints(ecClass);
|
|
390
400
|
yield* constraintClassesDeriveFromAbstractConstraint(ecClass);
|
|
391
401
|
}
|
|
392
|
-
exports.validateRelationship = validateRelationship;
|
|
393
402
|
/**
|
|
394
403
|
* EC Rule: When overriding a RelationshipClass, the derived abstract constraint must narrow the base constraint classes.
|
|
395
404
|
* @internal
|
|
@@ -405,7 +414,6 @@ async function* abstractConstraintMustNarrowBaseConstraints(ecClass) {
|
|
|
405
414
|
if (targetResult)
|
|
406
415
|
yield targetResult;
|
|
407
416
|
}
|
|
408
|
-
exports.abstractConstraintMustNarrowBaseConstraints = abstractConstraintMustNarrowBaseConstraints;
|
|
409
417
|
/**
|
|
410
418
|
* EC Rule: When overriding a RelationshipClass, derived constraint classes must narrow base constraint classes.
|
|
411
419
|
* @internal
|
|
@@ -421,7 +429,6 @@ async function* derivedConstraintsMustNarrowBaseConstraints(ecClass) {
|
|
|
421
429
|
if (targetResult)
|
|
422
430
|
yield targetResult;
|
|
423
431
|
}
|
|
424
|
-
exports.derivedConstraintsMustNarrowBaseConstraints = derivedConstraintsMustNarrowBaseConstraints;
|
|
425
432
|
/**
|
|
426
433
|
* EC Rule: All constraint classes must have a common base class specified in the abstract constraint.
|
|
427
434
|
* @internal
|
|
@@ -434,7 +441,6 @@ async function* constraintClassesDeriveFromAbstractConstraint(ecClass) {
|
|
|
434
441
|
if (targetResult)
|
|
435
442
|
yield targetResult;
|
|
436
443
|
}
|
|
437
|
-
exports.constraintClassesDeriveFromAbstractConstraint = constraintClassesDeriveFromAbstractConstraint;
|
|
438
444
|
/**
|
|
439
445
|
* Validates a RelationshipConstraint and yields EC-1600 and EC-1601 rule violations.
|
|
440
446
|
* @internal
|
|
@@ -443,7 +449,6 @@ async function* validateRelationshipConstraint(constraint) {
|
|
|
443
449
|
yield* atLeastOneConstraintClassDefined(constraint);
|
|
444
450
|
yield* abstractConstraintMustExistWithMultipleConstraints(constraint);
|
|
445
451
|
}
|
|
446
|
-
exports.validateRelationshipConstraint = validateRelationshipConstraint;
|
|
447
452
|
/**
|
|
448
453
|
* EC Rule: At least on concrete constraint class must be defined in the list of constraint classes.
|
|
449
454
|
* @internal
|
|
@@ -454,7 +459,6 @@ async function* atLeastOneConstraintClassDefined(constraint) {
|
|
|
454
459
|
yield new exports.Diagnostics.AtLeastOneConstraintClassDefined(constraint, [constraintType, constraint.relationshipClass.fullName]);
|
|
455
460
|
}
|
|
456
461
|
}
|
|
457
|
-
exports.atLeastOneConstraintClassDefined = atLeastOneConstraintClassDefined;
|
|
458
462
|
/**
|
|
459
463
|
* EC Rule: If multiple constraints exist, an abstract constraint must be defined.
|
|
460
464
|
* @internal
|
|
@@ -469,7 +473,6 @@ async function* abstractConstraintMustExistWithMultipleConstraints(constraint) {
|
|
|
469
473
|
const constraintType = constraint.isSource ? ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_SOURCE : ecschema_metadata_1.ECStringConstants.RELATIONSHIP_END_TARGET;
|
|
470
474
|
yield new exports.Diagnostics.AbstractConstraintMustExistWithMultipleConstraints(constraint, [constraintType, constraint.relationshipClass.fullName]);
|
|
471
475
|
}
|
|
472
|
-
exports.abstractConstraintMustExistWithMultipleConstraints = abstractConstraintMustExistWithMultipleConstraints;
|
|
473
476
|
function propertyTypesMatch(propertyA, propertyB) {
|
|
474
477
|
return propertyA.constructor.name === propertyB.constructor.name;
|
|
475
478
|
}
|
|
@@ -488,7 +491,6 @@ async function* enumerationTypeUnsupported(enumeration) {
|
|
|
488
491
|
return;
|
|
489
492
|
yield new exports.Diagnostics.EnumerationTypeUnsupported(enumeration, [enumeration.fullName]);
|
|
490
493
|
}
|
|
491
|
-
exports.enumerationTypeUnsupported = enumerationTypeUnsupported;
|
|
492
494
|
/**
|
|
493
495
|
* EC Rule: Mixin applied to class must derived from the Mixin appliesTo constraint.
|
|
494
496
|
* @internal
|
|
@@ -503,7 +505,6 @@ async function* mixinAppliedToClassMustDeriveFromConstraint(entityClass) {
|
|
|
503
505
|
}
|
|
504
506
|
return;
|
|
505
507
|
}
|
|
506
|
-
exports.mixinAppliedToClassMustDeriveFromConstraint = mixinAppliedToClassMustDeriveFromConstraint;
|
|
507
508
|
/**
|
|
508
509
|
* Validates a custom attribute instance and yields EC-500, EC-501, and EC-502 rule violations.
|
|
509
510
|
* @internal
|
|
@@ -513,7 +514,6 @@ async function* validateCustomAttributeInstance(container, customAttribute) {
|
|
|
513
514
|
yield* customAttributeSchemaMustBeReferenced(container, customAttribute);
|
|
514
515
|
yield* customAttributeClassMustExist(container, customAttribute);
|
|
515
516
|
}
|
|
516
|
-
exports.validateCustomAttributeInstance = validateCustomAttributeInstance;
|
|
517
517
|
/** EC Rule: CustomAttribute instance must be of a concrete CustomAttributeClass. */
|
|
518
518
|
async function* customAttributeNotOfConcreteClass(container, customAttribute) {
|
|
519
519
|
const schema = container.schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECRules.js","sourceRoot":"","sources":["../../../src/Validation/ECRules.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAKkC;AAClC,6CAKsB;AAGtB,MAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,GAAG,WAAW,IAAI,IAAI,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,yDAAyD;AAC5C,QAAA,eAAe,GAAG;IAC7B,6BAA6B;IAC7B,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC;IAC/B,wBAAwB,EAAE,OAAO,CAAC,GAAG,CAAC;IACtC,uEAAuE;IACvE,gCAAgC,EAAE,OAAO,CAAC,GAAG,CAAC;IAE9C,oCA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right (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 Validation\r\n */\r\n\r\nimport {\r\n AnyClass, AnyProperty, CustomAttribute, CustomAttributeContainerProps, ECClass, ECClassModifier,\r\n ECStringConstants, EntityClass, Enumeration, PrimitiveProperty, PrimitiveType, primitiveTypeToString,\r\n Property, RelationshipClass, RelationshipConstraint, RelationshipMultiplicity, Schema, SchemaGraph, SchemaItemType,\r\n StrengthDirection, strengthDirectionToString,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport {\r\n ClassDiagnostic, createClassDiagnosticClass, createCustomAttributeContainerDiagnosticClass, createPropertyDiagnosticClass,\r\n createRelationshipConstraintDiagnosticClass, createSchemaDiagnosticClass, createSchemaItemDiagnosticClass, CustomAttributeContainerDiagnostic,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n DiagnosticType, PropertyDiagnostic, RelationshipConstraintDiagnostic, SchemaDiagnostic, SchemaItemDiagnostic,\r\n} from \"./Diagnostic\";\r\nimport { IRuleSet } from \"./Rules\";\r\n\r\nconst ruleSetName = \"ECObjects\";\r\n\r\nfunction getCode(code: number): string {\r\n return `${ruleSetName}-${code}`;\r\n}\r\n\r\n/**\r\n * The unique diagnostic codes for ECObjects rules.\r\n *\r\n * To provide meaning to code values, with anticipation\r\n * of future rules for all current EC Types, the following\r\n * value ranges should be used:\r\n *\r\n * - Schema: 000-099\r\n * - Class: 100-199\r\n * - Constant: 200-299\r\n * - CustomAttribute 300-399\r\n * - CustomAttributeClass: 400-499\r\n * - CustomAttributeContainer: 500-599\r\n * - EntityClass: 600-699\r\n * - Enumeration: 700-799\r\n * - Format: 800-899\r\n * - InvertedUnit: 900-999\r\n * - KindOfQuantity: 1000-1099\r\n * - Mixin: 1100-1199\r\n * - Phenomenon: 1200-1299\r\n * - Property: 1300-1399\r\n * - PropertyCategory: 1400-1499\r\n * - RelationshipClass: 1500-1599\r\n * - RelationshipConstraint: 1600-1699\r\n * - StructClass: 1700-1799\r\n * - Unit: 1800-1899\r\n * - UnitSystem: 1900-1999\r\n * @beta\r\n */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nexport const DiagnosticCodes = {\r\n // Class Rule Codes (100-199)\r\n BaseClassIsSealed: getCode(100),\r\n BaseClassOfDifferentType: getCode(101),\r\n // EC-102 has been deprecated. Leaving the code here to prevent re-use.\r\n AbstractClassWithNonAbstractBase: getCode(102),\r\n\r\n // CA Container Rule Codes (500-599)\r\n CustomAttributeNotOfConcreteClass: getCode(500),\r\n CustomAttributeSchemaMustBeReferenced: getCode(501),\r\n CustomAttributeClassNotFound: getCode(502),\r\n\r\n // Enumeration Rule Codes (700-799)\r\n EnumerationTypeUnsupported: getCode(700),\r\n\r\n // Mixin Rule Codes (1100-1199)\r\n MixinAppliedToClassMustDeriveFromConstraint: getCode(1100),\r\n\r\n // Property Rule Codes (1300-1399)\r\n IncompatibleValueTypePropertyOverride: getCode(1300),\r\n IncompatibleTypePropertyOverride: getCode(1301),\r\n IncompatibleUnitPropertyOverride: getCode(1302),\r\n\r\n // Relationship Rule Codes (1500-1599)\r\n AbstractConstraintMustNarrowBaseConstraints: getCode(1500),\r\n DerivedConstraintsMustNarrowBaseConstraints: getCode(1501),\r\n ConstraintClassesDeriveFromAbstractConstraint: getCode(1502),\r\n\r\n // Relationship Constraint Rule Codes (1600-1699)\r\n AtLeastOneConstraintClassDefined: getCode(1600),\r\n AbstractConstraintMustExistWithMultipleConstraints: getCode(1601),\r\n};\r\n\r\n/**\r\n * The list of [[IDiagnostic]] implementation classes used by the EC rule implementations.\r\n * @beta\r\n */\r\nexport const Diagnostics = {\r\n /** EC-001: Required message parameters: schema name, referenced schema name */\r\n SupplementalSchemasCannotBeReferenced: createSchemaDiagnosticClass<[string, string]>(getCode(1),\r\n \"Referenced schema '{1}' of schema '{0}' is a supplemental schema. Supplemental schemas are not allowed to be referenced.\"),\r\n\r\n /** EC-002: Required message parameters: schema name, reference schema alias, first schema reference name, second schema reference name. */\r\n SchemaRefAliasMustBeUnique: createSchemaDiagnosticClass<[string, string, string, string]>(getCode(2),\r\n \"Schema '{0}' has multiple schema references ({2}, {3}) with the same alias '{1}', which is not allowed.\"),\r\n\r\n /** EC-003: Required message parameters: schema name, cycle text */\r\n ReferenceCyclesNotAllowed: createSchemaDiagnosticClass<[string, string]>(getCode(3),\r\n \"Schema '{0}' has reference cycles: {1}\"),\r\n\r\n /** EC-100: Required message parameters: childClass.FullName, baseClass.FullName */\r\n BaseClassIsSealed: createClassDiagnosticClass<[string, string]>(DiagnosticCodes.BaseClassIsSealed,\r\n \"Class '{0}' cannot derive from sealed base class '{1}'.\"),\r\n\r\n /** EC-101: Required message parameters: childClass.FullName, baseClass.FullName, baseClass.schemaItemType */\r\n BaseClassIsOfDifferentType: createClassDiagnosticClass<[string, string, string]>(DiagnosticCodes.BaseClassOfDifferentType,\r\n \"Class '{0}' cannot derive from base class '{1}' of type '{2}'.\"),\r\n\r\n /** **DEPRECATED** EC-102: Required message parameters: childClass.FullName, baseClass.FullName */\r\n AbstractClassWithNonAbstractBase: createClassDiagnosticClass<[string, string]>(DiagnosticCodes.AbstractClassWithNonAbstractBase,\r\n \"Abstract Class '{0}' cannot derive from base class '{1}' because it is not an abstract class.\"),\r\n\r\n /** EC-500: Required message parameters: CustomAttribute container name and CustomAttributeClass name. */\r\n CustomAttributeNotOfConcreteClass: createCustomAttributeContainerDiagnosticClass<[string, string]>(DiagnosticCodes.CustomAttributeNotOfConcreteClass,\r\n \"The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' which is not a concrete class.\"),\r\n\r\n /** EC-501: Required message parameters: CustomAttribute container name, CustomAttributeClass name, CustomAttributeClass Schema name. */\r\n CustomAttributeSchemaMustBeReferenced: createCustomAttributeContainerDiagnosticClass<[string, string]>(DiagnosticCodes.CustomAttributeSchemaMustBeReferenced,\r\n \"The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' whose schema is not referenced by the container's Schema.\"),\r\n\r\n /** EC-502: Required message parameters: CustomAttribute container name and CustomAttributeClass name. */\r\n CustomAttributeClassNotFound: createCustomAttributeContainerDiagnosticClass<[string, string]>(DiagnosticCodes.CustomAttributeClassNotFound,\r\n \"The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' which cannot be found.\"),\r\n\r\n /** EC-700: Required message parameters: Enumeration name */\r\n EnumerationTypeUnsupported: createSchemaItemDiagnosticClass<Enumeration, [string]>(DiagnosticCodes.EnumerationTypeUnsupported,\r\n \"Enumeration '{0}' has invalid primitive type.\"),\r\n\r\n /** EC-1100: Required message parameters: mixin class fullName, class fullName, applies to constraint class fullName */\r\n MixinAppliedToClassMustDeriveFromConstraint: createSchemaItemDiagnosticClass<EntityClass, [string, string, string]>(DiagnosticCodes.MixinAppliedToClassMustDeriveFromConstraint,\r\n \"Mixin '{0}' cannot be applied to the class '{1}' because it does not satisfy the applies to constraint '{2}'.\"),\r\n\r\n /** EC-1300: Required message parameters: childClass.FullName, property name, baseClass.FullName, base value type, child value type */\r\n IncompatibleValueTypePropertyOverride: createPropertyDiagnosticClass<[string, string, string, string, string]>(DiagnosticCodes.IncompatibleValueTypePropertyOverride,\r\n \"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}.\"),\r\n\r\n /** EC-1301: Required message parameters: childClass.FullName, property name, baseClass.FullName, base property type, child property type */\r\n IncompatibleTypePropertyOverride: createPropertyDiagnosticClass<[string, string, string, string, string]>(DiagnosticCodes.IncompatibleTypePropertyOverride,\r\n \"The ECProperty '{0}.{1}' has a base property '{2}.{1}' with a type of {3} which is incompatible with the type of {4}.\"),\r\n\r\n /** 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 */\r\n IncompatibleUnitPropertyOverride: createPropertyDiagnosticClass<[string, string, string, string, string, string, string]>(DiagnosticCodes.IncompatibleUnitPropertyOverride,\r\n \"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}'.\"),\r\n\r\n /** EC-1303: Required message parameters: property.fullName, navigation relationship.fullName */\r\n NavigationRelationshipMustBeRoot: createPropertyDiagnosticClass<[string, string]>(getCode(1303),\r\n \"The referenced relationship '{1}', used in NavigationProperty '{0}' is not the root relationship.\"),\r\n\r\n /** EC-1304: Required message parameters: property.fullName, navigation relationship.fullName */\r\n NavigationTargetMustHaveSingularMultiplicity: createPropertyDiagnosticClass<[string, string, string]>(getCode(1304),\r\n \"NavigationProperty '{0}' uses the relationship '{1}' that cannot be traversed in the '{2}' direction due to a max multiplicity greater than 1.\"),\r\n\r\n /** EC-1305: Required message parameters: property.fullName, navigation relationship.fullName */\r\n NavigationRelationshipAbstractConstraintEntityOrMixin: createPropertyDiagnosticClass<[string, string]>(getCode(1305),\r\n \"The NavigationProperty '{0}', using the relationship '{1}', points to a RelationshipClass, which is not allowed. NavigationProperties must point to an EntityClass or Mixin.\"),\r\n\r\n /** EC-1306: Required message parameters: class name, property name, navigation relationship.fullName */\r\n NavigationClassMustBeAConstraintClassOfRelationship: createPropertyDiagnosticClass<[string, string, string, string]>(getCode(1306),\r\n \"The class '{0}' of NavigationProperty '{1}' is not supported by the {3} constraint of the referenced relationship '{2}'.\"),\r\n\r\n /** EC-1500: Required message parameters: abstract constraint class name, relationship end (source/target), relationship name, base relationship name */\r\n AbstractConstraintMustNarrowBaseConstraints: createSchemaItemDiagnosticClass<RelationshipClass, [string, string, string, string]>(DiagnosticCodes.AbstractConstraintMustNarrowBaseConstraints,\r\n \"The abstract constraint class '{0}' on the {1}-Constraint of '{2}' is not supported by the base class constraint in '{3}'.\"),\r\n\r\n /** EC-1501: Required message parameters: constraint class name, relationship end (source/target), relationship name, base relationship name */\r\n DerivedConstraintsMustNarrowBaseConstraints: createSchemaItemDiagnosticClass<RelationshipClass, [string, string, string, string]>(DiagnosticCodes.DerivedConstraintsMustNarrowBaseConstraints,\r\n \"The constraint class '{0}' on the {1}-Constraint of '{2}' is not supported by the base class constraint in '{3}'.\"),\r\n\r\n /** EC-1502: Required message parameters: constraint class name, relationship end (source/target), relationship name, abstract constraint class name */\r\n ConstraintClassesDeriveFromAbstractConstraint: createSchemaItemDiagnosticClass<RelationshipClass, [string, string, string, string]>(DiagnosticCodes.ConstraintClassesDeriveFromAbstractConstraint,\r\n \"The constraint class '{0}' on the {1}-Constraint of '{2}' is not derived from the abstract constraint class '{3}'.\"),\r\n\r\n /** EC-1600: Required message parameters: relationship end (source/target), relationship name */\r\n AtLeastOneConstraintClassDefined: createRelationshipConstraintDiagnosticClass<[string, string]>(DiagnosticCodes.AtLeastOneConstraintClassDefined,\r\n \"The {0}-Constraint of '{1}' does not contain any constraint classes.\"),\r\n\r\n /** EC-1601: Required message parameters: relationship end (source/target), relationship name */\r\n AbstractConstraintMustExistWithMultipleConstraints: createRelationshipConstraintDiagnosticClass<[string, string]>(DiagnosticCodes.AbstractConstraintMustExistWithMultipleConstraints,\r\n \"The {0}-Constraint of '{1}' has multiple constraint classes which requires an abstract constraint to be defined.\"),\r\n};\r\n\r\n/**\r\n * All schema validation rules that fall under the category of ECObjects.\r\n * @beta\r\n */\r\nexport const ECRuleSet: IRuleSet = {\r\n name: ruleSetName,\r\n\r\n schemaRules: [\r\n validateSchemaReferences,\r\n ],\r\n classRules: [\r\n baseClassIsSealed,\r\n baseClassIsOfDifferentType,\r\n ],\r\n propertyRules: [\r\n incompatibleValueTypePropertyOverride,\r\n incompatibleTypePropertyOverride,\r\n incompatibleUnitPropertyOverride,\r\n validateNavigationProperty,\r\n ],\r\n relationshipRules: [\r\n abstractConstraintMustNarrowBaseConstraints,\r\n constraintClassesDeriveFromAbstractConstraint,\r\n derivedConstraintsMustNarrowBaseConstraints,\r\n ],\r\n relationshipConstraintRules: [\r\n atLeastOneConstraintClassDefined,\r\n abstractConstraintMustExistWithMultipleConstraints,\r\n ],\r\n enumerationRules: [\r\n enumerationTypeUnsupported,\r\n ],\r\n entityClassRules: [\r\n mixinAppliedToClassMustDeriveFromConstraint,\r\n ],\r\n customAttributeInstanceRules: [\r\n validateCustomAttributeInstance,\r\n ],\r\n};\r\n\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n\r\n/**\r\n * Validates schema references against multiple EC rules.\r\n * @param schema The schema to validate.\r\n * @internal\r\n */\r\nexport async function* validateSchemaReferences(schema: Schema): AsyncIterable<SchemaDiagnostic<any[]>> {\r\n yield* validateSchemaReferencesSync(schema);\r\n}\r\n\r\n/**\r\n * Validates schema references against multiple EC rules.\r\n * @param schema The schema to validate.\r\n * @internal\r\n */\r\nexport function* validateSchemaReferencesSync(schema: Schema): Iterable<SchemaDiagnostic<any[]>> {\r\n const aliases = new Map();\r\n for (const schemaRef of schema.references) {\r\n if (schemaRef.customAttributes && schemaRef.customAttributes.has(\"CoreCustomAttributes.SupplementalSchema\"))\r\n yield new Diagnostics.SupplementalSchemasCannotBeReferenced(schema, [schema.name, schemaRef.name]);\r\n\r\n if (schema.schemaKey.matches(schemaRef.schemaKey))\r\n yield new Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, `${schema.name} --> ${schemaRef.name}`]);\r\n\r\n if (aliases.has(schemaRef.alias)) {\r\n const currentRef = aliases.get(schemaRef.alias);\r\n yield new Diagnostics.SchemaRefAliasMustBeUnique(schema, [schema.name, schemaRef.alias, currentRef.name, schemaRef.name]);\r\n } else {\r\n aliases.set(schemaRef.alias, schemaRef);\r\n }\r\n }\r\n\r\n const graph = SchemaGraph.generateGraphSync(schema);\r\n const cycles = graph.detectCycles();\r\n if (cycles) {\r\n const result = cycles.map((cycle) => `${cycle.schema.schemaKey.name} --> ${cycle.refSchema.schemaKey.name}`).join(\", \");\r\n yield new Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, result]);\r\n }\r\n}\r\n/**\r\n * EC Rule: Sealed classes cannot be a base class.\r\n * @internal\r\n */\r\nexport async function* baseClassIsSealed(ecClass: AnyClass): AsyncIterable<ClassDiagnostic<any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseClass = await ecClass.baseClass;\r\n // return if rule passed\r\n if (baseClass.modifier !== ECClassModifier.Sealed)\r\n return;\r\n\r\n yield new Diagnostics.BaseClassIsSealed(ecClass, [ecClass.fullName, baseClass.fullName]);\r\n}\r\n\r\n/**\r\n * EC Rule: Base and child class must be of the same type (i.e. Entity, Mixin, Relationship, etc.)\r\n * @internal\r\n */\r\nexport async function* baseClassIsOfDifferentType(ecClass: AnyClass): AsyncIterable<ClassDiagnostic<any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseClass = await ecClass.baseClass;\r\n // return if rule passed\r\n if (baseClass.schemaItemType === ecClass.schemaItemType)\r\n return;\r\n\r\n const itemType = baseClass.schemaItemType;\r\n yield new Diagnostics.BaseClassIsOfDifferentType(ecClass, [ecClass.fullName, baseClass.fullName, itemType]);\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a class primitive property, the child and base property must be of the same type (string, number, etc...).\r\n * @internal\r\n*/\r\nexport async function* incompatibleValueTypePropertyOverride(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.class.baseClass)\r\n return;\r\n\r\n const primitiveType = getPrimitiveType(property);\r\n if (!primitiveType)\r\n return;\r\n\r\n async function callback(baseClass: ECClass): Promise<PropertyDiagnostic<any[]> | undefined> {\r\n const baseProperty = await baseClass.getProperty(property.name);\r\n if (!baseProperty)\r\n return;\r\n\r\n // Other rules will catch this if false, but we need to make sure\r\n // types match for this rule to be valid.\r\n if (!propertyTypesMatch(property, baseProperty))\r\n return;\r\n\r\n const baseType = getPrimitiveType(baseProperty);\r\n\r\n // Return if rule passed\r\n if (!baseType || primitiveType === baseType)\r\n return;\r\n\r\n return new Diagnostics.IncompatibleValueTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, primitiveTypeToString(baseType), primitiveTypeToString(primitiveType!)]);\r\n }\r\n\r\n for await (const baseClass of property.class.getAllBaseClasses()) {\r\n const result = await callback(baseClass);\r\n if (result)\r\n yield result;\r\n }\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a class property, the child and base property must be of the same property type (primitive, struct, enumeration, etc...).\r\n * @internal\r\n */\r\nexport async function* incompatibleTypePropertyOverride(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.class.baseClass)\r\n return;\r\n\r\n async function callback(baseClass: ECClass): Promise<PropertyDiagnostic<any[]> | undefined> {\r\n const baseProperty = await baseClass.getProperty(property.name);\r\n if (!baseProperty)\r\n return;\r\n\r\n // Return if rule passed\r\n if (propertyTypesMatch(property, baseProperty))\r\n return;\r\n\r\n return new Diagnostics.IncompatibleTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, baseProperty.constructor.name, property.constructor.name]);\r\n }\r\n\r\n for await (const baseClass of property.class.getAllBaseClasses()) {\r\n const result = await callback(baseClass);\r\n if (result)\r\n yield result;\r\n }\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a kindOfQuantity property, the child and base property units must be the same.\r\n * @internal\r\n */\r\nexport async function* incompatibleUnitPropertyOverride(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.kindOfQuantity || !property.class.baseClass)\r\n return;\r\n\r\n async function callback(baseClass: ECClass): Promise<PropertyDiagnostic<any[]> | undefined> {\r\n const baseProperty = await baseClass.getProperty(property.name);\r\n if (!baseProperty || !baseProperty.kindOfQuantity)\r\n return;\r\n\r\n // Other rules will catch this if false, but we need to make sure\r\n // types match for this rule to be valid.\r\n if (!propertyTypesMatch(property, baseProperty))\r\n return;\r\n\r\n const koq = await property.kindOfQuantity;\r\n const baseKoq = await baseProperty.kindOfQuantity;\r\n if (!koq || !baseKoq)\r\n return;\r\n\r\n const unit = await koq.persistenceUnit;\r\n const baseUnit = await baseKoq.persistenceUnit;\r\n\r\n if (!unit || !baseUnit)\r\n return;\r\n\r\n // return if rule passed\r\n if (unit.key.matches(baseUnit.key))\r\n return;\r\n\r\n return new Diagnostics.IncompatibleUnitPropertyOverride(property, [\r\n property.class.fullName,\r\n property.name,\r\n baseClass.fullName,\r\n baseKoq.fullName,\r\n baseUnit.fullName,\r\n unit.fullName,\r\n koq.fullName,\r\n ]);\r\n }\r\n\r\n for await (const baseClass of property.class.getAllBaseClasses()) {\r\n const result = await callback(baseClass);\r\n if (result)\r\n yield result;\r\n }\r\n}\r\n\r\n/**\r\n * Validates Navigation Properties. EC Rules: 1303, 1304\r\n * @internal\r\n */\r\nexport async function* validateNavigationProperty(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.isNavigation())\r\n return;\r\n\r\n const navProp = property;\r\n const relationship = await navProp.relationshipClass;\r\n\r\n if (relationship.baseClass)\r\n yield new Diagnostics.NavigationRelationshipMustBeRoot(property, [property.fullName, relationship.fullName]);\r\n\r\n let thisConstraint: RelationshipConstraint;\r\n let thatConstraint: RelationshipConstraint;\r\n let navigationClassSide: string;\r\n if (navProp.direction === StrengthDirection.Forward) {\r\n thisConstraint = relationship.source;\r\n thatConstraint = relationship.target;\r\n navigationClassSide = \"source\";\r\n } else {\r\n thisConstraint = relationship.target;\r\n thatConstraint = relationship.source;\r\n navigationClassSide = \"target\";\r\n }\r\n\r\n const thatAbstractConstraint = await thatConstraint.abstractConstraint;\r\n if (thatAbstractConstraint && thatAbstractConstraint.schemaItemType === SchemaItemType.RelationshipClass) {\r\n yield new Diagnostics.NavigationRelationshipAbstractConstraintEntityOrMixin(property, [property.fullName, relationship.fullName]);\r\n }\r\n\r\n const isClassSupported = async (ecClass: ECClass, propertyName: string, constraintName: string): Promise<boolean> => {\r\n if (constraintName === ecClass.fullName && undefined !== await ecClass.getProperty(propertyName))\r\n return true;\r\n\r\n const inheritedProp = await ecClass.getInheritedProperty(propertyName);\r\n if (inheritedProp && constraintName === inheritedProp.class.fullName)\r\n return true;\r\n\r\n const baseClass = await ecClass.baseClass;\r\n if (!baseClass)\r\n return false;\r\n\r\n return isClassSupported(baseClass, propertyName, constraintName);\r\n };\r\n\r\n let classSupported = false;\r\n if (thisConstraint.constraintClasses) {\r\n for (const constraintClass of thisConstraint.constraintClasses) {\r\n classSupported = await isClassSupported(property.class, property.name, constraintClass.fullName);\r\n if (classSupported)\r\n break;\r\n }\r\n }\r\n\r\n if (!classSupported)\r\n yield new Diagnostics.NavigationClassMustBeAConstraintClassOfRelationship(property, [property.class.name, property.name, relationship.fullName, navigationClassSide]);\r\n\r\n if (thatConstraint.multiplicity === RelationshipMultiplicity.oneMany || thatConstraint.multiplicity === RelationshipMultiplicity.zeroMany) {\r\n const direction = strengthDirectionToString(navProp.direction);\r\n yield new Diagnostics.NavigationTargetMustHaveSingularMultiplicity(property, [property.fullName, relationship.fullName, direction]);\r\n }\r\n\r\n return;\r\n}\r\n\r\n/**\r\n * Validates a Relationship class and yields EC-1500, EC-1501, and EC-1502 rule violations.\r\n * @internal\r\n */\r\nexport async function* validateRelationship(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n yield* abstractConstraintMustNarrowBaseConstraints(ecClass);\r\n yield* derivedConstraintsMustNarrowBaseConstraints(ecClass);\r\n yield* constraintClassesDeriveFromAbstractConstraint(ecClass);\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a RelationshipClass, the derived abstract constraint must narrow the base constraint classes.\r\n * @internal\r\n */\r\nexport async function* abstractConstraintMustNarrowBaseConstraints(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseRelationship = await ecClass.baseClass as RelationshipClass;\r\n\r\n const sourceResult = await applyAbstractConstraintMustNarrowBaseConstraints(ecClass, ecClass.source, baseRelationship);\r\n if (sourceResult)\r\n yield sourceResult;\r\n const targetResult = await applyAbstractConstraintMustNarrowBaseConstraints(ecClass, ecClass.target, baseRelationship);\r\n if (targetResult)\r\n yield targetResult;\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a RelationshipClass, derived constraint classes must narrow base constraint classes.\r\n * @internal\r\n */\r\nexport async function* derivedConstraintsMustNarrowBaseConstraints(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseRelationship = await ecClass.baseClass as RelationshipClass;\r\n\r\n const sourceResult = await applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, ecClass.source, baseRelationship);\r\n if (sourceResult)\r\n yield sourceResult;\r\n const targetResult = await applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, ecClass.target, baseRelationship);\r\n if (targetResult)\r\n yield targetResult;\r\n}\r\n\r\n/**\r\n * EC Rule: All constraint classes must have a common base class specified in the abstract constraint.\r\n * @internal\r\n */\r\nexport async function* constraintClassesDeriveFromAbstractConstraint(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n const sourceResult = await applyConstraintClassesDeriveFromAbstractConstraint(ecClass, ecClass.source);\r\n if (sourceResult)\r\n yield sourceResult;\r\n const targetResult = await applyConstraintClassesDeriveFromAbstractConstraint(ecClass, ecClass.target);\r\n if (targetResult)\r\n yield targetResult;\r\n}\r\n\r\n/**\r\n * Validates a RelationshipConstraint and yields EC-1600 and EC-1601 rule violations.\r\n * @internal\r\n */\r\nexport async function* validateRelationshipConstraint(constraint: RelationshipConstraint): AsyncIterable<RelationshipConstraintDiagnostic<any[]>> {\r\n yield* atLeastOneConstraintClassDefined(constraint);\r\n yield* abstractConstraintMustExistWithMultipleConstraints(constraint);\r\n}\r\n\r\n/**\r\n * EC Rule: At least on concrete constraint class must be defined in the list of constraint classes.\r\n * @internal\r\n */\r\nexport async function* atLeastOneConstraintClassDefined(constraint: RelationshipConstraint): AsyncIterable<RelationshipConstraintDiagnostic<any[]>> {\r\n if (!constraint.constraintClasses || constraint.constraintClasses.length === 0) {\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n yield new Diagnostics.AtLeastOneConstraintClassDefined(constraint, [constraintType, constraint.relationshipClass.fullName]);\r\n }\r\n}\r\n\r\n/**\r\n * EC Rule: If multiple constraints exist, an abstract constraint must be defined.\r\n * @internal\r\n */\r\nexport async function* abstractConstraintMustExistWithMultipleConstraints(constraint: RelationshipConstraint): AsyncIterable<RelationshipConstraintDiagnostic<any[]>> {\r\n if (!constraint.constraintClasses || constraint.constraintClasses.length <= 1) {\r\n return;\r\n }\r\n\r\n const abstractConstraint = await getAbstractConstraint(constraint);\r\n if (abstractConstraint)\r\n return;\r\n\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n yield new Diagnostics.AbstractConstraintMustExistWithMultipleConstraints(constraint, [constraintType, constraint.relationshipClass.fullName]);\r\n}\r\n\r\nfunction propertyTypesMatch(propertyA: Property, propertyB: Property) {\r\n return propertyA.constructor.name === propertyB.constructor.name;\r\n}\r\n\r\nfunction getPrimitiveType(property: Property): PrimitiveType | undefined {\r\n if (property.isPrimitive())\r\n return (property as PrimitiveProperty).primitiveType;\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * EC Rule: Enumeration type must be a string or integer\r\n * @internal\r\n */\r\nexport async function* enumerationTypeUnsupported(enumeration: Enumeration): AsyncIterable<SchemaItemDiagnostic<Enumeration, any[]>> {\r\n const type = enumeration.type;\r\n if (type === PrimitiveType.Integer || type === PrimitiveType.String)\r\n return;\r\n\r\n yield new Diagnostics.EnumerationTypeUnsupported(enumeration, [enumeration.fullName]);\r\n}\r\n\r\n/**\r\n * EC Rule: Mixin applied to class must derived from the Mixin appliesTo constraint.\r\n * @internal\r\n */\r\nexport async function* mixinAppliedToClassMustDeriveFromConstraint(entityClass: EntityClass): AsyncIterable<SchemaItemDiagnostic<EntityClass, any[]>> {\r\n for (const lazyMixin of entityClass.mixins) {\r\n const mixin = await lazyMixin;\r\n if (!mixin.appliesTo)\r\n continue;\r\n\r\n if (!await entityClass.is(await mixin.appliesTo))\r\n yield new Diagnostics.MixinAppliedToClassMustDeriveFromConstraint(entityClass, [mixin.fullName, entityClass.fullName, mixin.appliesTo.fullName]);\r\n }\r\n\r\n return;\r\n}\r\n\r\n/**\r\n * Validates a custom attribute instance and yields EC-500, EC-501, and EC-502 rule violations.\r\n * @internal\r\n */\r\nexport async function* validateCustomAttributeInstance(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n yield* customAttributeNotOfConcreteClass(container, customAttribute);\r\n yield* customAttributeSchemaMustBeReferenced(container, customAttribute);\r\n yield* customAttributeClassMustExist(container, customAttribute);\r\n}\r\n\r\n/** EC Rule: CustomAttribute instance must be of a concrete CustomAttributeClass. */\r\nasync function* customAttributeNotOfConcreteClass(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n const schema = container.schema;\r\n const caClass = await schema.lookupItem(customAttribute.className) as ECClass;\r\n if (!caClass)\r\n return;\r\n\r\n if (caClass.modifier !== ECClassModifier.Abstract)\r\n return;\r\n\r\n yield new Diagnostics.CustomAttributeNotOfConcreteClass(container, [container.fullName, caClass.fullName]);\r\n}\r\n\r\n/** EC Rule: CustomAttribute Schema must be referenced by the container's Schema. */\r\nasync function* customAttributeSchemaMustBeReferenced(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n const schema = container.schema;\r\n const nameParts = customAttribute.className.split(\".\");\r\n if (nameParts.length === 1 || nameParts[0] === schema.name)\r\n return;\r\n\r\n if (schema.references.some((s) => s.name === nameParts[0]))\r\n return;\r\n\r\n yield new Diagnostics.CustomAttributeSchemaMustBeReferenced(container, [container.fullName, customAttribute.className]);\r\n}\r\n\r\n/** EC Rule: CustomAttribute instance class must exist. */\r\nasync function* customAttributeClassMustExist(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n const schema = container.schema;\r\n const caClass = await schema.lookupItem(customAttribute.className) as ECClass;\r\n if (!caClass)\r\n yield new Diagnostics.CustomAttributeClassNotFound(container, [container.fullName, customAttribute.className]);\r\n}\r\n\r\nasync function applyAbstractConstraintMustNarrowBaseConstraints(ecClass: RelationshipClass, constraint: RelationshipConstraint, baseRelationship: RelationshipClass): Promise<SchemaItemDiagnostic<RelationshipClass, any[]> | undefined> {\r\n const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;\r\n const abstractConstraint = await constraint.abstractConstraint;\r\n if (!abstractConstraint)\r\n return;\r\n\r\n if (await baseConstraint.supportsClass(abstractConstraint))\r\n return;\r\n\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.AbstractConstraintMustNarrowBaseConstraints(ecClass, [abstractConstraint.fullName, constraintType, constraint.relationshipClass.fullName, baseRelationship.fullName]);\r\n}\r\n\r\nasync function applyDerivedConstraintsMustNarrowBaseConstraints(ecClass: RelationshipClass, constraint: RelationshipConstraint, baseRelationship: RelationshipClass): Promise<SchemaItemDiagnostic<RelationshipClass, any[]> | undefined> {\r\n const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;\r\n\r\n if (!constraint.constraintClasses)\r\n return;\r\n\r\n for (const classPromise of constraint.constraintClasses) {\r\n const constraintClass = await classPromise;\r\n\r\n if (await baseConstraint.supportsClass(constraintClass))\r\n continue;\r\n\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.DerivedConstraintsMustNarrowBaseConstraints(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, baseRelationship.fullName]);\r\n }\r\n\r\n return;\r\n}\r\n\r\nasync function applyConstraintClassesDeriveFromAbstractConstraint(ecClass: RelationshipClass, constraint: RelationshipConstraint): Promise<SchemaItemDiagnostic<RelationshipClass, any[]> | undefined> {\r\n const abstractConstraint = await getAbstractConstraint(constraint);\r\n if (!abstractConstraint)\r\n return;\r\n\r\n if (!constraint.constraintClasses)\r\n return;\r\n\r\n for (const classPromise of constraint.constraintClasses) {\r\n const constraintClass = await classPromise;\r\n\r\n if (constraintClass.schemaItemType === SchemaItemType.Mixin && abstractConstraint.schemaItemType === SchemaItemType.EntityClass) {\r\n if (!await (constraintClass).applicableTo(abstractConstraint as EntityClass)) {\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.ConstraintClassesDeriveFromAbstractConstraint(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, abstractConstraint.fullName]);\r\n }\r\n continue;\r\n }\r\n\r\n if (!await constraintClass.is(abstractConstraint)) {\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.ConstraintClassesDeriveFromAbstractConstraint(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, abstractConstraint.fullName]);\r\n }\r\n }\r\n\r\n return;\r\n}\r\n\r\nasync function getAbstractConstraint(constraint: RelationshipConstraint): Promise<ECClass | undefined> {\r\n const abstractConstraint = await constraint.abstractConstraint;\r\n if (abstractConstraint)\r\n return abstractConstraint;\r\n\r\n const baseRelationship = await constraint.relationshipClass.baseClass as RelationshipClass;\r\n if (!baseRelationship)\r\n return;\r\n\r\n const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;\r\n\r\n return getAbstractConstraint(baseConstraint);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ECR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AAC;IAED,OAAO;AACT,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,UAAkC;IACrE,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;IAC/D,IAAI,kBAAkB;QACpB,OAAO,kBAAkB,CAAC;IAE5B,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,iBAAiB,CAAC,SAA8B,CAAC;IAC3F,IAAI,CAAC,gBAAgB;QACnB,OAAO;IAET,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAE/F,OAAO,qBAAqB,CAAC,cAAc,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Validation\r\n */\r\n\r\nimport {\r\n AnyClass, AnyProperty, CustomAttribute, CustomAttributeContainerProps, ECClass, ECClassModifier,\r\n ECStringConstants, EntityClass, Enumeration, PrimitiveProperty, PrimitiveType, primitiveTypeToString,\r\n Property, RelationshipClass, RelationshipConstraint, RelationshipMultiplicity, Schema, SchemaGraph, SchemaItemType,\r\n StrengthDirection, strengthDirectionToString,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport {\r\n ClassDiagnostic, createClassDiagnosticClass, createCustomAttributeContainerDiagnosticClass, createPropertyDiagnosticClass,\r\n createRelationshipConstraintDiagnosticClass, createSchemaDiagnosticClass, createSchemaItemDiagnosticClass, CustomAttributeContainerDiagnostic,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n DiagnosticType, PropertyDiagnostic, RelationshipConstraintDiagnostic, SchemaDiagnostic, SchemaItemDiagnostic,\r\n} from \"./Diagnostic\";\r\nimport { IRuleSet } from \"./Rules\";\r\n\r\nconst ruleSetName = \"ECObjects\";\r\n\r\nfunction getCode(code: number): string {\r\n return `${ruleSetName}-${code}`;\r\n}\r\n\r\n/**\r\n * The unique diagnostic codes for ECObjects rules.\r\n *\r\n * To provide meaning to code values, with anticipation\r\n * of future rules for all current EC Types, the following\r\n * value ranges should be used:\r\n *\r\n * - Schema: 000-099\r\n * - Class: 100-199\r\n * - Constant: 200-299\r\n * - CustomAttribute 300-399\r\n * - CustomAttributeClass: 400-499\r\n * - CustomAttributeContainer: 500-599\r\n * - EntityClass: 600-699\r\n * - Enumeration: 700-799\r\n * - Format: 800-899\r\n * - InvertedUnit: 900-999\r\n * - KindOfQuantity: 1000-1099\r\n * - Mixin: 1100-1199\r\n * - Phenomenon: 1200-1299\r\n * - Property: 1300-1399\r\n * - PropertyCategory: 1400-1499\r\n * - RelationshipClass: 1500-1599\r\n * - RelationshipConstraint: 1600-1699\r\n * - StructClass: 1700-1799\r\n * - Unit: 1800-1899\r\n * - UnitSystem: 1900-1999\r\n * @beta\r\n */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nexport const DiagnosticCodes = {\r\n // Class Rule Codes (100-199)\r\n BaseClassIsSealed: getCode(100),\r\n BaseClassOfDifferentType: getCode(101),\r\n // EC-102 has been deprecated. Leaving the code here to prevent re-use.\r\n AbstractClassWithNonAbstractBase: getCode(102),\r\n\r\n // CA Container Rule Codes (500-599)\r\n CustomAttributeNotOfConcreteClass: getCode(500),\r\n CustomAttributeSchemaMustBeReferenced: getCode(501),\r\n CustomAttributeClassNotFound: getCode(502),\r\n\r\n // Enumeration Rule Codes (700-799)\r\n EnumerationTypeUnsupported: getCode(700),\r\n\r\n // Mixin Rule Codes (1100-1199)\r\n MixinAppliedToClassMustDeriveFromConstraint: getCode(1100),\r\n\r\n // Property Rule Codes (1300-1399)\r\n IncompatibleValueTypePropertyOverride: getCode(1300),\r\n IncompatibleTypePropertyOverride: getCode(1301),\r\n IncompatibleUnitPropertyOverride: getCode(1302),\r\n\r\n // Relationship Rule Codes (1500-1599)\r\n AbstractConstraintMustNarrowBaseConstraints: getCode(1500),\r\n DerivedConstraintsMustNarrowBaseConstraints: getCode(1501),\r\n ConstraintClassesDeriveFromAbstractConstraint: getCode(1502),\r\n\r\n // Relationship Constraint Rule Codes (1600-1699)\r\n AtLeastOneConstraintClassDefined: getCode(1600),\r\n AbstractConstraintMustExistWithMultipleConstraints: getCode(1601),\r\n};\r\n\r\n/**\r\n * The list of [[IDiagnostic]] implementation classes used by the EC rule implementations.\r\n * @beta\r\n */\r\nexport const Diagnostics = {\r\n /** EC-001: Required message parameters: schema name, referenced schema name */\r\n SupplementalSchemasCannotBeReferenced: createSchemaDiagnosticClass<[string, string]>(getCode(1),\r\n \"Referenced schema '{1}' of schema '{0}' is a supplemental schema. Supplemental schemas are not allowed to be referenced.\"),\r\n\r\n /** EC-002: Required message parameters: schema name, reference schema alias, first schema reference name, second schema reference name. */\r\n SchemaRefAliasMustBeUnique: createSchemaDiagnosticClass<[string, string, string, string]>(getCode(2),\r\n \"Schema '{0}' has multiple schema references ({2}, {3}) with the same alias '{1}', which is not allowed.\"),\r\n\r\n /** EC-003: Required message parameters: schema name, cycle text */\r\n ReferenceCyclesNotAllowed: createSchemaDiagnosticClass<[string, string]>(getCode(3),\r\n \"Schema '{0}' has reference cycles: {1}\"),\r\n\r\n /** EC-100: Required message parameters: childClass.FullName, baseClass.FullName */\r\n BaseClassIsSealed: createClassDiagnosticClass<[string, string]>(DiagnosticCodes.BaseClassIsSealed,\r\n \"Class '{0}' cannot derive from sealed base class '{1}'.\"),\r\n\r\n /** EC-101: Required message parameters: childClass.FullName, baseClass.FullName, baseClass.schemaItemType */\r\n BaseClassIsOfDifferentType: createClassDiagnosticClass<[string, string, string]>(DiagnosticCodes.BaseClassOfDifferentType,\r\n \"Class '{0}' cannot derive from base class '{1}' of type '{2}'.\"),\r\n\r\n /** **DEPRECATED** EC-102: Required message parameters: childClass.FullName, baseClass.FullName */\r\n AbstractClassWithNonAbstractBase: createClassDiagnosticClass<[string, string]>(DiagnosticCodes.AbstractClassWithNonAbstractBase,\r\n \"Abstract Class '{0}' cannot derive from base class '{1}' because it is not an abstract class.\"),\r\n\r\n /** EC-500: Required message parameters: CustomAttribute container name and CustomAttributeClass name. */\r\n CustomAttributeNotOfConcreteClass: createCustomAttributeContainerDiagnosticClass<[string, string]>(DiagnosticCodes.CustomAttributeNotOfConcreteClass,\r\n \"The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' which is not a concrete class.\"),\r\n\r\n /** EC-501: Required message parameters: CustomAttribute container name, CustomAttributeClass name, CustomAttributeClass Schema name. */\r\n CustomAttributeSchemaMustBeReferenced: createCustomAttributeContainerDiagnosticClass<[string, string]>(DiagnosticCodes.CustomAttributeSchemaMustBeReferenced,\r\n \"The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' whose schema is not referenced by the container's Schema.\"),\r\n\r\n /** EC-502: Required message parameters: CustomAttribute container name and CustomAttributeClass name. */\r\n CustomAttributeClassNotFound: createCustomAttributeContainerDiagnosticClass<[string, string]>(DiagnosticCodes.CustomAttributeClassNotFound,\r\n \"The CustomAttribute container '{0}' has a CustomAttribute with the class '{1}' which cannot be found.\"),\r\n\r\n /** EC-700: Required message parameters: Enumeration name */\r\n EnumerationTypeUnsupported: createSchemaItemDiagnosticClass<Enumeration, [string]>(DiagnosticCodes.EnumerationTypeUnsupported,\r\n \"Enumeration '{0}' has invalid primitive type.\"),\r\n\r\n /** EC-1100: Required message parameters: mixin class fullName, class fullName, applies to constraint class fullName */\r\n MixinAppliedToClassMustDeriveFromConstraint: createSchemaItemDiagnosticClass<EntityClass, [string, string, string]>(DiagnosticCodes.MixinAppliedToClassMustDeriveFromConstraint,\r\n \"Mixin '{0}' cannot be applied to the class '{1}' because it does not satisfy the applies to constraint '{2}'.\"),\r\n\r\n /** EC-1300: Required message parameters: childClass.FullName, property name, baseClass.FullName, base value type, child value type */\r\n IncompatibleValueTypePropertyOverride: createPropertyDiagnosticClass<[string, string, string, string, string]>(DiagnosticCodes.IncompatibleValueTypePropertyOverride,\r\n \"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}.\"),\r\n\r\n /** EC-1301: Required message parameters: childClass.FullName, property name, baseClass.FullName, base property type, child property type */\r\n IncompatibleTypePropertyOverride: createPropertyDiagnosticClass<[string, string, string, string, string]>(DiagnosticCodes.IncompatibleTypePropertyOverride,\r\n \"The ECProperty '{0}.{1}' has a base property '{2}.{1}' with a type of {3} which is incompatible with the type of {4}.\"),\r\n\r\n /** 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 */\r\n IncompatibleUnitPropertyOverride: createPropertyDiagnosticClass<[string, string, string, string, string, string, string]>(DiagnosticCodes.IncompatibleUnitPropertyOverride,\r\n \"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}'.\"),\r\n\r\n /** EC-1303: Required message parameters: property.fullName, navigation relationship.fullName */\r\n NavigationRelationshipMustBeRoot: createPropertyDiagnosticClass<[string, string]>(getCode(1303),\r\n \"The referenced relationship '{1}', used in NavigationProperty '{0}' is not the root relationship.\"),\r\n\r\n /** EC-1304: Required message parameters: property.fullName, navigation relationship.fullName */\r\n NavigationTargetMustHaveSingularMultiplicity: createPropertyDiagnosticClass<[string, string, string]>(getCode(1304),\r\n \"NavigationProperty '{0}' uses the relationship '{1}' that cannot be traversed in the '{2}' direction due to a max multiplicity greater than 1.\"),\r\n\r\n /** EC-1305: Required message parameters: property.fullName, navigation relationship.fullName */\r\n NavigationRelationshipAbstractConstraintEntityOrMixin: createPropertyDiagnosticClass<[string, string]>(getCode(1305),\r\n \"The NavigationProperty '{0}', using the relationship '{1}', points to a RelationshipClass, which is not allowed. NavigationProperties must point to an EntityClass or Mixin.\"),\r\n\r\n /** EC-1306: Required message parameters: class name, property name, navigation relationship.fullName */\r\n NavigationClassMustBeAConstraintClassOfRelationship: createPropertyDiagnosticClass<[string, string, string, string]>(getCode(1306),\r\n \"The class '{0}' of NavigationProperty '{1}' is not supported by the {3} constraint of the referenced relationship '{2}'.\"),\r\n\r\n /** EC-1500: Required message parameters: abstract constraint class name, relationship end (source/target), relationship name, base relationship name */\r\n AbstractConstraintMustNarrowBaseConstraints: createSchemaItemDiagnosticClass<RelationshipClass, [string, string, string, string]>(DiagnosticCodes.AbstractConstraintMustNarrowBaseConstraints,\r\n \"The abstract constraint class '{0}' on the {1}-Constraint of '{2}' is not supported by the base class constraint in '{3}'.\"),\r\n\r\n /** EC-1501: Required message parameters: constraint class name, relationship end (source/target), relationship name, base relationship name */\r\n DerivedConstraintsMustNarrowBaseConstraints: createSchemaItemDiagnosticClass<RelationshipClass, [string, string, string, string]>(DiagnosticCodes.DerivedConstraintsMustNarrowBaseConstraints,\r\n \"The constraint class '{0}' on the {1}-Constraint of '{2}' is not supported by the base class constraint in '{3}'.\"),\r\n\r\n /** EC-1502: Required message parameters: constraint class name, relationship end (source/target), relationship name, abstract constraint class name */\r\n ConstraintClassesDeriveFromAbstractConstraint: createSchemaItemDiagnosticClass<RelationshipClass, [string, string, string, string]>(DiagnosticCodes.ConstraintClassesDeriveFromAbstractConstraint,\r\n \"The constraint class '{0}' on the {1}-Constraint of '{2}' is not derived from the abstract constraint class '{3}'.\"),\r\n\r\n /** EC-1600: Required message parameters: relationship end (source/target), relationship name */\r\n AtLeastOneConstraintClassDefined: createRelationshipConstraintDiagnosticClass<[string, string]>(DiagnosticCodes.AtLeastOneConstraintClassDefined,\r\n \"The {0}-Constraint of '{1}' does not contain any constraint classes.\"),\r\n\r\n /** EC-1601: Required message parameters: relationship end (source/target), relationship name */\r\n AbstractConstraintMustExistWithMultipleConstraints: createRelationshipConstraintDiagnosticClass<[string, string]>(DiagnosticCodes.AbstractConstraintMustExistWithMultipleConstraints,\r\n \"The {0}-Constraint of '{1}' has multiple constraint classes which requires an abstract constraint to be defined.\"),\r\n};\r\n\r\n/**\r\n * All schema validation rules that fall under the category of ECObjects.\r\n * @beta\r\n */\r\nexport const ECRuleSet: IRuleSet = {\r\n name: ruleSetName,\r\n\r\n schemaRules: [\r\n validateSchemaReferences,\r\n ],\r\n classRules: [\r\n baseClassIsSealed,\r\n baseClassIsOfDifferentType,\r\n ],\r\n propertyRules: [\r\n incompatibleValueTypePropertyOverride,\r\n incompatibleTypePropertyOverride,\r\n incompatibleUnitPropertyOverride,\r\n validateNavigationProperty,\r\n ],\r\n relationshipRules: [\r\n abstractConstraintMustNarrowBaseConstraints,\r\n constraintClassesDeriveFromAbstractConstraint,\r\n derivedConstraintsMustNarrowBaseConstraints,\r\n ],\r\n relationshipConstraintRules: [\r\n atLeastOneConstraintClassDefined,\r\n abstractConstraintMustExistWithMultipleConstraints,\r\n ],\r\n enumerationRules: [\r\n enumerationTypeUnsupported,\r\n ],\r\n entityClassRules: [\r\n mixinAppliedToClassMustDeriveFromConstraint,\r\n ],\r\n customAttributeInstanceRules: [\r\n validateCustomAttributeInstance,\r\n ],\r\n};\r\n\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n\r\n/**\r\n * Validates schema references against multiple EC rules.\r\n * @param schema The schema to validate.\r\n * @internal\r\n */\r\nexport async function* validateSchemaReferences(schema: Schema): AsyncIterable<SchemaDiagnostic<any[]>> {\r\n yield* validateSchemaReferencesSync(schema);\r\n}\r\n\r\n/**\r\n * Validates schema references against multiple EC rules.\r\n * @param schema The schema to validate.\r\n * @internal\r\n */\r\nexport function* validateSchemaReferencesSync(schema: Schema): Iterable<SchemaDiagnostic<any[]>> {\r\n const aliases = new Map();\r\n for (const schemaRef of schema.references) {\r\n if (schemaRef.customAttributes && schemaRef.customAttributes.has(\"CoreCustomAttributes.SupplementalSchema\"))\r\n yield new Diagnostics.SupplementalSchemasCannotBeReferenced(schema, [schema.name, schemaRef.name]);\r\n\r\n if (schema.schemaKey.matches(schemaRef.schemaKey))\r\n yield new Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, `${schema.name} --> ${schemaRef.name}`]);\r\n\r\n if (aliases.has(schemaRef.alias)) {\r\n const currentRef = aliases.get(schemaRef.alias);\r\n yield new Diagnostics.SchemaRefAliasMustBeUnique(schema, [schema.name, schemaRef.alias, currentRef.name, schemaRef.name]);\r\n } else {\r\n aliases.set(schemaRef.alias, schemaRef);\r\n }\r\n }\r\n\r\n const graph = SchemaGraph.generateGraphSync(schema);\r\n const cycles = graph.detectCycles();\r\n if (cycles) {\r\n const result = cycles.map((cycle) => `${cycle.schema.schemaKey.name} --> ${cycle.refSchema.schemaKey.name}`).join(\", \");\r\n yield new Diagnostics.ReferenceCyclesNotAllowed(schema, [schema.name, result]);\r\n }\r\n}\r\n/**\r\n * EC Rule: Sealed classes cannot be a base class.\r\n * @internal\r\n */\r\nexport async function* baseClassIsSealed(ecClass: AnyClass): AsyncIterable<ClassDiagnostic<any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseClass = await ecClass.baseClass;\r\n // return if rule passed\r\n if (baseClass.modifier !== ECClassModifier.Sealed)\r\n return;\r\n\r\n yield new Diagnostics.BaseClassIsSealed(ecClass, [ecClass.fullName, baseClass.fullName]);\r\n}\r\n\r\n/**\r\n * EC Rule: Base and child class must be of the same type (i.e. Entity, Mixin, Relationship, etc.)\r\n * @internal\r\n */\r\nexport async function* baseClassIsOfDifferentType(ecClass: AnyClass): AsyncIterable<ClassDiagnostic<any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseClass = await ecClass.baseClass;\r\n // return if rule passed\r\n if (baseClass.schemaItemType === ecClass.schemaItemType)\r\n return;\r\n\r\n const itemType = baseClass.schemaItemType;\r\n yield new Diagnostics.BaseClassIsOfDifferentType(ecClass, [ecClass.fullName, baseClass.fullName, itemType]);\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a class primitive property, the child and base property must be of the same type (string, number, etc...).\r\n * @internal\r\n*/\r\nexport async function* incompatibleValueTypePropertyOverride(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.class.baseClass)\r\n return;\r\n\r\n const primitiveType = getPrimitiveType(property);\r\n if (!primitiveType)\r\n return;\r\n\r\n async function callback(baseClass: ECClass): Promise<PropertyDiagnostic<any[]> | undefined> {\r\n const baseProperty = await baseClass.getProperty(property.name);\r\n if (!baseProperty)\r\n return;\r\n\r\n // Other rules will catch this if false, but we need to make sure\r\n // types match for this rule to be valid.\r\n if (!propertyTypesMatch(property, baseProperty))\r\n return;\r\n\r\n const baseType = getPrimitiveType(baseProperty);\r\n\r\n // Return if rule passed\r\n if (!baseType || primitiveType === baseType)\r\n return;\r\n\r\n return new Diagnostics.IncompatibleValueTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, primitiveTypeToString(baseType), primitiveTypeToString(primitiveType!)]);\r\n }\r\n\r\n for await (const baseClass of property.class.getAllBaseClasses()) {\r\n const result = await callback(baseClass);\r\n if (result)\r\n yield result;\r\n }\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a class property, the child and base property must be of the same property type (primitive, struct, enumeration, etc...).\r\n * @internal\r\n */\r\nexport async function* incompatibleTypePropertyOverride(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.class.baseClass)\r\n return;\r\n\r\n async function callback(baseClass: ECClass): Promise<PropertyDiagnostic<any[]> | undefined> {\r\n const baseProperty = await baseClass.getProperty(property.name);\r\n if (!baseProperty)\r\n return;\r\n\r\n // Return if rule passed\r\n if (propertyTypesMatch(property, baseProperty))\r\n return;\r\n\r\n return new Diagnostics.IncompatibleTypePropertyOverride(property, [property.class.fullName, property.name, baseClass.fullName, baseProperty.constructor.name, property.constructor.name]);\r\n }\r\n\r\n for await (const baseClass of property.class.getAllBaseClasses()) {\r\n const result = await callback(baseClass);\r\n if (result)\r\n yield result;\r\n }\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a kindOfQuantity property, the child and base property units must be the same.\r\n * @internal\r\n */\r\nexport async function* incompatibleUnitPropertyOverride(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.kindOfQuantity || !property.class.baseClass)\r\n return;\r\n\r\n async function callback(baseClass: ECClass): Promise<PropertyDiagnostic<any[]> | undefined> {\r\n const baseProperty = await baseClass.getProperty(property.name);\r\n if (!baseProperty || !baseProperty.kindOfQuantity)\r\n return;\r\n\r\n // Other rules will catch this if false, but we need to make sure\r\n // types match for this rule to be valid.\r\n if (!propertyTypesMatch(property, baseProperty))\r\n return;\r\n\r\n const koq = await property.kindOfQuantity;\r\n const baseKoq = await baseProperty.kindOfQuantity;\r\n if (!koq || !baseKoq)\r\n return;\r\n\r\n const unit = await koq.persistenceUnit;\r\n const baseUnit = await baseKoq.persistenceUnit;\r\n\r\n if (!unit || !baseUnit)\r\n return;\r\n\r\n // return if rule passed\r\n if (unit.key.matches(baseUnit.key))\r\n return;\r\n\r\n return new Diagnostics.IncompatibleUnitPropertyOverride(property, [\r\n property.class.fullName,\r\n property.name,\r\n baseClass.fullName,\r\n baseKoq.fullName,\r\n baseUnit.fullName,\r\n unit.fullName,\r\n koq.fullName,\r\n ]);\r\n }\r\n\r\n for await (const baseClass of property.class.getAllBaseClasses()) {\r\n const result = await callback(baseClass);\r\n if (result)\r\n yield result;\r\n }\r\n}\r\n\r\n/**\r\n * Validates Navigation Properties. EC Rules: 1303, 1304\r\n * @internal\r\n */\r\nexport async function* validateNavigationProperty(property: AnyProperty): AsyncIterable<PropertyDiagnostic<any[]>> {\r\n if (!property.isNavigation())\r\n return;\r\n\r\n const navProp = property;\r\n const relationship = await navProp.relationshipClass;\r\n\r\n if (relationship.baseClass)\r\n yield new Diagnostics.NavigationRelationshipMustBeRoot(property, [property.fullName, relationship.fullName]);\r\n\r\n let thisConstraint: RelationshipConstraint;\r\n let thatConstraint: RelationshipConstraint;\r\n let navigationClassSide: string;\r\n if (navProp.direction === StrengthDirection.Forward) {\r\n thisConstraint = relationship.source;\r\n thatConstraint = relationship.target;\r\n navigationClassSide = \"source\";\r\n } else {\r\n thisConstraint = relationship.target;\r\n thatConstraint = relationship.source;\r\n navigationClassSide = \"target\";\r\n }\r\n\r\n const thatAbstractConstraint = await thatConstraint.abstractConstraint;\r\n if (thatAbstractConstraint && thatAbstractConstraint.schemaItemType === SchemaItemType.RelationshipClass) {\r\n yield new Diagnostics.NavigationRelationshipAbstractConstraintEntityOrMixin(property, [property.fullName, relationship.fullName]);\r\n }\r\n\r\n const isClassSupported = async (ecClass: ECClass, propertyName: string, constraintName: string): Promise<boolean> => {\r\n if (constraintName === ecClass.fullName && undefined !== await ecClass.getProperty(propertyName))\r\n return true;\r\n\r\n const inheritedProp = await ecClass.getInheritedProperty(propertyName);\r\n if (inheritedProp && constraintName === inheritedProp.class.fullName)\r\n return true;\r\n\r\n const baseClass = await ecClass.baseClass;\r\n if (!baseClass)\r\n return false;\r\n\r\n return isClassSupported(baseClass, propertyName, constraintName);\r\n };\r\n\r\n let classSupported = false;\r\n if (thisConstraint.constraintClasses) {\r\n for (const constraintClass of thisConstraint.constraintClasses) {\r\n classSupported = await isClassSupported(property.class, property.name, constraintClass.fullName);\r\n if (classSupported)\r\n break;\r\n }\r\n }\r\n\r\n if (!classSupported)\r\n yield new Diagnostics.NavigationClassMustBeAConstraintClassOfRelationship(property, [property.class.name, property.name, relationship.fullName, navigationClassSide]);\r\n\r\n if (thatConstraint.multiplicity === RelationshipMultiplicity.oneMany || thatConstraint.multiplicity === RelationshipMultiplicity.zeroMany) {\r\n const direction = strengthDirectionToString(navProp.direction);\r\n yield new Diagnostics.NavigationTargetMustHaveSingularMultiplicity(property, [property.fullName, relationship.fullName, direction]);\r\n }\r\n\r\n return;\r\n}\r\n\r\n/**\r\n * Validates a Relationship class and yields EC-1500, EC-1501, and EC-1502 rule violations.\r\n * @internal\r\n */\r\nexport async function* validateRelationship(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n yield* abstractConstraintMustNarrowBaseConstraints(ecClass);\r\n yield* derivedConstraintsMustNarrowBaseConstraints(ecClass);\r\n yield* constraintClassesDeriveFromAbstractConstraint(ecClass);\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a RelationshipClass, the derived abstract constraint must narrow the base constraint classes.\r\n * @internal\r\n */\r\nexport async function* abstractConstraintMustNarrowBaseConstraints(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseRelationship = await ecClass.baseClass as RelationshipClass;\r\n\r\n const sourceResult = await applyAbstractConstraintMustNarrowBaseConstraints(ecClass, ecClass.source, baseRelationship);\r\n if (sourceResult)\r\n yield sourceResult;\r\n const targetResult = await applyAbstractConstraintMustNarrowBaseConstraints(ecClass, ecClass.target, baseRelationship);\r\n if (targetResult)\r\n yield targetResult;\r\n}\r\n\r\n/**\r\n * EC Rule: When overriding a RelationshipClass, derived constraint classes must narrow base constraint classes.\r\n * @internal\r\n */\r\nexport async function* derivedConstraintsMustNarrowBaseConstraints(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n if (!ecClass.baseClass)\r\n return;\r\n\r\n const baseRelationship = await ecClass.baseClass as RelationshipClass;\r\n\r\n const sourceResult = await applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, ecClass.source, baseRelationship);\r\n if (sourceResult)\r\n yield sourceResult;\r\n const targetResult = await applyDerivedConstraintsMustNarrowBaseConstraints(ecClass, ecClass.target, baseRelationship);\r\n if (targetResult)\r\n yield targetResult;\r\n}\r\n\r\n/**\r\n * EC Rule: All constraint classes must have a common base class specified in the abstract constraint.\r\n * @internal\r\n */\r\nexport async function* constraintClassesDeriveFromAbstractConstraint(ecClass: RelationshipClass): AsyncIterable<SchemaItemDiagnostic<RelationshipClass, any[]>> {\r\n const sourceResult = await applyConstraintClassesDeriveFromAbstractConstraint(ecClass, ecClass.source);\r\n if (sourceResult)\r\n yield sourceResult;\r\n const targetResult = await applyConstraintClassesDeriveFromAbstractConstraint(ecClass, ecClass.target);\r\n if (targetResult)\r\n yield targetResult;\r\n}\r\n\r\n/**\r\n * Validates a RelationshipConstraint and yields EC-1600 and EC-1601 rule violations.\r\n * @internal\r\n */\r\nexport async function* validateRelationshipConstraint(constraint: RelationshipConstraint): AsyncIterable<RelationshipConstraintDiagnostic<any[]>> {\r\n yield* atLeastOneConstraintClassDefined(constraint);\r\n yield* abstractConstraintMustExistWithMultipleConstraints(constraint);\r\n}\r\n\r\n/**\r\n * EC Rule: At least on concrete constraint class must be defined in the list of constraint classes.\r\n * @internal\r\n */\r\nexport async function* atLeastOneConstraintClassDefined(constraint: RelationshipConstraint): AsyncIterable<RelationshipConstraintDiagnostic<any[]>> {\r\n if (!constraint.constraintClasses || constraint.constraintClasses.length === 0) {\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n yield new Diagnostics.AtLeastOneConstraintClassDefined(constraint, [constraintType, constraint.relationshipClass.fullName]);\r\n }\r\n}\r\n\r\n/**\r\n * EC Rule: If multiple constraints exist, an abstract constraint must be defined.\r\n * @internal\r\n */\r\nexport async function* abstractConstraintMustExistWithMultipleConstraints(constraint: RelationshipConstraint): AsyncIterable<RelationshipConstraintDiagnostic<any[]>> {\r\n if (!constraint.constraintClasses || constraint.constraintClasses.length <= 1) {\r\n return;\r\n }\r\n\r\n const abstractConstraint = await getAbstractConstraint(constraint);\r\n if (abstractConstraint)\r\n return;\r\n\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n yield new Diagnostics.AbstractConstraintMustExistWithMultipleConstraints(constraint, [constraintType, constraint.relationshipClass.fullName]);\r\n}\r\n\r\nfunction propertyTypesMatch(propertyA: Property, propertyB: Property) {\r\n return propertyA.constructor.name === propertyB.constructor.name;\r\n}\r\n\r\nfunction getPrimitiveType(property: Property): PrimitiveType | undefined {\r\n if (property.isPrimitive())\r\n return (property as PrimitiveProperty).primitiveType;\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * EC Rule: Enumeration type must be a string or integer\r\n * @internal\r\n */\r\nexport async function* enumerationTypeUnsupported(enumeration: Enumeration): AsyncIterable<SchemaItemDiagnostic<Enumeration, any[]>> {\r\n const type = enumeration.type;\r\n if (type === PrimitiveType.Integer || type === PrimitiveType.String)\r\n return;\r\n\r\n yield new Diagnostics.EnumerationTypeUnsupported(enumeration, [enumeration.fullName]);\r\n}\r\n\r\n/**\r\n * EC Rule: Mixin applied to class must derived from the Mixin appliesTo constraint.\r\n * @internal\r\n */\r\nexport async function* mixinAppliedToClassMustDeriveFromConstraint(entityClass: EntityClass): AsyncIterable<SchemaItemDiagnostic<EntityClass, any[]>> {\r\n for (const lazyMixin of entityClass.mixins) {\r\n const mixin = await lazyMixin;\r\n if (!mixin.appliesTo)\r\n continue;\r\n\r\n if (!await entityClass.is(await mixin.appliesTo))\r\n yield new Diagnostics.MixinAppliedToClassMustDeriveFromConstraint(entityClass, [mixin.fullName, entityClass.fullName, mixin.appliesTo.fullName]);\r\n }\r\n\r\n return;\r\n}\r\n\r\n/**\r\n * Validates a custom attribute instance and yields EC-500, EC-501, and EC-502 rule violations.\r\n * @internal\r\n */\r\nexport async function* validateCustomAttributeInstance(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n yield* customAttributeNotOfConcreteClass(container, customAttribute);\r\n yield* customAttributeSchemaMustBeReferenced(container, customAttribute);\r\n yield* customAttributeClassMustExist(container, customAttribute);\r\n}\r\n\r\n/** EC Rule: CustomAttribute instance must be of a concrete CustomAttributeClass. */\r\nasync function* customAttributeNotOfConcreteClass(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n const schema = container.schema;\r\n const caClass = await schema.lookupItem(customAttribute.className) as ECClass;\r\n if (!caClass)\r\n return;\r\n\r\n if (caClass.modifier !== ECClassModifier.Abstract)\r\n return;\r\n\r\n yield new Diagnostics.CustomAttributeNotOfConcreteClass(container, [container.fullName, caClass.fullName]);\r\n}\r\n\r\n/** EC Rule: CustomAttribute Schema must be referenced by the container's Schema. */\r\nasync function* customAttributeSchemaMustBeReferenced(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n const schema = container.schema;\r\n const nameParts = customAttribute.className.split(\".\");\r\n if (nameParts.length === 1 || nameParts[0] === schema.name)\r\n return;\r\n\r\n if (schema.references.some((s) => s.name === nameParts[0]))\r\n return;\r\n\r\n yield new Diagnostics.CustomAttributeSchemaMustBeReferenced(container, [container.fullName, customAttribute.className]);\r\n}\r\n\r\n/** EC Rule: CustomAttribute instance class must exist. */\r\nasync function* customAttributeClassMustExist(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): AsyncIterable<CustomAttributeContainerDiagnostic<any[]>> {\r\n const schema = container.schema;\r\n const caClass = await schema.lookupItem(customAttribute.className) as ECClass;\r\n if (!caClass)\r\n yield new Diagnostics.CustomAttributeClassNotFound(container, [container.fullName, customAttribute.className]);\r\n}\r\n\r\nasync function applyAbstractConstraintMustNarrowBaseConstraints(ecClass: RelationshipClass, constraint: RelationshipConstraint, baseRelationship: RelationshipClass): Promise<SchemaItemDiagnostic<RelationshipClass, any[]> | undefined> {\r\n const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;\r\n const abstractConstraint = await constraint.abstractConstraint;\r\n if (!abstractConstraint)\r\n return;\r\n\r\n if (await baseConstraint.supportsClass(abstractConstraint))\r\n return;\r\n\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.AbstractConstraintMustNarrowBaseConstraints(ecClass, [abstractConstraint.fullName, constraintType, constraint.relationshipClass.fullName, baseRelationship.fullName]);\r\n}\r\n\r\nasync function applyDerivedConstraintsMustNarrowBaseConstraints(ecClass: RelationshipClass, constraint: RelationshipConstraint, baseRelationship: RelationshipClass): Promise<SchemaItemDiagnostic<RelationshipClass, any[]> | undefined> {\r\n const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;\r\n\r\n if (!constraint.constraintClasses)\r\n return;\r\n\r\n for (const classPromise of constraint.constraintClasses) {\r\n const constraintClass = await classPromise;\r\n\r\n if (await baseConstraint.supportsClass(constraintClass))\r\n continue;\r\n\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.DerivedConstraintsMustNarrowBaseConstraints(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, baseRelationship.fullName]);\r\n }\r\n\r\n return;\r\n}\r\n\r\nasync function applyConstraintClassesDeriveFromAbstractConstraint(ecClass: RelationshipClass, constraint: RelationshipConstraint): Promise<SchemaItemDiagnostic<RelationshipClass, any[]> | undefined> {\r\n const abstractConstraint = await getAbstractConstraint(constraint);\r\n if (!abstractConstraint)\r\n return;\r\n\r\n if (!constraint.constraintClasses)\r\n return;\r\n\r\n for (const classPromise of constraint.constraintClasses) {\r\n const constraintClass = await classPromise;\r\n\r\n if (constraintClass.schemaItemType === SchemaItemType.Mixin && abstractConstraint.schemaItemType === SchemaItemType.EntityClass) {\r\n if (!await (constraintClass).applicableTo(abstractConstraint as EntityClass)) {\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.ConstraintClassesDeriveFromAbstractConstraint(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, abstractConstraint.fullName]);\r\n }\r\n continue;\r\n }\r\n\r\n if (!await constraintClass.is(abstractConstraint)) {\r\n const constraintType = constraint.isSource ? ECStringConstants.RELATIONSHIP_END_SOURCE : ECStringConstants.RELATIONSHIP_END_TARGET;\r\n return new Diagnostics.ConstraintClassesDeriveFromAbstractConstraint(ecClass, [constraintClass.fullName, constraintType, constraint.relationshipClass.fullName, abstractConstraint.fullName]);\r\n }\r\n }\r\n\r\n return;\r\n}\r\n\r\nasync function getAbstractConstraint(constraint: RelationshipConstraint): Promise<ECClass | undefined> {\r\n const abstractConstraint = await constraint.abstractConstraint;\r\n if (abstractConstraint)\r\n return abstractConstraint;\r\n\r\n const baseRelationship = await constraint.relationshipClass.baseClass as RelationshipClass;\r\n if (!baseRelationship)\r\n return;\r\n\r\n const baseConstraint = constraint.isSource ? baseRelationship.source : baseRelationship.target;\r\n\r\n return getAbstractConstraint(baseConstraint);\r\n}\r\n"]}
|