@itwin/ecschema-editing 3.4.0-dev.9 → 3.5.0-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/lib/cjs/Editing/Constants.d.ts +20 -20
  3. package/lib/cjs/Editing/Constants.d.ts.map +1 -1
  4. package/lib/cjs/Editing/Constants.js +60 -64
  5. package/lib/cjs/Editing/Constants.js.map +1 -1
  6. package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
  7. package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
  8. package/lib/cjs/Editing/CustomAttributes.js +59 -62
  9. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  10. package/lib/cjs/Editing/ECClasses.d.ts +54 -54
  11. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  12. package/lib/cjs/Editing/ECClasses.js +269 -269
  13. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  14. package/lib/cjs/Editing/Editor.d.ts +112 -112
  15. package/lib/cjs/Editing/Editor.d.ts.map +1 -1
  16. package/lib/cjs/Editing/Editor.js +166 -166
  17. package/lib/cjs/Editing/Editor.js.map +1 -1
  18. package/lib/cjs/Editing/Entities.d.ts +25 -25
  19. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  20. package/lib/cjs/Editing/Entities.js +116 -124
  21. package/lib/cjs/Editing/Entities.js.map +1 -1
  22. package/lib/cjs/Editing/Enumerations.d.ts +21 -21
  23. package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
  24. package/lib/cjs/Editing/Enumerations.js +66 -76
  25. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  26. package/lib/cjs/Editing/Formats.d.ts +21 -21
  27. package/lib/cjs/Editing/Formats.d.ts.map +1 -1
  28. package/lib/cjs/Editing/Formats.js +61 -63
  29. package/lib/cjs/Editing/Formats.js.map +1 -1
  30. package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
  31. package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
  32. package/lib/cjs/Editing/InvertedUnits.js +82 -85
  33. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  34. package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
  35. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  36. package/lib/cjs/Editing/KindOfQuantities.js +78 -79
  37. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  38. package/lib/cjs/Editing/Mixins.d.ts +22 -22
  39. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  40. package/lib/cjs/Editing/Mixins.js +84 -88
  41. package/lib/cjs/Editing/Mixins.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
  43. package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
  44. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  45. package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
  46. package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
  47. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  48. package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
  49. package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
  50. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
  52. package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
  53. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  54. package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
  55. package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
  56. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  57. package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
  58. package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
  59. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  60. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
  61. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
  62. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  63. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
  64. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
  65. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  66. package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
  67. package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
  68. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  69. package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
  70. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
  71. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  72. package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
  73. package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
  74. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  75. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
  76. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
  77. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  78. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
  79. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
  80. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  81. package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
  82. package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
  83. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  84. package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
  85. package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
  86. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  87. package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
  88. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
  89. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  90. package/lib/cjs/Editing/Phenomena.d.ts +15 -15
  91. package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
  92. package/lib/cjs/Editing/Phenomena.js +44 -47
  93. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  94. package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
  95. package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
  96. package/lib/cjs/Editing/PropertyCategories.js +51 -53
  97. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  98. package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
  99. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  100. package/lib/cjs/Editing/RelationshipClasses.js +68 -69
  101. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  102. package/lib/cjs/Editing/Structs.d.ts +19 -19
  103. package/lib/cjs/Editing/Structs.d.ts.map +1 -1
  104. package/lib/cjs/Editing/Structs.js +57 -60
  105. package/lib/cjs/Editing/Structs.js.map +1 -1
  106. package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
  107. package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
  108. package/lib/cjs/Editing/UnitSystems.js +41 -43
  109. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  110. package/lib/cjs/Editing/Units.d.ts +15 -15
  111. package/lib/cjs/Editing/Units.d.ts.map +1 -1
  112. package/lib/cjs/Editing/Units.js +58 -61
  113. package/lib/cjs/Editing/Units.js.map +1 -1
  114. package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
  115. package/lib/cjs/Validation/Diagnostic.js +310 -310
  116. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  117. package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
  118. package/lib/cjs/Validation/DiagnosticReporter.d.ts.map +1 -1
  119. package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
  120. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  121. package/lib/cjs/Validation/ECRules.d.ts +448 -438
  122. package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
  123. package/lib/cjs/Validation/ECRules.js +593 -583
  124. package/lib/cjs/Validation/ECRules.js.map +1 -1
  125. package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
  126. package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
  127. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  128. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -58
  129. package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
  130. package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
  131. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  132. package/lib/cjs/Validation/Rules.d.ts +64 -64
  133. package/lib/cjs/Validation/Rules.js +9 -9
  134. package/lib/cjs/Validation/Rules.js.map +1 -1
  135. package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
  136. package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
  137. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  138. package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
  139. package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
  140. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  141. package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
  142. package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
  143. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  144. package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
  145. package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
  146. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  147. package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
  148. package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
  149. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  150. package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
  151. package/lib/cjs/Validation/SchemaComparer.js +666 -666
  152. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  153. package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
  154. package/lib/cjs/Validation/SchemaValidater.js +61 -61
  155. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  156. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
  157. package/lib/cjs/Validation/SchemaValidationVisitor.d.ts.map +1 -1
  158. package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -490
  159. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  160. package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
  161. package/lib/cjs/Validation/SchemaWalker.js +51 -51
  162. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  163. package/lib/cjs/ecschema-editing.d.ts +33 -33
  164. package/lib/cjs/ecschema-editing.js +54 -54
  165. package/lib/cjs/ecschema-editing.js.map +1 -1
  166. package/package.json +11 -11
  167. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1,311 +1,311 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Diagnostic
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.diagnosticTypeToString = exports.diagnosticCategoryToString = exports.createCustomAttributeContainerDiagnosticClass = exports.createRelationshipConstraintDiagnosticClass = exports.createPropertyDiagnosticClass = exports.createClassDiagnosticClass = exports.createSchemaItemDiagnosticClass = exports.createSchemaDiagnosticClass = exports.CustomAttributeContainerDiagnostic = exports.RelationshipConstraintDiagnostic = exports.PropertyDiagnostic = exports.ClassDiagnostic = exports.SchemaItemDiagnostic = exports.SchemaDiagnostic = exports.BaseDiagnostic = exports.DiagnosticCategory = exports.DiagnosticType = void 0;
11
- /* eslint-disable @typescript-eslint/no-shadow */
12
- const formatString = (format, ...args) => {
13
- return format.replace(/{(\d+)}/g, (match, theNumber) => {
14
- return typeof args[theNumber] !== "undefined"
15
- ? args[theNumber]
16
- : match;
17
- });
18
- };
19
- /**
20
- * Defines the possible diagnostic types.
21
- * @beta
22
- */
23
- var DiagnosticType;
24
- (function (DiagnosticType) {
25
- DiagnosticType[DiagnosticType["None"] = 0] = "None";
26
- DiagnosticType[DiagnosticType["Schema"] = 1] = "Schema";
27
- DiagnosticType[DiagnosticType["SchemaItem"] = 2] = "SchemaItem";
28
- DiagnosticType[DiagnosticType["Property"] = 3] = "Property";
29
- DiagnosticType[DiagnosticType["CustomAttributeContainer"] = 4] = "CustomAttributeContainer";
30
- DiagnosticType[DiagnosticType["RelationshipConstraint"] = 5] = "RelationshipConstraint";
31
- })(DiagnosticType = exports.DiagnosticType || (exports.DiagnosticType = {}));
32
- /**
33
- * Defines the possible diagnostic categories.
34
- * @beta
35
- */
36
- var DiagnosticCategory;
37
- (function (DiagnosticCategory) {
38
- DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
39
- DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
40
- DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
41
- DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
42
- })(DiagnosticCategory = exports.DiagnosticCategory || (exports.DiagnosticCategory = {}));
43
- /**
44
- * The abstract base class for all [[IDiagnostic]] implementations.
45
- * @beta
46
- */
47
- class BaseDiagnostic {
48
- /**
49
- * Initializes a new BaseDiagnostic.
50
- * @param ecDefinition The EC object to associate with the diagnostic.
51
- * @param messageArgs The arguments used when formatting the diagnostic message.
52
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
53
- */
54
- constructor(ecDefinition, messageArgs, category = DiagnosticCategory.Error) {
55
- this.ecDefinition = ecDefinition;
56
- this.messageArgs = messageArgs;
57
- this.category = category;
58
- }
59
- }
60
- exports.BaseDiagnostic = BaseDiagnostic;
61
- /**
62
- * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.
63
- * @beta
64
- */
65
- class SchemaDiagnostic extends BaseDiagnostic {
66
- /**
67
- * Initializes a new SchemaDiagnostic.
68
- * @param ecDefinition The EC object to associate with the diagnostic.
69
- * @param messageArgs The arguments used when formatting the diagnostic message.
70
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
71
- */
72
- constructor(schema, messageArgs, category = DiagnosticCategory.Error) {
73
- super(schema, messageArgs, category);
74
- }
75
- /** Gets the schema where the diagnostic originated. */
76
- get schema() { return this.ecDefinition; }
77
- /** Gets the DiagnosticType. */
78
- get diagnosticType() { return DiagnosticType.Schema; }
79
- }
80
- exports.SchemaDiagnostic = SchemaDiagnostic;
81
- SchemaDiagnostic.diagnosticType = DiagnosticType.SchemaItem;
82
- /**
83
- * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.
84
- * @beta
85
- */
86
- class SchemaItemDiagnostic extends BaseDiagnostic {
87
- /**
88
- * Initializes a new SchemaItemDiagnostic.
89
- * @param ecDefinition The EC object to associate with the diagnostic.
90
- * @param messageArgs The arguments used when formatting the diagnostic message.
91
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
92
- */
93
- constructor(ecDefinition, messageArgs, category = DiagnosticCategory.Error) {
94
- super(ecDefinition, messageArgs, category);
95
- }
96
- /** Gets the schema where the diagnostic originated. */
97
- get schema() { return this.ecDefinition.schema; }
98
- /** Gets the DiagnosticType. */
99
- get diagnosticType() { return DiagnosticType.SchemaItem; }
100
- }
101
- exports.SchemaItemDiagnostic = SchemaItemDiagnostic;
102
- SchemaItemDiagnostic.diagnosticType = DiagnosticType.SchemaItem;
103
- /**
104
- * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.
105
- * @beta
106
- */
107
- class ClassDiagnostic extends SchemaItemDiagnostic {
108
- /**
109
- * Initializes a new ClassDiagnostic.
110
- * @param ecClass The class to associate with the diagnostic.
111
- * @param messageArgs The arguments used when formatting the diagnostic message.
112
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
113
- */
114
- constructor(ecClass, messageArgs, category = DiagnosticCategory.Error) {
115
- super(ecClass, messageArgs, category);
116
- }
117
- /** Gets the schema where the diagnostic originated. */
118
- get schema() { return this.ecDefinition.schema; }
119
- }
120
- exports.ClassDiagnostic = ClassDiagnostic;
121
- /**
122
- * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.
123
- * @beta
124
- */
125
- class PropertyDiagnostic extends BaseDiagnostic {
126
- /**
127
- * Initializes a new PropertyDiagnostic.
128
- * @param property The property to associate with the diagnostic.
129
- * @param messageArgs The arguments used when formatting the diagnostic message.
130
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
131
- */
132
- constructor(property, messageArgs, category = DiagnosticCategory.Error) {
133
- super(property, messageArgs, category);
134
- }
135
- /** Gets the schema where the diagnostic originated. */
136
- get schema() { return this.ecDefinition.schema; }
137
- /** Gets the DiagnosticType. */
138
- get diagnosticType() { return DiagnosticType.Property; }
139
- }
140
- exports.PropertyDiagnostic = PropertyDiagnostic;
141
- /**
142
- * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.
143
- * @beta
144
- */
145
- class RelationshipConstraintDiagnostic extends BaseDiagnostic {
146
- /**
147
- * Initializes a new RelationshipConstraintDiagnostic.
148
- * @param constraint The Relationship Constraint to associate with the diagnostic.
149
- * @param messageArgs The arguments used when formatting the diagnostic message.
150
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
151
- */
152
- constructor(constraint, messageArgs, category = DiagnosticCategory.Error) {
153
- super(constraint, messageArgs, category);
154
- }
155
- /** Gets the schema where the diagnostic originated. */
156
- get schema() { return this.ecDefinition.schema; }
157
- /** Gets the DiagnosticType. */
158
- get diagnosticType() { return DiagnosticType.RelationshipConstraint; }
159
- }
160
- exports.RelationshipConstraintDiagnostic = RelationshipConstraintDiagnostic;
161
- /**
162
- * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.
163
- * @beta
164
- */
165
- class CustomAttributeContainerDiagnostic extends BaseDiagnostic {
166
- /**
167
- * Initializes a new CustomAttributeContainerDiagnostic.
168
- * @param constraint The Custom Attribute Container to associate with the diagnostic.
169
- * @param messageArgs The arguments used when formatting the diagnostic message.
170
- * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
171
- */
172
- constructor(container, messageArgs, category = DiagnosticCategory.Error) {
173
- super(container, messageArgs, category);
174
- }
175
- /** Gets the schema where the diagnostic originated. */
176
- get schema() { return this.ecDefinition.schema; }
177
- /** Gets the DiagnosticType. */
178
- get diagnosticType() { return DiagnosticType.CustomAttributeContainer; }
179
- }
180
- exports.CustomAttributeContainerDiagnostic = CustomAttributeContainerDiagnostic;
181
- /**
182
- * Helper method for creating [[SchemaDiagnostic]] child classes.
183
- * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
184
- * @param messageText The message to associate with the diagnostic class.
185
- * @beta
186
- */
187
- function createSchemaDiagnosticClass(code, messageText) {
188
- var _a;
189
- validateCode(code);
190
- return _a = class extends SchemaDiagnostic {
191
- get code() { return code; }
192
- get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
193
- },
194
- _a.code = code,
195
- _a;
196
- }
197
- exports.createSchemaDiagnosticClass = createSchemaDiagnosticClass;
198
- /**
199
- * Helper method for creating [[SchemaItemDiagnostic]] child classes.
200
- * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
201
- * @param messageText The message to associate with the diagnostic class.
202
- * @beta
203
- */
204
- function createSchemaItemDiagnosticClass(code, messageText) {
205
- validateCode(code);
206
- return class extends SchemaItemDiagnostic {
207
- get code() { return code; }
208
- get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
209
- };
210
- }
211
- exports.createSchemaItemDiagnosticClass = createSchemaItemDiagnosticClass;
212
- /**
213
- * Helper method for creating [[ClassDiagnostic]] child classes.
214
- * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
215
- * @param messageText The message to associate with the diagnostic class.
216
- * @beta
217
- */
218
- function createClassDiagnosticClass(code, messageText) {
219
- validateCode(code);
220
- return class extends ClassDiagnostic {
221
- get code() { return code; }
222
- get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
223
- };
224
- }
225
- exports.createClassDiagnosticClass = createClassDiagnosticClass;
226
- /**
227
- * Helper method for creating [[PropertyDiagnostic]] child classes.
228
- * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
229
- * @param messageText The message to associate with the diagnostic class.
230
- * @beta
231
- */
232
- function createPropertyDiagnosticClass(code, messageText) {
233
- var _a;
234
- validateCode(code);
235
- return _a = class extends PropertyDiagnostic {
236
- get code() { return code; }
237
- get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
238
- },
239
- _a.code = code,
240
- _a;
241
- }
242
- exports.createPropertyDiagnosticClass = createPropertyDiagnosticClass;
243
- /**
244
- * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.
245
- * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.
246
- * @param messageText The message to associate with the diagnostic class.
247
- * @beta
248
- */
249
- function createRelationshipConstraintDiagnosticClass(code, messageText) {
250
- validateCode(code);
251
- return class extends RelationshipConstraintDiagnostic {
252
- get code() { return code; }
253
- get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
254
- };
255
- }
256
- exports.createRelationshipConstraintDiagnosticClass = createRelationshipConstraintDiagnosticClass;
257
- /**
258
- * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.
259
- * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.
260
- * @param messageText The message to associate with the diagnostic class.
261
- * @beta
262
- */
263
- function createCustomAttributeContainerDiagnosticClass(code, messageText) {
264
- validateCode(code);
265
- return class extends CustomAttributeContainerDiagnostic {
266
- get code() { return code; }
267
- get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
268
- };
269
- }
270
- exports.createCustomAttributeContainerDiagnosticClass = createCustomAttributeContainerDiagnosticClass;
271
- /** @beta */
272
- function diagnosticCategoryToString(category) {
273
- switch (category) {
274
- case DiagnosticCategory.Error:
275
- return "Error";
276
- case DiagnosticCategory.Warning:
277
- return "Warning";
278
- case DiagnosticCategory.Message:
279
- return "Message";
280
- case DiagnosticCategory.Suggestion:
281
- return "Suggestion";
282
- }
283
- }
284
- exports.diagnosticCategoryToString = diagnosticCategoryToString;
285
- /** @beta */
286
- function diagnosticTypeToString(type) {
287
- switch (type) {
288
- case DiagnosticType.CustomAttributeContainer:
289
- return "CustomAttributeContainer";
290
- case DiagnosticType.None:
291
- return "None";
292
- case DiagnosticType.Property:
293
- return "Property";
294
- case DiagnosticType.RelationshipConstraint:
295
- return "RelationshipConstraint";
296
- case DiagnosticType.Schema:
297
- return "Schema";
298
- case DiagnosticType.SchemaItem:
299
- return "SchemaItem";
300
- }
301
- }
302
- exports.diagnosticTypeToString = diagnosticTypeToString;
303
- function validateCode(code) {
304
- const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;
305
- const parts = code.split("-");
306
- if (parts.length !== 2)
307
- throw new Error(msg);
308
- if (isNaN(Number(parts[1])))
309
- throw new Error(msg);
310
- }
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Diagnostic
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.diagnosticTypeToString = exports.diagnosticCategoryToString = exports.createCustomAttributeContainerDiagnosticClass = exports.createRelationshipConstraintDiagnosticClass = exports.createPropertyDiagnosticClass = exports.createClassDiagnosticClass = exports.createSchemaItemDiagnosticClass = exports.createSchemaDiagnosticClass = exports.CustomAttributeContainerDiagnostic = exports.RelationshipConstraintDiagnostic = exports.PropertyDiagnostic = exports.ClassDiagnostic = exports.SchemaItemDiagnostic = exports.SchemaDiagnostic = exports.BaseDiagnostic = exports.DiagnosticCategory = exports.DiagnosticType = void 0;
11
+ /* eslint-disable @typescript-eslint/no-shadow */
12
+ const formatString = (format, ...args) => {
13
+ return format.replace(/{(\d+)}/g, (match, theNumber) => {
14
+ return typeof args[theNumber] !== "undefined"
15
+ ? args[theNumber]
16
+ : match;
17
+ });
18
+ };
19
+ /**
20
+ * Defines the possible diagnostic types.
21
+ * @beta
22
+ */
23
+ var DiagnosticType;
24
+ (function (DiagnosticType) {
25
+ DiagnosticType[DiagnosticType["None"] = 0] = "None";
26
+ DiagnosticType[DiagnosticType["Schema"] = 1] = "Schema";
27
+ DiagnosticType[DiagnosticType["SchemaItem"] = 2] = "SchemaItem";
28
+ DiagnosticType[DiagnosticType["Property"] = 3] = "Property";
29
+ DiagnosticType[DiagnosticType["CustomAttributeContainer"] = 4] = "CustomAttributeContainer";
30
+ DiagnosticType[DiagnosticType["RelationshipConstraint"] = 5] = "RelationshipConstraint";
31
+ })(DiagnosticType = exports.DiagnosticType || (exports.DiagnosticType = {}));
32
+ /**
33
+ * Defines the possible diagnostic categories.
34
+ * @beta
35
+ */
36
+ var DiagnosticCategory;
37
+ (function (DiagnosticCategory) {
38
+ DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
39
+ DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
40
+ DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
41
+ DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
42
+ })(DiagnosticCategory = exports.DiagnosticCategory || (exports.DiagnosticCategory = {}));
43
+ /**
44
+ * The abstract base class for all [[IDiagnostic]] implementations.
45
+ * @beta
46
+ */
47
+ class BaseDiagnostic {
48
+ /**
49
+ * Initializes a new BaseDiagnostic.
50
+ * @param ecDefinition The EC object to associate with the diagnostic.
51
+ * @param messageArgs The arguments used when formatting the diagnostic message.
52
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
53
+ */
54
+ constructor(ecDefinition, messageArgs, category = DiagnosticCategory.Error) {
55
+ this.ecDefinition = ecDefinition;
56
+ this.messageArgs = messageArgs;
57
+ this.category = category;
58
+ }
59
+ }
60
+ exports.BaseDiagnostic = BaseDiagnostic;
61
+ /**
62
+ * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.
63
+ * @beta
64
+ */
65
+ class SchemaDiagnostic extends BaseDiagnostic {
66
+ /**
67
+ * Initializes a new SchemaDiagnostic.
68
+ * @param ecDefinition The EC object to associate with the diagnostic.
69
+ * @param messageArgs The arguments used when formatting the diagnostic message.
70
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
71
+ */
72
+ constructor(schema, messageArgs, category = DiagnosticCategory.Error) {
73
+ super(schema, messageArgs, category);
74
+ }
75
+ /** Gets the schema where the diagnostic originated. */
76
+ get schema() { return this.ecDefinition; }
77
+ /** Gets the DiagnosticType. */
78
+ get diagnosticType() { return DiagnosticType.Schema; }
79
+ }
80
+ exports.SchemaDiagnostic = SchemaDiagnostic;
81
+ SchemaDiagnostic.diagnosticType = DiagnosticType.SchemaItem;
82
+ /**
83
+ * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.
84
+ * @beta
85
+ */
86
+ class SchemaItemDiagnostic extends BaseDiagnostic {
87
+ /**
88
+ * Initializes a new SchemaItemDiagnostic.
89
+ * @param ecDefinition The EC object to associate with the diagnostic.
90
+ * @param messageArgs The arguments used when formatting the diagnostic message.
91
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
92
+ */
93
+ constructor(ecDefinition, messageArgs, category = DiagnosticCategory.Error) {
94
+ super(ecDefinition, messageArgs, category);
95
+ }
96
+ /** Gets the schema where the diagnostic originated. */
97
+ get schema() { return this.ecDefinition.schema; }
98
+ /** Gets the DiagnosticType. */
99
+ get diagnosticType() { return DiagnosticType.SchemaItem; }
100
+ }
101
+ exports.SchemaItemDiagnostic = SchemaItemDiagnostic;
102
+ SchemaItemDiagnostic.diagnosticType = DiagnosticType.SchemaItem;
103
+ /**
104
+ * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.
105
+ * @beta
106
+ */
107
+ class ClassDiagnostic extends SchemaItemDiagnostic {
108
+ /**
109
+ * Initializes a new ClassDiagnostic.
110
+ * @param ecClass The class to associate with the diagnostic.
111
+ * @param messageArgs The arguments used when formatting the diagnostic message.
112
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
113
+ */
114
+ constructor(ecClass, messageArgs, category = DiagnosticCategory.Error) {
115
+ super(ecClass, messageArgs, category);
116
+ }
117
+ /** Gets the schema where the diagnostic originated. */
118
+ get schema() { return this.ecDefinition.schema; }
119
+ }
120
+ exports.ClassDiagnostic = ClassDiagnostic;
121
+ /**
122
+ * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.
123
+ * @beta
124
+ */
125
+ class PropertyDiagnostic extends BaseDiagnostic {
126
+ /**
127
+ * Initializes a new PropertyDiagnostic.
128
+ * @param property The property to associate with the diagnostic.
129
+ * @param messageArgs The arguments used when formatting the diagnostic message.
130
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
131
+ */
132
+ constructor(property, messageArgs, category = DiagnosticCategory.Error) {
133
+ super(property, messageArgs, category);
134
+ }
135
+ /** Gets the schema where the diagnostic originated. */
136
+ get schema() { return this.ecDefinition.schema; }
137
+ /** Gets the DiagnosticType. */
138
+ get diagnosticType() { return DiagnosticType.Property; }
139
+ }
140
+ exports.PropertyDiagnostic = PropertyDiagnostic;
141
+ /**
142
+ * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.
143
+ * @beta
144
+ */
145
+ class RelationshipConstraintDiagnostic extends BaseDiagnostic {
146
+ /**
147
+ * Initializes a new RelationshipConstraintDiagnostic.
148
+ * @param constraint The Relationship Constraint to associate with the diagnostic.
149
+ * @param messageArgs The arguments used when formatting the diagnostic message.
150
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
151
+ */
152
+ constructor(constraint, messageArgs, category = DiagnosticCategory.Error) {
153
+ super(constraint, messageArgs, category);
154
+ }
155
+ /** Gets the schema where the diagnostic originated. */
156
+ get schema() { return this.ecDefinition.schema; }
157
+ /** Gets the DiagnosticType. */
158
+ get diagnosticType() { return DiagnosticType.RelationshipConstraint; }
159
+ }
160
+ exports.RelationshipConstraintDiagnostic = RelationshipConstraintDiagnostic;
161
+ /**
162
+ * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.
163
+ * @beta
164
+ */
165
+ class CustomAttributeContainerDiagnostic extends BaseDiagnostic {
166
+ /**
167
+ * Initializes a new CustomAttributeContainerDiagnostic.
168
+ * @param constraint The Custom Attribute Container to associate with the diagnostic.
169
+ * @param messageArgs The arguments used when formatting the diagnostic message.
170
+ * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.
171
+ */
172
+ constructor(container, messageArgs, category = DiagnosticCategory.Error) {
173
+ super(container, messageArgs, category);
174
+ }
175
+ /** Gets the schema where the diagnostic originated. */
176
+ get schema() { return this.ecDefinition.schema; }
177
+ /** Gets the DiagnosticType. */
178
+ get diagnosticType() { return DiagnosticType.CustomAttributeContainer; }
179
+ }
180
+ exports.CustomAttributeContainerDiagnostic = CustomAttributeContainerDiagnostic;
181
+ /**
182
+ * Helper method for creating [[SchemaDiagnostic]] child classes.
183
+ * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
184
+ * @param messageText The message to associate with the diagnostic class.
185
+ * @beta
186
+ */
187
+ function createSchemaDiagnosticClass(code, messageText) {
188
+ var _a;
189
+ validateCode(code);
190
+ return _a = class extends SchemaDiagnostic {
191
+ get code() { return code; }
192
+ get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
193
+ },
194
+ _a.code = code,
195
+ _a;
196
+ }
197
+ exports.createSchemaDiagnosticClass = createSchemaDiagnosticClass;
198
+ /**
199
+ * Helper method for creating [[SchemaItemDiagnostic]] child classes.
200
+ * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
201
+ * @param messageText The message to associate with the diagnostic class.
202
+ * @beta
203
+ */
204
+ function createSchemaItemDiagnosticClass(code, messageText) {
205
+ validateCode(code);
206
+ return class extends SchemaItemDiagnostic {
207
+ get code() { return code; }
208
+ get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
209
+ };
210
+ }
211
+ exports.createSchemaItemDiagnosticClass = createSchemaItemDiagnosticClass;
212
+ /**
213
+ * Helper method for creating [[ClassDiagnostic]] child classes.
214
+ * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
215
+ * @param messageText The message to associate with the diagnostic class.
216
+ * @beta
217
+ */
218
+ function createClassDiagnosticClass(code, messageText) {
219
+ validateCode(code);
220
+ return class extends ClassDiagnostic {
221
+ get code() { return code; }
222
+ get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
223
+ };
224
+ }
225
+ exports.createClassDiagnosticClass = createClassDiagnosticClass;
226
+ /**
227
+ * Helper method for creating [[PropertyDiagnostic]] child classes.
228
+ * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.
229
+ * @param messageText The message to associate with the diagnostic class.
230
+ * @beta
231
+ */
232
+ function createPropertyDiagnosticClass(code, messageText) {
233
+ var _a;
234
+ validateCode(code);
235
+ return _a = class extends PropertyDiagnostic {
236
+ get code() { return code; }
237
+ get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
238
+ },
239
+ _a.code = code,
240
+ _a;
241
+ }
242
+ exports.createPropertyDiagnosticClass = createPropertyDiagnosticClass;
243
+ /**
244
+ * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.
245
+ * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.
246
+ * @param messageText The message to associate with the diagnostic class.
247
+ * @beta
248
+ */
249
+ function createRelationshipConstraintDiagnosticClass(code, messageText) {
250
+ validateCode(code);
251
+ return class extends RelationshipConstraintDiagnostic {
252
+ get code() { return code; }
253
+ get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
254
+ };
255
+ }
256
+ exports.createRelationshipConstraintDiagnosticClass = createRelationshipConstraintDiagnosticClass;
257
+ /**
258
+ * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.
259
+ * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.
260
+ * @param messageText The message to associate with the diagnostic class.
261
+ * @beta
262
+ */
263
+ function createCustomAttributeContainerDiagnosticClass(code, messageText) {
264
+ validateCode(code);
265
+ return class extends CustomAttributeContainerDiagnostic {
266
+ get code() { return code; }
267
+ get messageText() { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }
268
+ };
269
+ }
270
+ exports.createCustomAttributeContainerDiagnosticClass = createCustomAttributeContainerDiagnosticClass;
271
+ /** @beta */
272
+ function diagnosticCategoryToString(category) {
273
+ switch (category) {
274
+ case DiagnosticCategory.Error:
275
+ return "Error";
276
+ case DiagnosticCategory.Warning:
277
+ return "Warning";
278
+ case DiagnosticCategory.Message:
279
+ return "Message";
280
+ case DiagnosticCategory.Suggestion:
281
+ return "Suggestion";
282
+ }
283
+ }
284
+ exports.diagnosticCategoryToString = diagnosticCategoryToString;
285
+ /** @beta */
286
+ function diagnosticTypeToString(type) {
287
+ switch (type) {
288
+ case DiagnosticType.CustomAttributeContainer:
289
+ return "CustomAttributeContainer";
290
+ case DiagnosticType.None:
291
+ return "None";
292
+ case DiagnosticType.Property:
293
+ return "Property";
294
+ case DiagnosticType.RelationshipConstraint:
295
+ return "RelationshipConstraint";
296
+ case DiagnosticType.Schema:
297
+ return "Schema";
298
+ case DiagnosticType.SchemaItem:
299
+ return "SchemaItem";
300
+ }
301
+ }
302
+ exports.diagnosticTypeToString = diagnosticTypeToString;
303
+ function validateCode(code) {
304
+ const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;
305
+ const parts = code.split("-");
306
+ if (parts.length !== 2)
307
+ throw new Error(msg);
308
+ if (isNaN(Number(parts[1])))
309
+ throw new Error(msg);
310
+ }
311
311
  //# sourceMappingURL=Diagnostic.js.map