@itwin/ecschema-editing 4.10.0-dev.9 → 4.10.0

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 (155) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/cjs/Differencing/Errors.d.ts +3 -3
  3. package/lib/cjs/Differencing/Errors.d.ts.map +1 -1
  4. package/lib/cjs/Differencing/Errors.js.map +1 -1
  5. package/lib/cjs/Differencing/SchemaConflicts.d.ts +17 -15
  6. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -1
  7. package/lib/cjs/Differencing/SchemaConflicts.js +1 -0
  8. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -1
  9. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +3 -2
  10. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
  11. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +30 -11
  12. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
  13. package/lib/cjs/Differencing/SchemaDifference.d.ts +16 -5
  14. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
  15. package/lib/cjs/Differencing/SchemaDifference.js +3 -2
  16. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
  17. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts +2 -2
  18. package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
  19. package/lib/cjs/Differencing/SchemaDifferenceValidator.js +37 -44
  20. package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
  21. package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
  22. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +2 -0
  23. package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
  24. package/lib/cjs/Differencing/Utils.js +21 -22
  25. package/lib/cjs/Differencing/Utils.js.map +1 -1
  26. package/lib/cjs/Editing/Constants.js.map +1 -1
  27. package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
  28. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  29. package/lib/cjs/Editing/Editor.js.map +1 -1
  30. package/lib/cjs/Editing/Entities.js.map +1 -1
  31. package/lib/cjs/Editing/Enumerations.js.map +1 -1
  32. package/lib/cjs/Editing/Exception.d.ts.map +1 -1
  33. package/lib/cjs/Editing/Exception.js.map +1 -1
  34. package/lib/cjs/Editing/Formats.js.map +1 -1
  35. package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
  36. package/lib/cjs/Editing/KindOfQuantities.d.ts +1 -2
  37. package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
  38. package/lib/cjs/Editing/KindOfQuantities.js +2 -4
  39. package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
  40. package/lib/cjs/Editing/Mixins.js.map +1 -1
  41. package/lib/cjs/Editing/Mutable/MutableArrayProperty.js.map +1 -1
  42. package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
  43. package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
  44. package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
  45. package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
  46. package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
  47. package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
  48. package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
  49. package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
  50. package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
  51. package/lib/cjs/Editing/Mutable/MutableNavigationProperty.js.map +1 -1
  52. package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
  53. package/lib/cjs/Editing/Mutable/MutablePrimitiveOrEnumProperty.js.map +1 -1
  54. package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
  55. package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
  56. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
  57. package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
  58. package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
  59. package/lib/cjs/Editing/Mutable/MutableSchemaItem.js.map +1 -1
  60. package/lib/cjs/Editing/Mutable/MutableStructProperty.js.map +1 -1
  61. package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
  62. package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
  63. package/lib/cjs/Editing/Phenomena.js.map +1 -1
  64. package/lib/cjs/Editing/Properties.js +2 -2
  65. package/lib/cjs/Editing/Properties.js.map +1 -1
  66. package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
  67. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  68. package/lib/cjs/Editing/SchemaItems.js.map +1 -1
  69. package/lib/cjs/Editing/Structs.js.map +1 -1
  70. package/lib/cjs/Editing/UnitSystems.js.map +1 -1
  71. package/lib/cjs/Editing/Units.js.map +1 -1
  72. package/lib/cjs/Merging/ClassMerger.js +1 -2
  73. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  74. package/lib/cjs/Merging/ConstantMerger.js +2 -3
  75. package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
  76. package/lib/cjs/Merging/CustomAttributeClassMerger.js +2 -3
  77. package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -1
  78. package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
  79. package/lib/cjs/Merging/CustomAttributeMerger.js +7 -6
  80. package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
  81. package/lib/cjs/Merging/Edits/RenameEditHandler.js +4 -5
  82. package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
  83. package/lib/cjs/Merging/Edits/SchemaEdits.js.map +1 -1
  84. package/lib/cjs/Merging/Edits/SkipEditHandler.d.ts.map +1 -1
  85. package/lib/cjs/Merging/Edits/SkipEditHandler.js +6 -6
  86. package/lib/cjs/Merging/Edits/SkipEditHandler.js.map +1 -1
  87. package/lib/cjs/Merging/EntityClassMerger.js +3 -4
  88. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  89. package/lib/cjs/Merging/EnumerationMerger.js +2 -3
  90. package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
  91. package/lib/cjs/Merging/EnumeratorMerger.js +2 -3
  92. package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -1
  93. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +7 -2
  94. package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
  95. package/lib/cjs/Merging/KindOfQuantityMerger.js +38 -17
  96. package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
  97. package/lib/cjs/Merging/MixinMerger.js +2 -3
  98. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  99. package/lib/cjs/Merging/PhenomenonMerger.js +2 -3
  100. package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
  101. package/lib/cjs/Merging/PropertyCategoryMerger.js +2 -3
  102. package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
  103. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
  104. package/lib/cjs/Merging/PropertyMerger.js +9 -29
  105. package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
  106. package/lib/cjs/Merging/RelationshipClassMerger.js +4 -5
  107. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
  108. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  109. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +6 -1
  110. package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -1
  111. package/lib/cjs/Merging/SchemaMergingVisitor.js +9 -0
  112. package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -1
  113. package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -1
  114. package/lib/cjs/Merging/SchemaMergingWalker.js +1 -0
  115. package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -1
  116. package/lib/cjs/Merging/SchemaReferenceMerger.js +2 -3
  117. package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
  118. package/lib/cjs/Merging/StructClassMerger.js +2 -3
  119. package/lib/cjs/Merging/StructClassMerger.js.map +1 -1
  120. package/lib/cjs/Merging/UnitSystemMerger.js +2 -3
  121. package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
  122. package/lib/cjs/Merging/Utils.d.ts +6 -1
  123. package/lib/cjs/Merging/Utils.d.ts.map +1 -1
  124. package/lib/cjs/Merging/Utils.js +26 -4
  125. package/lib/cjs/Merging/Utils.js.map +1 -1
  126. package/lib/cjs/Validation/Diagnostic.d.ts +2 -2
  127. package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
  128. package/lib/cjs/Validation/Diagnostic.js +9 -9
  129. package/lib/cjs/Validation/Diagnostic.js.map +1 -1
  130. package/lib/cjs/Validation/DiagnosticReporter.js +1 -1
  131. package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
  132. package/lib/cjs/Validation/ECRules.js +19 -19
  133. package/lib/cjs/Validation/ECRules.js.map +1 -1
  134. package/lib/cjs/Validation/LoggingDiagnosticReporter.js.map +1 -1
  135. package/lib/cjs/Validation/RuleSuppressionSet.d.ts +2 -2
  136. package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
  137. package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
  138. package/lib/cjs/Validation/Rules.d.ts +1 -1
  139. package/lib/cjs/Validation/Rules.d.ts.map +1 -1
  140. package/lib/cjs/Validation/Rules.js.map +1 -1
  141. package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
  142. package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
  143. package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
  144. package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
  145. package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
  146. package/lib/cjs/Validation/SchemaComparer.js +6 -6
  147. package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
  148. package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
  149. package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
  150. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  151. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  152. package/lib/cjs/ecschema-editing.js +0 -1
  153. package/lib/cjs/ecschema-editing.js.map +1 -1
  154. package/package.json +13 -13
  155. package/public/locales/en/ECSchemaEditing.json +26 -26
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAND,sCAMC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAPD,4CAOC","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\nimport type { UnitSystemDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new UnitSystem into the target schema.\r\n * @internal\r\n */\r\nexport async function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference) {\r\n await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing UnitSystem in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey) {\r\n if(change.difference.label !== undefined) {\r\n await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.unitSystems.setDescription(itemKey, change.difference.description);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":";;AAYA,sCAMC;AAMD,4CAOC;AAvBD;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { UnitSystemDifference } from \"../Differencing/SchemaDifference\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new UnitSystem into the target schema.\n * @internal\n */\nexport async function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference) {\n await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n });\n}\n\n/**\n * Merges differences to an existing UnitSystem in the target schema.\n * @internal\n */\nexport async function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey) {\n if(change.difference.label !== undefined) {\n await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.unitSystems.setDescription(itemKey, change.difference.description);\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
+ import { ECClasses } from "../Editing/ECClasses";
1
2
  import type { SchemaMergeContext } from "./SchemaMerger";
2
- import { SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
3
+ import { ECClass, SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
3
4
  /**
4
5
  * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
5
6
  * @internal
@@ -15,4 +16,8 @@ export declare function updateSchemaItemKey(context: SchemaMergeContext, referen
15
16
  * @internal
16
17
  */
17
18
  export declare function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string): Promise<SchemaItem>;
19
+ /**
20
+ * @internal
21
+ */
22
+ export declare function getClassEditor(context: SchemaMergeContext, ecClass: ECClass | SchemaItemKey): Promise<ECClasses>;
18
23
  //# sourceMappingURL=Utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAkD,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAErH;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAG5F;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,0BAYvF;AAgBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG"}
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAkD,UAAU,EAAE,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAE9I;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAG5F;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,0BAYvF;AAgBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAmBtH"}
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.locateSchemaItem = exports.updateSchemaItemKey = exports.updateSchemaItemFullName = void 0;
3
+ exports.updateSchemaItemFullName = updateSchemaItemFullName;
4
+ exports.updateSchemaItemKey = updateSchemaItemKey;
5
+ exports.locateSchemaItem = locateSchemaItem;
6
+ exports.getClassEditor = getClassEditor;
4
7
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
5
8
  /**
6
9
  * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
@@ -10,7 +13,6 @@ async function updateSchemaItemFullName(context, reference) {
10
13
  const schemaItemKey = await updateSchemaItemKey(context, reference);
11
14
  return schemaItemKey.fullName;
12
15
  }
13
- exports.updateSchemaItemFullName = updateSchemaItemFullName;
14
16
  /**
15
17
  * Updates the given reference if it refers to a SchemaItem in the source Schema and
16
18
  * returns a SchemaItemKey. If any other schema is referred the reference is not change.
@@ -27,7 +29,6 @@ async function updateSchemaItemKey(context, reference) {
27
29
  }
28
30
  throw new Error(`Cannot locate referenced schema item ${reference}`);
29
31
  }
30
- exports.updateSchemaItemKey = updateSchemaItemKey;
31
32
  /**
32
33
  * To support case insensitivity for schema items, the given key is checked if there
33
34
  * exists an item for it.
@@ -52,5 +53,26 @@ async function locateSchemaItem(context, itemName, schemaType) {
52
53
  }
53
54
  return schemaItem;
54
55
  }
55
- exports.locateSchemaItem = locateSchemaItem;
56
+ /**
57
+ * @internal
58
+ */
59
+ async function getClassEditor(context, ecClass) {
60
+ const schemaItemType = ecschema_metadata_1.ECClass.isECClass(ecClass)
61
+ ? ecClass.schemaItemType
62
+ : (await context.editor.schemaContext.getSchemaItem(ecClass))?.schemaItemType;
63
+ switch (schemaItemType) {
64
+ case ecschema_metadata_1.SchemaItemType.EntityClass:
65
+ return context.editor.entities;
66
+ case ecschema_metadata_1.SchemaItemType.Mixin:
67
+ return context.editor.mixins;
68
+ case ecschema_metadata_1.SchemaItemType.StructClass:
69
+ return context.editor.structs;
70
+ case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
71
+ return context.editor.customAttributes;
72
+ case ecschema_metadata_1.SchemaItemType.RelationshipClass:
73
+ return context.editor.relationships;
74
+ default:
75
+ throw new Error("SchemaItemType not supported");
76
+ }
77
+ }
56
78
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":";;;AAKA,gEAAqH;AAErH;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,SAAiB;IAC3F,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChC,CAAC;AAHD,4DAGC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,SAAiB;IACtF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnE,IAAI,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,OAAO,oBAAoB,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D,4CAQC","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\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECObjectsError, ECObjectsStatus, SchemaContext, SchemaItem, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\r\n * @internal\r\n */\r\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\r\n const schemaItemKey = await updateSchemaItemKey(context, reference);\r\n return schemaItemKey.fullName;\r\n}\r\n\r\n/**\r\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\r\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\r\n * @internal\r\n */\r\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\r\n if (context.sourceSchemaKey.compareByName(schemaName)) {\r\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, context.targetSchemaKey));\r\n }\r\n\r\n const referencedSchema = await context.targetSchema.getReference(schemaName);\r\n if (referencedSchema !== undefined) {\r\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\r\n }\r\n\r\n throw new Error(`Cannot locate referenced schema item ${reference}`);\r\n}\r\n\r\n/**\r\n * To support case insensitivity for schema items, the given key is checked if there\r\n * exists an item for it.\r\n * @internal\r\n */\r\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\r\n const item = await schemaContext.getSchemaItem(itemKey);\r\n if (item === undefined) {\r\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\r\n return itemKey;\r\n }\r\n return item.key;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\r\n const schemaItemKey = new SchemaItemKey(itemName, context.targetSchemaKey);\r\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\r\n if (schemaItem === undefined) {\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\r\n }\r\n\r\n return schemaItem;\r\n}\r\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":";;AAYA,4DAGC;AAOD,kDAYC;AAmBD,4CAQC;AAKD,wCAmBC;AA/ED,gEAA8I;AAE9I;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,SAAiB;IAC3F,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,SAAiB;IACtF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnE,IAAI,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,OAAO,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC7E,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,iCAAa,CAAC,QAAQ,EAAE,gBAAgB,CAAC,SAAS,CAAC,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C,KAAK,kCAAc,CAAC,KAAK;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,KAAK,kCAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,KAAK,kCAAc,CAAC,oBAAoB;YACtC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzC,KAAK,kCAAc,CAAC,iBAAiB;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QACtC;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ECClasses } from \"../Editing/ECClasses\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, ECObjectsError, ECObjectsStatus, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\n * @internal\n */\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\n const schemaItemKey = await updateSchemaItemKey(context, reference);\n return schemaItemKey.fullName;\n}\n\n/**\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\n * @internal\n */\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\n if (context.sourceSchemaKey.compareByName(schemaName)) {\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, context.targetSchemaKey));\n }\n\n const referencedSchema = await context.targetSchema.getReference(schemaName);\n if (referencedSchema !== undefined) {\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\n }\n\n throw new Error(`Cannot locate referenced schema item ${reference}`);\n}\n\n/**\n * To support case insensitivity for schema items, the given key is checked if there\n * exists an item for it.\n * @internal\n */\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\n const item = await schemaContext.getSchemaItem(itemKey);\n if (item === undefined) {\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\n return itemKey;\n }\n return item.key;\n}\n\n/**\n * @internal\n */\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\n const schemaItemKey = new SchemaItemKey(itemName, context.targetSchemaKey);\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined) {\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\n }\n\n return schemaItem;\n}\n\n/**\n * @internal\n */\nexport async function getClassEditor(context: SchemaMergeContext, ecClass: ECClass | SchemaItemKey): Promise<ECClasses> {\n const schemaItemType = ECClass.isECClass(ecClass)\n ? ecClass.schemaItemType\n : (await context.editor.schemaContext.getSchemaItem<ECClass>(ecClass))?.schemaItemType;\n\n switch(schemaItemType) {\n case SchemaItemType.EntityClass:\n return context.editor.entities;\n case SchemaItemType.Mixin:\n return context.editor.mixins;\n case SchemaItemType.StructClass:\n return context.editor.structs;\n case SchemaItemType.CustomAttributeClass:\n return context.editor.customAttributes;\n case SchemaItemType.RelationshipClass:\n return context.editor.relationships;\n default:\n throw new Error(\"SchemaItemType not supported\");\n }\n}\n"]}
@@ -8,8 +8,8 @@ import { AnyClass, AnyECType, AnyProperty, CustomAttributeContainerProps, Relati
8
8
  */
9
9
  export declare enum DiagnosticType {
10
10
  None = 0,
11
- Schema = 1,// eslint-disable-line @typescript-eslint/no-shadow
12
- SchemaItem = 2,// eslint-disable-line @typescript-eslint/no-shadow
11
+ Schema = 1,
12
+ SchemaItem = 2,
13
13
  Property = 3,
14
14
  CustomAttributeContainer = 4,
15
15
  RelationshipConstraint = 5
@@ -1 +1 @@
1
- {"version":3,"file":"Diagnostic.d.ts","sourceRoot":"","sources":["../../../src/Validation/Diagnostic.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAYvJ;;;GAGG;AACH,oBAAY,cAAc;IACxB,IAAI,IAAA;IACJ,MAAM,IAAA,CAAE,mDAAmD;IAC3D,UAAU,IAAA,CAAE,mDAAmD;IAC/D,QAAQ,IAAA;IACR,wBAAwB,IAAA;IACxB,sBAAsB,IAAA;CACvB;AAED;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,IAAA;IACP,KAAK,IAAA;IACL,UAAU,IAAA;IACV,OAAO,IAAA;CACR;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,SAAS,GAAG,EAAE;IACrE,8FAA8F;IAC9F,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,kIAAkI;IAClI,IAAI,EAAE,MAAM,CAAC;IACb,oHAAoH;IACpH,cAAc,EAAE,cAAc,CAAC;IAC/B,yGAAyG;IACzG,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,6DAA6D;IAC7D,YAAY,EAAE,IAAI,CAAC;IACnB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;AAE1D;;;GAGG;AACH,8BAAsB,cAAc,CAAC,IAAI,SAAS,SAAS,EAAE,IAAI,SAAS,GAAG,EAAE,CAAE,YAAW,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;IACjH;;;;;OA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qBAjGvF,sBAAsB,gCAA+B,kBAAkB;;;QAI/F,uDAAuD;;QAGvD,+BAA+B;;QAlH/B,sDAAsD;;QAEtD,kEAAkE;;QAElE,4GAA4G;kBAC3F,kBAAkB;;EA6MpC;AAED;;;;;GAKG;AACH,wBAAgB,6CAA6C,CAAC,IAAI,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;oBAzF1F,6BAA6B,gCAA+B,kBAAkB;;;QAIrG,uDAAuD;;QAGvD,+BAA+B;;QAxI/B,sDAAsD;;QAEtD,kEAAkE;;QAElE,4GAA4G;kBAC3F,kBAAkB;;EA2NpC;AAED,YAAY;AACZ,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,kBAAkB,kDAWtE;AAED,YAAY;AACZ,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,yGAe1D"}
@@ -7,7 +7,15 @@
7
7
  * @module Diagnostic
8
8
  */
9
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;
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,E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B,sBAAsB,CAAC,IAAoB;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;AAfD,wDAeC;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"]}
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,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,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,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Diagnostic\n */\n\nimport { AnyClass, AnyECType, AnyProperty, CustomAttributeContainerProps, RelationshipConstraint, Schema, SchemaItem } from \"@itwin/ecschema-metadata\";\n\n/* eslint-disable @typescript-eslint/no-shadow */\n\nconst formatString = (format: string, ...args: string[]) => {\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\n return typeof args[theNumber] !== \"undefined\"\n ? args[theNumber]\n : match;\n });\n};\n\n/**\n * Defines the possible diagnostic types.\n * @beta\n */\nexport enum DiagnosticType {\n None,\n Schema,\n SchemaItem,\n Property,\n CustomAttributeContainer,\n RelationshipConstraint,\n}\n\n/**\n * Defines the possible diagnostic categories.\n * @beta\n */\nexport enum DiagnosticCategory {\n Warning,\n Error,\n Suggestion,\n Message,\n}\n\n/**\n * The interface implemented by all diagnostics used during schema validation.\n * @beta\n */\nexport interface IDiagnostic<TYPE extends AnyECType, ARGS extends any[]> {\n /** The diagnostic category (error, warning, etc...). Value is static across all instances. */\n category: DiagnosticCategory;\n /** The unique string identifier of the diagnostic in the format '<ruleSetName>:<number>. Value is static across all instances. */\n code: string;\n /** The context type of diagnostic (schema, schema item, property, etc...). Value is static across all instances. */\n diagnosticType: DiagnosticType;\n /** The unformatted message text associated with the diagnostic. Value is static across all instances. */\n messageText: string;\n /** The arguments used when formatted the diagnostic instance's message. */\n messageArgs?: ARGS;\n /** The EC object associated with the diagnostic instance. */\n ecDefinition: TYPE;\n /** The schema where the diagnostic originated. */\n schema: Schema;\n}\n\n/**\n * Type which encapsulates all possible diagnostics.\n * @beta\n */\nexport type AnyDiagnostic = IDiagnostic<AnyECType, any[]>;\n\n/**\n * The abstract base class for all [[IDiagnostic]] implementations.\n * @beta\n */\nexport abstract class BaseDiagnostic<TYPE extends AnyECType, ARGS extends any[]> implements IDiagnostic<TYPE, ARGS> {\n /**\n * Initializes a new BaseDiagnostic.\n * @param ecDefinition The EC object to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(ecDefinition: TYPE, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n this.ecDefinition = ecDefinition;\n this.messageArgs = messageArgs;\n this.category = category;\n }\n\n /** Gets the unique string identifier for the diagnostic in the format '<ruleSetName>:<number>'. */\n public abstract get code(): string;\n /** Gets the context type of the diagnostic (schema, schema item, property, etc...) */\n public abstract get diagnosticType(): DiagnosticType;\n /** Gets the message associated with the diagnostic. */\n public abstract get messageText(): string;\n /** Gets the schema where the diagnostic originated. */\n public abstract get schema(): Schema;\n\n /** The EC object to associate with the diagnostic. */\n public ecDefinition: TYPE;\n /** The arguments used when formatting the diagnostic message. */\n public messageArgs?: ARGS;\n /** The diagnostic category is of the type DiagnosticCategory; which is defined as an enumeration above. */\n public category: DiagnosticCategory;\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[Schema]] diagnostics.\n * @beta\n */\nexport abstract class SchemaDiagnostic<ARGS extends any[]> extends BaseDiagnostic<Schema, ARGS> {\n public static diagnosticType = DiagnosticType.SchemaItem;\n\n /**\n * Initializes a new SchemaDiagnostic.\n * @param ecDefinition The EC object to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(schema: Schema, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(schema, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Schema; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[SchemaItem]] diagnostics.\n * @beta\n */\nexport abstract class SchemaItemDiagnostic<TYPE extends SchemaItem, ARGS extends any[]> extends BaseDiagnostic<TYPE, ARGS> {\n public static diagnosticType = DiagnosticType.SchemaItem;\n /**\n * Initializes a new SchemaItemDiagnostic.\n * @param ecDefinition The EC object to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(ecDefinition: SchemaItem, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(ecDefinition as TYPE, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.SchemaItem; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[ECClass]] diagnostics.\n * @beta\n */\nexport abstract class ClassDiagnostic<ARGS extends any[]> extends SchemaItemDiagnostic<AnyClass, ARGS> {\n /**\n * Initializes a new ClassDiagnostic.\n * @param ecClass The class to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(ecClass: AnyClass, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(ecClass, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public override get schema(): Schema { return this.ecDefinition.schema; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[Property]] diagnostics.\n * @beta\n */\nexport abstract class PropertyDiagnostic<ARGS extends any[]> extends BaseDiagnostic<AnyProperty, ARGS> {\n /**\n * Initializes a new PropertyDiagnostic.\n * @param property The property to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(property: AnyProperty, messageArgs?: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(property, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.Property; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[RelationshipConstraint]] diagnostics.\n * @beta\n */\nexport abstract class RelationshipConstraintDiagnostic<ARGS extends any[]> extends BaseDiagnostic<RelationshipConstraint, ARGS> {\n /**\n * Initializes a new RelationshipConstraintDiagnostic.\n * @param constraint The Relationship Constraint to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(constraint: RelationshipConstraint, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(constraint, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.RelationshipConstraint; }\n}\n\n/**\n * An [[IDiagnostic]] implementation used for [[CustomAttributeContainerProps]] diagnostics.\n * @beta\n */\nexport abstract class CustomAttributeContainerDiagnostic<ARGS extends any[]> extends BaseDiagnostic<CustomAttributeContainerProps, ARGS> {\n /**\n * Initializes a new CustomAttributeContainerDiagnostic.\n * @param constraint The Custom Attribute Container to associate with the diagnostic.\n * @param messageArgs The arguments used when formatting the diagnostic message.\n * @param category The [[DiagnosticCategory]] to associate with the diagnostic, Error by default.\n */\n constructor(container: CustomAttributeContainerProps, messageArgs: ARGS, category: DiagnosticCategory = DiagnosticCategory.Error) {\n super(container, messageArgs, category);\n }\n\n /** Gets the schema where the diagnostic originated. */\n public get schema(): Schema { return this.ecDefinition.schema; }\n\n /** Gets the DiagnosticType. */\n public get diagnosticType(): DiagnosticType { return DiagnosticType.CustomAttributeContainer; }\n}\n\n/**\n * Helper method for creating [[SchemaDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createSchemaDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends SchemaDiagnostic<ARGS> {\n public static code = code;\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[SchemaItemDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createSchemaItemDiagnosticClass<ITEM extends SchemaItem, ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends SchemaItemDiagnostic<ITEM, ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[ClassDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createClassDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends ClassDiagnostic<ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[PropertyDiagnostic]] child classes.\n * @param code The string that uniquely identifies the diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createPropertyDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends PropertyDiagnostic<ARGS> {\n public static code = code;\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[RelationshipConstraintDiagnostic]] child classes.\n * @param code The string that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createRelationshipConstraintDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends RelationshipConstraintDiagnostic<ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/**\n * Helper method for creating [[CustomAttributeContainerDiagnostic]] child classes.\n * @param code The that uniquely identifies the type of diagnostic in the format '<ruleSetName>:<number>'.\n * @param messageText The message to associate with the diagnostic class.\n * @beta\n */\nexport function createCustomAttributeContainerDiagnosticClass<ARGS extends any[]>(code: string, messageText: string) {\n validateCode(code);\n return class extends CustomAttributeContainerDiagnostic<ARGS> {\n public get code(): string { return code; }\n public get messageText(): string { return undefined === this.messageArgs ? messageText : formatString(messageText, ...this.messageArgs); }\n };\n}\n\n/** @beta */\nexport function diagnosticCategoryToString(category: DiagnosticCategory) {\n switch (category) {\n case DiagnosticCategory.Error:\n return \"Error\";\n case DiagnosticCategory.Warning:\n return \"Warning\";\n case DiagnosticCategory.Message:\n return \"Message\";\n case DiagnosticCategory.Suggestion:\n return \"Suggestion\";\n }\n}\n\n/** @beta */\nexport function diagnosticTypeToString(type: DiagnosticType) {\n switch (type) {\n case DiagnosticType.CustomAttributeContainer:\n return \"CustomAttributeContainer\";\n case DiagnosticType.None:\n return \"None\";\n case DiagnosticType.Property:\n return \"Property\";\n case DiagnosticType.RelationshipConstraint:\n return \"RelationshipConstraint\";\n case DiagnosticType.Schema:\n return \"Schema\";\n case DiagnosticType.SchemaItem:\n return \"SchemaItem\";\n }\n}\n\nfunction validateCode(code: string) {\n const msg = `Diagnostic code ${code} is invalid. Expected the format <ruleSetName>-<number>.`;\n const parts = code.split(\"-\");\n if (parts.length !== 2)\n throw new Error(msg);\n\n if (isNaN(Number(parts[1])))\n throw new Error(msg);\n}\n"]}
@@ -8,7 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.FormatDiagnosticReporter = exports.SuppressionDiagnosticReporter = void 0;
11
- const assert = require("assert");
11
+ const assert = require("assert"); // eslint-disable-line @typescript-eslint/no-require-imports
12
12
  const translationNamespace = "ECSchemaMetaData";
13
13
  const subTranslationNamespace = "Diagnostics";
14
14
  const baseTranslationKey = `${translationNamespace}:${subTranslationNamespace}`;
@@ -1 +1 @@
1
- {"version":3,"file":"DiagnosticReporter.js","sourceRoot":"","sources":["../../../src/Validation/DiagnosticReporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,iCAAkC;AAElC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAC9C,MAAM,kBAAkB,GAAG,GAAG,oBAAoB,IAAI,uBAAuB,EAAE,CAAC;AAwBhF;;;;;GAKG;AACH,MAAsB,6BAA6B;IAGjD;;;OAGG;IACH,YAAY,YAAoC;QAC9C,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAyB;QACrC,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7E,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CA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QAEhC,OAAO,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;IAClF,CAAC;IAEO,iBAAiB,CAAC,UAAyB;QACjD,OAAO,GAAG,kBAAkB,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IAEO,aAAa,CAAI,KAA2B,EAAE,OAAgB;QACpE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YACvC,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAU,CAAC;QAEzC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApED,4DAoEC","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 { Localization } from \"@itwin/core-common\";\r\nimport { AnyDiagnostic } from \"./Diagnostic\";\r\n\r\nimport assert = require(\"assert\");\r\n\r\nconst translationNamespace = \"ECSchemaMetaData\";\r\nconst subTranslationNamespace = \"Diagnostics\";\r\nconst baseTranslationKey = `${translationNamespace}:${subTranslationNamespace}`;\r\n\r\n/**\r\n * Interface used to report [[IDiagnostic]] objects created during schema validation.\r\n * @beta\r\n */\r\nexport interface IDiagnosticReporter {\r\n /**\r\n * A map where the key is a schema full name and the value is a collection\r\n * of diagnostics codes identifying which rules violations to ignore during validation.\r\n */\r\n suppressions?: Map<string, string[]>;\r\n\r\n /** The localization object to use for message translation. */\r\n localization?: Localization;\r\n\r\n /**\r\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\r\n * given reporter.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n report(diagnostic: AnyDiagnostic): void;\r\n}\r\n\r\n/**\r\n * An abstract base class for [[IDiagnosticReporter]] implementation that used the\r\n * provided Map to suppress certain rule violations from being reported. The Map's key\r\n * a schema full name, and the Map's value is a collection of rule codes to suppress.\r\n * @beta\r\n */\r\nexport abstract class SuppressionDiagnosticReporter implements IDiagnosticReporter {\r\n private _suppressions?: Map<string, string[]>;\r\n\r\n /**\r\n * Initializes a new SuppressionDiagnosticReporter\r\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\r\n */\r\n constructor(suppressions?: Map<string, string[]>) {\r\n this._suppressions = suppressions;\r\n }\r\n\r\n /**\r\n * Gets the collection of ISchemaDiagnosticSuppression objects that identify\r\n * rules violations to ignore during validation.\r\n */\r\n public get suppressions(): Map<string, string[]> | undefined {\r\n return this._suppressions;\r\n }\r\n\r\n /**\r\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\r\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n public report(diagnostic: AnyDiagnostic) {\r\n if (this._suppressions && this._suppressions.has(diagnostic.schema.fullName)) {\r\n const suppressedCodes = this._suppressions.get(diagnostic.schema.fullName);\r\n if (suppressedCodes!.includes(diagnostic.code))\r\n return;\r\n }\r\n\r\n this.reportInternal(diagnostic);\r\n }\r\n\r\n /**\r\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\r\n * given reporter.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n protected abstract reportInternal(diagnostic: AnyDiagnostic): void;\r\n}\r\n\r\n/**\r\n * An abstract [[SuppressionDiagnosticReporter]] implementation that formats the\r\n * diagnostic message with the message args. If a Localization implementation is specified,\r\n * the message will also be translated.\r\n * @beta\r\n */\r\nexport abstract class FormatDiagnosticReporter extends SuppressionDiagnosticReporter {\r\n /**\r\n * Initializes a new FormatDiagnosticReporter\r\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\r\n * @param localization The Localization instance to use to translate validation messages.\r\n */\r\n constructor(suppressions?: Map<string, string[]>, localization?: Localization) {\r\n super(suppressions);\r\n this.localization = localization;\r\n }\r\n\r\n /** The Localization object to use for message translation. If undefined, no translation will occur. */\r\n public localization?: Localization;\r\n\r\n /**\r\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\r\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\r\n * @param diagnostic The diagnostic to report.\r\n */\r\n public reportInternal(diagnostic: AnyDiagnostic) {\r\n const message = this.formatMessage(diagnostic);\r\n this.reportDiagnostic(diagnostic, message);\r\n }\r\n\r\n /**\r\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\r\n * given reporter.\r\n * @param diagnostic The diagnostic to report.\r\n * @param messageText The formatted message.\r\n */\r\n protected abstract reportDiagnostic(diagnostic: AnyDiagnostic, messageText: string): void;\r\n\r\n /**\r\n * Helper method that formats string with provided arguments where the place holders\r\n * are in the the format '{0}', '{1}', etc.\r\n * @param text The text to format.\r\n * @param args The arguments to place in the text.\r\n * @param baseIndex The base index for the args, used for validation (typically 0, which is the default).\r\n */\r\n protected formatStringFromArgs(text: string, args: ArrayLike<string>, baseIndex = 0): string {\r\n return text.replace(/{(\\d+)}/g, (_match, index: string) => this.assertDefined(args[+index + baseIndex]));\r\n }\r\n\r\n private formatMessage(diagnostic: AnyDiagnostic): string {\r\n let translatedMessage = this.translateMessage(diagnostic);\r\n\r\n if (diagnostic.messageArgs && diagnostic.messageArgs.length > 0)\r\n translatedMessage = this.formatStringFromArgs(translatedMessage, diagnostic.messageArgs);\r\n return translatedMessage;\r\n }\r\n\r\n private translateMessage(diagnostic: AnyDiagnostic): string {\r\n if (!this.localization)\r\n return diagnostic.messageText;\r\n\r\n return this.localization.getLocalizedString(this.getTranslationKey(diagnostic));\r\n }\r\n\r\n private getTranslationKey(diagnostic: AnyDiagnostic): string {\r\n return `${baseTranslationKey}.${diagnostic.code}`;\r\n }\r\n\r\n private assertDefined<T>(value: T | null | undefined, message?: string): T {\r\n if (value === undefined || value === null)\r\n return assert(false, message) as never;\r\n\r\n return value;\r\n }\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AC,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAUD;;;;;;OAMG;IACO,oBAAoB,CAAC,IAAY,EAAE,IAAuB,EAAE,SAAS,GAAG,CAAC;QACjF,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3G,CAAC;IAEO,aAAa,CAAC,UAAyB;QAC7C,IAAI,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAE1D,IAAI,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAC7D,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3F,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,gBAAgB,CAAC,UAAyB;QAChD,IAAI,CAAC,IAAI,CAAC,YAAY;YACpB,OAAO,UAAU,CAAC,WAAW,CAAC;QAEhC,OAAO,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC;IAClF,CAAC;IAEO,iBAAiB,CAAC,UAAyB;QACjD,OAAO,GAAG,kBAAkB,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IAEO,aAAa,CAAI,KAA2B,EAAE,OAAgB;QACpE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YACvC,OAAO,MAAM,CAAC,KAAK,EAAE,OAAO,CAAU,CAAC;QAEzC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApED,4DAoEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Diagnostic\n */\n\nimport { Localization } from \"@itwin/core-common\";\nimport { AnyDiagnostic } from \"./Diagnostic\";\n\nimport assert = require(\"assert\"); // eslint-disable-line @typescript-eslint/no-require-imports\n\nconst translationNamespace = \"ECSchemaMetaData\";\nconst subTranslationNamespace = \"Diagnostics\";\nconst baseTranslationKey = `${translationNamespace}:${subTranslationNamespace}`;\n\n/**\n * Interface used to report [[IDiagnostic]] objects created during schema validation.\n * @beta\n */\nexport interface IDiagnosticReporter {\n /**\n * A map where the key is a schema full name and the value is a collection\n * of diagnostics codes identifying which rules violations to ignore during validation.\n */\n suppressions?: Map<string, string[]>;\n\n /** The localization object to use for message translation. */\n localization?: Localization;\n\n /**\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\n * given reporter.\n * @param diagnostic The diagnostic to report.\n */\n report(diagnostic: AnyDiagnostic): void;\n}\n\n/**\n * An abstract base class for [[IDiagnosticReporter]] implementation that used the\n * provided Map to suppress certain rule violations from being reported. The Map's key\n * a schema full name, and the Map's value is a collection of rule codes to suppress.\n * @beta\n */\nexport abstract class SuppressionDiagnosticReporter implements IDiagnosticReporter {\n private _suppressions?: Map<string, string[]>;\n\n /**\n * Initializes a new SuppressionDiagnosticReporter\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\n */\n constructor(suppressions?: Map<string, string[]>) {\n this._suppressions = suppressions;\n }\n\n /**\n * Gets the collection of ISchemaDiagnosticSuppression objects that identify\n * rules violations to ignore during validation.\n */\n public get suppressions(): Map<string, string[]> | undefined {\n return this._suppressions;\n }\n\n /**\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\n * @param diagnostic The diagnostic to report.\n */\n public report(diagnostic: AnyDiagnostic) {\n if (this._suppressions && this._suppressions.has(diagnostic.schema.fullName)) {\n const suppressedCodes = this._suppressions.get(diagnostic.schema.fullName);\n if (suppressedCodes!.includes(diagnostic.code))\n return;\n }\n\n this.reportInternal(diagnostic);\n }\n\n /**\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\n * given reporter.\n * @param diagnostic The diagnostic to report.\n */\n protected abstract reportInternal(diagnostic: AnyDiagnostic): void;\n}\n\n/**\n * An abstract [[SuppressionDiagnosticReporter]] implementation that formats the\n * diagnostic message with the message args. If a Localization implementation is specified,\n * the message will also be translated.\n * @beta\n */\nexport abstract class FormatDiagnosticReporter extends SuppressionDiagnosticReporter {\n /**\n * Initializes a new FormatDiagnosticReporter\n * @param suppressions A Map where the key is a schema full name and the value is collection of diagnostic codes to suppress.\n * @param localization The Localization instance to use to translate validation messages.\n */\n constructor(suppressions?: Map<string, string[]>, localization?: Localization) {\n super(suppressions);\n this.localization = localization;\n }\n\n /** The Localization object to use for message translation. If undefined, no translation will occur. */\n public localization?: Localization;\n\n /**\n * Prior to reporting the [[IDiagnostic]], the diagnostic message is formatted (with translations)\n * base on arguments contained in the diagnostic. Calls reportDiagnostic after the message is formatted.\n * @param diagnostic The diagnostic to report.\n */\n public reportInternal(diagnostic: AnyDiagnostic) {\n const message = this.formatMessage(diagnostic);\n this.reportDiagnostic(diagnostic, message);\n }\n\n /**\n * Handles the given [[IDiagnostic]] based on the implementation requirements for a\n * given reporter.\n * @param diagnostic The diagnostic to report.\n * @param messageText The formatted message.\n */\n protected abstract reportDiagnostic(diagnostic: AnyDiagnostic, messageText: string): void;\n\n /**\n * Helper method that formats string with provided arguments where the place holders\n * are in the the format '{0}', '{1}', etc.\n * @param text The text to format.\n * @param args The arguments to place in the text.\n * @param baseIndex The base index for the args, used for validation (typically 0, which is the default).\n */\n protected formatStringFromArgs(text: string, args: ArrayLike<string>, baseIndex = 0): string {\n return text.replace(/{(\\d+)}/g, (_match, index: string) => this.assertDefined(args[+index + baseIndex]));\n }\n\n private formatMessage(diagnostic: AnyDiagnostic): string {\n let translatedMessage = this.translateMessage(diagnostic);\n\n if (diagnostic.messageArgs && diagnostic.messageArgs.length > 0)\n translatedMessage = this.formatStringFromArgs(translatedMessage, diagnostic.messageArgs);\n return translatedMessage;\n }\n\n private translateMessage(diagnostic: AnyDiagnostic): string {\n if (!this.localization)\n return diagnostic.messageText;\n\n return this.localization.getLocalizedString(this.getTranslationKey(diagnostic));\n }\n\n private getTranslationKey(diagnostic: AnyDiagnostic): string {\n return `${baseTranslationKey}.${diagnostic.code}`;\n }\n\n private assertDefined<T>(value: T | null | undefined, message?: string): T {\n if (value === undefined || value === null)\n return assert(false, message) as never;\n\n return value;\n }\n}\n"]}
@@ -7,7 +7,25 @@
7
7
  * @module Validation
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.validateCustomAttributeInstance = exports.mixinAppliedToClassMustDeriveFromConstraint = exports.enumerationTypeUnsupported = exports.abstractConstraintMustExistWithMultipleConstraints = exports.atLeastOneConstraintClassDefined = exports.validateRelationshipConstraint = exports.constraintClassesDeriveFromAbstractConstraint = exports.derivedConstraintsMustNarrowBaseConstraints = exports.abstractConstraintMustNarrowBaseConstraints = exports.validateRelationship = exports.validateNavigationProperty = exports.incompatibleUnitPropertyOverride = exports.incompatibleTypePropertyOverride = exports.incompatibleValueTypePropertyOverride = exports.baseClassIsOfDifferentType = exports.baseClassIsSealed = exports.validateSchemaReferencesSync = exports.validateSchemaReferences = exports.ECRuleSet = exports.Diagnostics = exports.DiagnosticCodes = void 0;
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;