@@ -12,30 +12,39 @@ import { getCodeQLDatabasePath } from "./util";
1212 */
1313export type DiagnosticTag = "internal-error" ;
1414
15+ /** Optional information about the origin of a diagnostic. */
16+ export type DiagnosticSourceOptions = {
17+ /**
18+ * Name of the CodeQL extractor. This is used to identify which tool component the reporting
19+ * descriptor object should be nested under in SARIF.
20+ */
21+ extractorName ?: string ;
22+ /** An array of tags for the diagnostic. */
23+ tags ?: DiagnosticTag [ ] ;
24+ } ;
25+
1526/** Represents information about the origin of a diagnostic. */
16- export interface DiagnosticSource {
27+ export type DiagnosticSource = {
1728 /**
1829 * An identifier under which it makes sense to group this diagnostic message.
1930 * This is used to build the SARIF reporting descriptor object.
2031 */
2132 id : string ;
2233 /** Display name for the ID. This is used to build the SARIF reporting descriptor object. */
2334 name : string ;
24- /**
25- * Name of the CodeQL extractor. This is used to identify which tool component the reporting
26- * descriptor object should be nested under in SARIF.
27- */
28- extractorName ?: string ;
29- /** An array of tags for the diagnostic. */
30- tags ?: DiagnosticTag [ ] ;
31- }
35+ } & DiagnosticSourceOptions ;
3236
33- /** Represents a diagnostic message for the tool status page, etc. */
34- export interface DiagnosticMessage {
37+ /**
38+ * Represents a diagnostic message for the tool status page, etc.
39+ *
40+ * Unlike {@link DiagnosticMessage}, properties which can automatically
41+ * be populated are optional in this type.
42+ */
43+ export type DiagnosticMessageOptions = {
3544 /** ISO 8601 timestamp */
36- timestamp : string ;
45+ timestamp ? : string ;
3746 /** Information about the origin of the diagnostic. */
38- source : DiagnosticSource ;
47+ source ?: DiagnosticSourceOptions ;
3948 /** GitHub flavored Markdown formatted message. Should include inline links to any help pages. */
4049 markdownMessage ?: string ;
4150 /** Plain text message. Used by components where the string processing needed to support Markdown is cumbersome. */
@@ -65,7 +74,15 @@ export interface DiagnosticMessage {
6574 } ;
6675 /** Structured metadata about the diagnostic message */
6776 attributes ?: { [ key : string ] : any } ;
68- }
77+ } ;
78+
79+ /** Represents a diagnostic message for the tool status page, etc. */
80+ export type DiagnosticMessage = DiagnosticMessageOptions & {
81+ /** ISO 8601 timestamp */
82+ timestamp : string ;
83+ /** Information about the origin of the diagnostic. */
84+ source : DiagnosticSource ;
85+ } ;
6986
7087/** Represents a diagnostic message that has not yet been written to the database. */
7188interface UnwrittenDiagnostic {
@@ -102,7 +119,7 @@ let diagnosticCounter = 0;
102119export function makeDiagnostic (
103120 id : string ,
104121 name : string ,
105- data : Partial < DiagnosticMessage > | undefined = undefined ,
122+ data : DiagnosticMessageOptions | undefined = undefined ,
106123) : DiagnosticMessage {
107124 return {
108125 ...data ,
0 commit comments