@thymian/core 0.1.11 → 0.1.12-canary.20260709-74e687c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/report.event.d.ts.map +1 -1
- package/dist/events/report.event.js +119 -54
- package/dist/events/report.event.js.map +1 -1
- package/dist/report/finding-render.d.ts +36 -0
- package/dist/report/finding-render.d.ts.map +1 -0
- package/dist/report/finding-render.js +62 -0
- package/dist/report/finding-render.js.map +1 -0
- package/dist/report/index.d.ts +8 -2
- package/dist/report/index.d.ts.map +1 -1
- package/dist/report/index.js +4 -1
- package/dist/report/index.js.map +1 -1
- package/dist/report/location-format.d.ts +38 -0
- package/dist/report/location-format.d.ts.map +1 -0
- package/dist/report/location-format.js +106 -0
- package/dist/report/location-format.js.map +1 -0
- package/dist/report/report-builder.d.ts +51 -18
- package/dist/report/report-builder.d.ts.map +1 -1
- package/dist/report/report-builder.js +133 -91
- package/dist/report/report-builder.js.map +1 -1
- package/dist/report/report-traversal.d.ts +28 -0
- package/dist/report/report-traversal.d.ts.map +1 -0
- package/dist/report/report-traversal.js +38 -0
- package/dist/report/report-traversal.js.map +1 -0
- package/dist/report/report.d.ts +106 -73
- package/dist/report/report.d.ts.map +1 -1
- package/dist/rules/rule-violation.d.ts +9 -1
- package/dist/rules/rule-violation.d.ts.map +1 -1
- package/dist/thymian.d.ts.map +1 -1
- package/dist/thymian.js +4 -1
- package/dist/thymian.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.event.d.ts","sourceRoot":"","sources":["../../src/events/report.event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"report.event.d.ts","sourceRoot":"","sources":["../../src/events/report.event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAsHjC,eAAO,MAAM,YAAY,EA6DT,cAAc,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,3 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loose location schema shared by `Execution.location` and `TestStep.location`.
|
|
3
|
+
* `Location` is a closed union (`thymianFormat` | `url` | `file` | `custom`);
|
|
4
|
+
* this only asserts `type` is present and leaves per-variant fields
|
|
5
|
+
* (`elementId`, `url`, `path`, `value`, …) to `additionalProperties`.
|
|
6
|
+
*/
|
|
7
|
+
const locationSchema = {
|
|
8
|
+
type: 'object',
|
|
9
|
+
nullable: false,
|
|
10
|
+
required: ['type'],
|
|
11
|
+
additionalProperties: true,
|
|
12
|
+
properties: {
|
|
13
|
+
type: { type: 'string', nullable: false },
|
|
14
|
+
elementType: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
enum: ['node', 'edge'],
|
|
17
|
+
nullable: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* `FindingRecord` schema. Severity no longer lives on findings — it is
|
|
23
|
+
* resolved from the owning execution's `ruleId`/`status` (see
|
|
24
|
+
* `resolveExecutionSeverity`) — so it is intentionally absent here.
|
|
25
|
+
*/
|
|
26
|
+
const findingSchema = {
|
|
27
|
+
type: 'object',
|
|
28
|
+
nullable: false,
|
|
29
|
+
required: ['id', 'kind', 'title'],
|
|
30
|
+
additionalProperties: true,
|
|
31
|
+
properties: {
|
|
32
|
+
id: { type: 'string', nullable: false },
|
|
33
|
+
kind: { type: 'string', nullable: false },
|
|
34
|
+
title: { type: 'string', nullable: false },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* `Execution` schema. Report Format v4 (issue #323/#334) replaced the
|
|
39
|
+
* hierarchical `Execution.children`/`nestedFindings` shape with a flat,
|
|
40
|
+
* per-runType union: `LintExecution`/`AnalyzeExecution` (`location` +
|
|
41
|
+
* `findings`) and `TestCaseExecution` (`name` + `steps`, no `location`).
|
|
42
|
+
* `kind` and `status` are the only fields common to every variant, so only
|
|
43
|
+
* those are `required`; the rest are optional and validated loosely rather
|
|
44
|
+
* than as a strict discriminated union (ajv's `JSONSchemaType` cannot express
|
|
45
|
+
* "required iff kind === X" without repeating the whole union per branch).
|
|
46
|
+
*/
|
|
47
|
+
const executionSchema = {
|
|
48
|
+
type: 'object',
|
|
49
|
+
nullable: false,
|
|
50
|
+
required: ['kind', 'status'],
|
|
51
|
+
additionalProperties: true,
|
|
52
|
+
properties: {
|
|
53
|
+
kind: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
enum: ['lint', 'analyze', 'test'],
|
|
56
|
+
nullable: false,
|
|
57
|
+
},
|
|
58
|
+
ruleId: { type: 'string', nullable: true },
|
|
59
|
+
status: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
nullable: false,
|
|
62
|
+
required: ['kind'],
|
|
63
|
+
additionalProperties: true,
|
|
64
|
+
properties: {
|
|
65
|
+
kind: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
enum: ['passed', 'failed', 'skipped'],
|
|
68
|
+
nullable: false,
|
|
69
|
+
},
|
|
70
|
+
reason: { type: 'string', nullable: true },
|
|
71
|
+
durationMilliseconds: { type: 'number', nullable: true },
|
|
72
|
+
severity: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
enum: ['error', 'warn', 'info', 'hint'],
|
|
75
|
+
nullable: true,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
// Present on LintExecution/AnalyzeExecution only.
|
|
80
|
+
location: { ...locationSchema, nullable: true },
|
|
81
|
+
findings: {
|
|
82
|
+
type: 'array',
|
|
83
|
+
nullable: true,
|
|
84
|
+
items: findingSchema,
|
|
85
|
+
},
|
|
86
|
+
// Present on TestCaseExecution only.
|
|
87
|
+
name: { type: 'string', nullable: true },
|
|
88
|
+
steps: {
|
|
89
|
+
type: 'array',
|
|
90
|
+
nullable: true,
|
|
91
|
+
items: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
nullable: false,
|
|
94
|
+
required: ['name', 'location', 'findings'],
|
|
95
|
+
additionalProperties: true,
|
|
96
|
+
properties: {
|
|
97
|
+
name: { type: 'string', nullable: false },
|
|
98
|
+
location: locationSchema,
|
|
99
|
+
findings: {
|
|
100
|
+
type: 'array',
|
|
101
|
+
nullable: false,
|
|
102
|
+
items: findingSchema,
|
|
103
|
+
},
|
|
104
|
+
httpTransactions: {
|
|
105
|
+
type: 'array',
|
|
106
|
+
nullable: true,
|
|
107
|
+
items: {},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
1
114
|
export const reportSchema = {
|
|
2
115
|
type: 'object',
|
|
3
116
|
nullable: false,
|
|
@@ -31,60 +144,7 @@ export const reportSchema = {
|
|
|
31
144
|
executions: {
|
|
32
145
|
type: 'array',
|
|
33
146
|
nullable: true,
|
|
34
|
-
items:
|
|
35
|
-
type: 'object',
|
|
36
|
-
nullable: false,
|
|
37
|
-
required: ['location', 'findings'],
|
|
38
|
-
additionalProperties: true,
|
|
39
|
-
properties: {
|
|
40
|
-
name: { type: 'string', nullable: true },
|
|
41
|
-
description: { type: 'string', nullable: true },
|
|
42
|
-
location: {
|
|
43
|
-
type: 'object',
|
|
44
|
-
nullable: false,
|
|
45
|
-
required: ['type'],
|
|
46
|
-
additionalProperties: true,
|
|
47
|
-
properties: {
|
|
48
|
-
type: { type: 'string', nullable: false },
|
|
49
|
-
elementType: {
|
|
50
|
-
type: 'string',
|
|
51
|
-
enum: ['node', 'edge'],
|
|
52
|
-
nullable: true,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
findings: {
|
|
57
|
-
type: 'array',
|
|
58
|
-
nullable: false,
|
|
59
|
-
items: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
nullable: false,
|
|
62
|
-
required: ['id', 'kind', 'title', 'severity'],
|
|
63
|
-
additionalProperties: true,
|
|
64
|
-
properties: {
|
|
65
|
-
id: { type: 'string', nullable: false },
|
|
66
|
-
kind: { type: 'string', nullable: false },
|
|
67
|
-
title: { type: 'string', nullable: false },
|
|
68
|
-
severity: {
|
|
69
|
-
type: 'string',
|
|
70
|
-
enum: ['error', 'warn', 'info', 'hint'],
|
|
71
|
-
nullable: false,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
children: {
|
|
77
|
-
type: 'array',
|
|
78
|
-
nullable: true,
|
|
79
|
-
items: {},
|
|
80
|
-
},
|
|
81
|
-
httpTransactions: {
|
|
82
|
-
type: 'array',
|
|
83
|
-
nullable: true,
|
|
84
|
-
items: {},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
147
|
+
items: executionSchema,
|
|
88
148
|
},
|
|
89
149
|
rules: {
|
|
90
150
|
type: 'array',
|
|
@@ -106,6 +166,11 @@ export const reportSchema = {
|
|
|
106
166
|
},
|
|
107
167
|
},
|
|
108
168
|
},
|
|
169
|
+
thymianFormat: {
|
|
170
|
+
type: 'object',
|
|
171
|
+
nullable: true,
|
|
172
|
+
additionalProperties: true,
|
|
173
|
+
},
|
|
109
174
|
},
|
|
110
175
|
};
|
|
111
176
|
//# sourceMappingURL=report.event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.event.js","sourceRoot":"","sources":["../../src/events/report.event.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"report.event.js","sourceRoot":"","sources":["../../src/events/report.event.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,M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,EAAE;4BACzC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;yBAC5C;qBACF;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,IAAI;wBACd,KAAK,EAAE,eAAe;qBACvB;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,IAAI;wBACd,KAAK,EAAE,EAA6B;qBACrC;oBACD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;oBAC5C,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;oBACxD,SAAS,EAAE;wBACT,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,IAAI;wBACd,KAAK,EAAE,EAA6B;qBACrC;oBACD,WAAW,EAAE;wBACX,IAAI,EAAE,OAAO;wBACb,QAAQ,EAAE,IAAI;wBACd,KAAK,EAAE,EAA6B;qBACrC;iBACF;aACF;SACF;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,oBAAoB,EAAE,IAAI;SAC3B;KACF;CACwC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Execution, FindingRecord, RuleDescriptor, Severity } from './report.js';
|
|
2
|
+
/** Minimal logger surface used for defensive severity-resolution warnings. */
|
|
3
|
+
export interface SeverityWarnLogger {
|
|
4
|
+
warn(message: string): void;
|
|
5
|
+
}
|
|
6
|
+
/** A single label/value detail extracted from a finding for rendering. */
|
|
7
|
+
export interface FindingDetail {
|
|
8
|
+
/** Stable label, e.g. `expected`, `actual`. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Plain-text value. */
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
/** Build an `id -> descriptor` lookup from a run's rules list. */
|
|
14
|
+
export declare function buildRuleIndex(rules: RuleDescriptor[] | undefined): ReadonlyMap<string, RuleDescriptor>;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the effective {@link Severity} of an execution.
|
|
17
|
+
*
|
|
18
|
+
* Only `failed` executions have a severity (per SARIF, a "level" applies only to
|
|
19
|
+
* failing results). For a failed execution the severity is `status.severity`
|
|
20
|
+
* (an override) if present, else the rule's configured severity looked up via
|
|
21
|
+
* `ruleId`, else `'error'` as a last-resort fallback (with a warning). Non-failed
|
|
22
|
+
* executions return `undefined`; if one nonetheless carries a `severity`, that is
|
|
23
|
+
* a model violation — it is warned about and ignored.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveExecutionSeverity(execution: Execution, ruleIndex: ReadonlyMap<string, RuleDescriptor>, logger?: SeverityWarnLogger): Severity | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Extract the kind-specific detail lines for a finding as plain label/value
|
|
28
|
+
* pairs. Renderers decide layout (indented lines, table cells, CSV columns) and
|
|
29
|
+
* apply their own coloring.
|
|
30
|
+
*
|
|
31
|
+
* Rule identity and outcome detail (reason, duration, skip reason) no longer
|
|
32
|
+
* live on findings — they are carried by the owning execution's `ruleId` and
|
|
33
|
+
* {@link ExecutionStatus} and are rendered at the execution level.
|
|
34
|
+
*/
|
|
35
|
+
export declare function findingDetails(finding: FindingRecord): FindingDetail[];
|
|
36
|
+
//# sourceMappingURL=finding-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding-render.d.ts","sourceRoot":"","sources":["../../src/report/finding-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,QAAQ,EACT,MAAM,aAAa,CAAC;AAErB,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kEAAkE;AAClE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,cAAc,EAAE,GAAG,SAAS,GAClC,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAQrC;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,EAC9C,MAAM,CAAC,EAAE,kBAAkB,GAC1B,QAAQ,GAAG,SAAS,CAiCtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,EAAE,CAiBtE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Build an `id -> descriptor` lookup from a run's rules list. */
|
|
2
|
+
export function buildRuleIndex(rules) {
|
|
3
|
+
const index = new Map();
|
|
4
|
+
for (const rule of rules ?? []) {
|
|
5
|
+
index.set(rule.id, rule);
|
|
6
|
+
}
|
|
7
|
+
return index;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the effective {@link Severity} of an execution.
|
|
11
|
+
*
|
|
12
|
+
* Only `failed` executions have a severity (per SARIF, a "level" applies only to
|
|
13
|
+
* failing results). For a failed execution the severity is `status.severity`
|
|
14
|
+
* (an override) if present, else the rule's configured severity looked up via
|
|
15
|
+
* `ruleId`, else `'error'` as a last-resort fallback (with a warning). Non-failed
|
|
16
|
+
* executions return `undefined`; if one nonetheless carries a `severity`, that is
|
|
17
|
+
* a model violation — it is warned about and ignored.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveExecutionSeverity(execution, ruleIndex, logger) {
|
|
20
|
+
const { status } = execution;
|
|
21
|
+
if (status.kind !== 'failed') {
|
|
22
|
+
if ('severity' in status &&
|
|
23
|
+
status.severity !== undefined) {
|
|
24
|
+
logger?.warn(`severity on non-'failed' status (kind '${status.kind}'); ignoring it.`);
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
if (status.severity !== undefined) {
|
|
29
|
+
return status.severity;
|
|
30
|
+
}
|
|
31
|
+
const fromRule = execution.ruleId !== undefined
|
|
32
|
+
? ruleIndex.get(execution.ruleId)?.severity
|
|
33
|
+
: undefined;
|
|
34
|
+
if (fromRule !== undefined) {
|
|
35
|
+
return fromRule;
|
|
36
|
+
}
|
|
37
|
+
logger?.warn(`Could not resolve severity for failed execution${execution.ruleId ? ` (rule '${execution.ruleId}')` : ''}; defaulting to 'error'.`);
|
|
38
|
+
return 'error';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Extract the kind-specific detail lines for a finding as plain label/value
|
|
42
|
+
* pairs. Renderers decide layout (indented lines, table cells, CSV columns) and
|
|
43
|
+
* apply their own coloring.
|
|
44
|
+
*
|
|
45
|
+
* Rule identity and outcome detail (reason, duration, skip reason) no longer
|
|
46
|
+
* live on findings — they are carried by the owning execution's `ruleId` and
|
|
47
|
+
* {@link ExecutionStatus} and are rendered at the execution level.
|
|
48
|
+
*/
|
|
49
|
+
export function findingDetails(finding) {
|
|
50
|
+
const details = [];
|
|
51
|
+
if (finding.kind === 'assertion-failure') {
|
|
52
|
+
const { expected, actual } = finding;
|
|
53
|
+
if (expected !== undefined) {
|
|
54
|
+
details.push({ label: 'expected', value: JSON.stringify(expected) });
|
|
55
|
+
}
|
|
56
|
+
if (actual !== undefined) {
|
|
57
|
+
details.push({ label: 'actual', value: JSON.stringify(actual) });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return details;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=finding-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding-render.js","sourceRoot":"","sources":["../../src/report/finding-render.ts"],"names":[],"mappings":"AAoBA,kEAAkE;AAClE,MAAM,UAAU,cAAc,CAC5B,KAAmC;IAEnC,MAAM,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AAC;IAEpC,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACzC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAG5B,CAAC;QACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { FindingDetail, SeverityWarnLogger } from './finding-render.js';
|
|
2
|
+
export { buildRuleIndex, findingDetails, resolveExecutionSeverity, } from './finding-render.js';
|
|
3
|
+
export type { LocationResolver } from './location-format.js';
|
|
4
|
+
export { createLocationResolver, formatLocation, formatThymianFormatLocation, resolveThymianFormatForRun, } from './location-format.js';
|
|
5
|
+
export type { AnalyzeExecution, Artifact, BaseFinding, BodyContent, Execution, ExecutionBase, ExecutionStatus, FindingRecord, Headers, Informational, Invocation, LintExecution, Location, Message, Report, ReportHttpRequest, ReportHttpResponse, ReportHttpTransaction, RuleDescriptor, RuleViolationFinding, Severity, TestCaseExecution, TestStep, ThymianFormatVersion, Tool, ToolRun, } from './report.js';
|
|
2
6
|
export type { AssertionFailure as ReportAssertionFailure, AssertionSuccess as ReportAssertionSuccess, } from './report.js';
|
|
3
|
-
export {
|
|
7
|
+
export { createAnalyzeExecution, createLintExecution, createReport, createTestCaseExecution, createTestStep, createToolRun, executionsFromRunRulesResult, executionsFromViolations, httpTestResultToRuleFindings, ruleFindingsToFindingRecords, ruleFindingToFindingRecord, rulesToRuleDescriptors, } from './report-builder.js';
|
|
8
|
+
export type { ExecutionVisit, FindingVisit } from './report-traversal.js';
|
|
9
|
+
export { collectFindings, walkExecutions, walkFindings, } from './report-traversal.js';
|
|
4
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EACL,cAAc,EACd,cAAc,EACd,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,eAAe,EACf,aAAa,EACb,OAAO,EACP,aAAa,EACb,UAAU,EACV,aAAa,EACb,QAAQ,EACR,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EACpB,IAAI,EACJ,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,gBAAgB,IAAI,sBAAsB,EAC1C,gBAAgB,IAAI,sBAAsB,GAC3C,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC"}
|
package/dist/report/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { buildRuleIndex, findingDetails, resolveExecutionSeverity, } from './finding-render.js';
|
|
2
|
+
export { createLocationResolver, formatLocation, formatThymianFormatLocation, resolveThymianFormatForRun, } from './location-format.js';
|
|
3
|
+
export { createAnalyzeExecution, createLintExecution, createReport, createTestCaseExecution, createTestStep, createToolRun, executionsFromRunRulesResult, executionsFromViolations, httpTestResultToRuleFindings, ruleFindingsToFindingRecords, ruleFindingToFindingRecord, rulesToRuleDescriptors, } from './report-builder.js';
|
|
4
|
+
export { collectFindings, walkExecutions, walkFindings, } from './report-traversal.js';
|
|
2
5
|
//# sourceMappingURL=index.js.map
|
package/dist/report/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,cAAc,EACd,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAiC9B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ThymianFormat } from '../format/thymian-format.js';
|
|
2
|
+
import type { Location, Report } from './report.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves report {@link Location}s to human-readable strings (e.g.
|
|
5
|
+
* `POST /orders`). Single source of truth for location rendering, shared by
|
|
6
|
+
* every consumer that turns a `Report` into user-facing output (markdown/CSV
|
|
7
|
+
* formatters, the CLI renderer) so they can't drift from one another.
|
|
8
|
+
*/
|
|
9
|
+
export type LocationResolver = (location: Location, runVersion?: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Render a `thymianFormat` location against an already-resolved
|
|
12
|
+
* {@link ThymianFormat}, falling back to the raw `format:{elementId}` form
|
|
13
|
+
* when the format is absent or the node/edge can't be resolved to an HTTP
|
|
14
|
+
* request/response/transaction.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatThymianFormatLocation(location: Extract<Location, {
|
|
17
|
+
type: 'thymianFormat';
|
|
18
|
+
}>, format?: ThymianFormat): string;
|
|
19
|
+
/** Render any report {@link Location} (not just `thymianFormat`) to a string. */
|
|
20
|
+
export declare function formatLocation(location: Location, format?: ThymianFormat): string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the {@link ThymianFormat} a run used, from `report.thymianFormat`.
|
|
23
|
+
* Falls back to the single entry when `runVersion` is absent/unmatched and
|
|
24
|
+
* there is exactly one format in the report — this guards against a producer
|
|
25
|
+
* plugin forgetting to set `ToolRun.thymianFormatVersion`. Returns `undefined`
|
|
26
|
+
* (never throws) on malformed/unsupported serialized format data, so a single
|
|
27
|
+
* bad entry can't fail an entire render.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveThymianFormatForRun(formats: Report['thymianFormat'], runVersion: string | undefined): ThymianFormat | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Build a caching {@link LocationResolver} for a whole report: resolves and
|
|
32
|
+
* caches the `ThymianFormat` per `runVersion` (via
|
|
33
|
+
* {@link resolveThymianFormatForRun}) and renders locations against it (via
|
|
34
|
+
* {@link formatLocation}). Suited to callers that render many locations
|
|
35
|
+
* across potentially many run versions (markdown/CSV formatters).
|
|
36
|
+
*/
|
|
37
|
+
export declare function createLocationResolver(report: Report): LocationResolver;
|
|
38
|
+
//# sourceMappingURL=location-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location-format.d.ts","sourceRoot":"","sources":["../../src/report/location-format.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAMxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,QAAQ,EAClB,UAAU,CAAC,EAAE,MAAM,KAChB,MAAM,CAAC;AAQZ;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC,EACtD,MAAM,CAAC,EAAE,aAAa,GACrB,MAAM,CAiCR;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,aAAa,GACrB,MAAM,CAaR;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,CAAC,eAAe,CAAC,EAChC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,aAAa,GAAG,SAAS,CAkB3B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAqBvE"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { isNodeType, ThymianFormat } from '../format/thymian-format.js';
|
|
2
|
+
import { thymianHttpTransactionToString, thymianRequestToString, thymianResponseToString, } from '../utils.js';
|
|
3
|
+
function fallbackThymianFormatLocation(location) {
|
|
4
|
+
return `format:${location.elementId}${location.pointer ? `#${location.pointer}` : ''}`;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Render a `thymianFormat` location against an already-resolved
|
|
8
|
+
* {@link ThymianFormat}, falling back to the raw `format:{elementId}` form
|
|
9
|
+
* when the format is absent or the node/edge can't be resolved to an HTTP
|
|
10
|
+
* request/response/transaction.
|
|
11
|
+
*/
|
|
12
|
+
export function formatThymianFormatLocation(location, format) {
|
|
13
|
+
if (!format) {
|
|
14
|
+
return fallbackThymianFormatLocation(location);
|
|
15
|
+
}
|
|
16
|
+
if (location.elementType === 'node') {
|
|
17
|
+
const node = format.getNode(location.elementId);
|
|
18
|
+
if (node && isNodeType(node, 'http-request')) {
|
|
19
|
+
return thymianRequestToString(node);
|
|
20
|
+
}
|
|
21
|
+
if (node && isNodeType(node, 'http-response')) {
|
|
22
|
+
return thymianResponseToString(node);
|
|
23
|
+
}
|
|
24
|
+
return fallbackThymianFormatLocation(location);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const transaction = format.getEdge(location.elementId);
|
|
28
|
+
const [source, target] = format.graph.extremities(location.elementId);
|
|
29
|
+
const request = format.getNode(source);
|
|
30
|
+
const response = format.getNode(target);
|
|
31
|
+
if (transaction && request && response) {
|
|
32
|
+
return thymianHttpTransactionToString(request, response);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return fallbackThymianFormatLocation(location);
|
|
37
|
+
}
|
|
38
|
+
return fallbackThymianFormatLocation(location);
|
|
39
|
+
}
|
|
40
|
+
/** Render any report {@link Location} (not just `thymianFormat`) to a string. */
|
|
41
|
+
export function formatLocation(location, format) {
|
|
42
|
+
switch (location.type) {
|
|
43
|
+
case 'custom':
|
|
44
|
+
return location.value;
|
|
45
|
+
case 'file':
|
|
46
|
+
return [location.path, location.line, location.column]
|
|
47
|
+
.filter((part) => part !== undefined)
|
|
48
|
+
.join(':');
|
|
49
|
+
case 'url':
|
|
50
|
+
return location.url;
|
|
51
|
+
case 'thymianFormat':
|
|
52
|
+
return formatThymianFormatLocation(location, format);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the {@link ThymianFormat} a run used, from `report.thymianFormat`.
|
|
57
|
+
* Falls back to the single entry when `runVersion` is absent/unmatched and
|
|
58
|
+
* there is exactly one format in the report — this guards against a producer
|
|
59
|
+
* plugin forgetting to set `ToolRun.thymianFormatVersion`. Returns `undefined`
|
|
60
|
+
* (never throws) on malformed/unsupported serialized format data, so a single
|
|
61
|
+
* bad entry can't fail an entire render.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveThymianFormatForRun(formats, runVersion) {
|
|
64
|
+
const entries = Object.entries(formats ?? {});
|
|
65
|
+
const serialized = runVersion !== undefined && formats?.[runVersion]
|
|
66
|
+
? formats[runVersion]
|
|
67
|
+
: entries.length === 1
|
|
68
|
+
? entries[0]?.[1]
|
|
69
|
+
: undefined;
|
|
70
|
+
if (!serialized) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return ThymianFormat.import(serialized);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build a caching {@link LocationResolver} for a whole report: resolves and
|
|
82
|
+
* caches the `ThymianFormat` per `runVersion` (via
|
|
83
|
+
* {@link resolveThymianFormatForRun}) and renders locations against it (via
|
|
84
|
+
* {@link formatLocation}). Suited to callers that render many locations
|
|
85
|
+
* across potentially many run versions (markdown/CSV formatters).
|
|
86
|
+
*/
|
|
87
|
+
export function createLocationResolver(report) {
|
|
88
|
+
const formatCache = new Map();
|
|
89
|
+
const cacheKeyFor = (version) => version ?? '\0single-entry';
|
|
90
|
+
return (location, runVersion) => {
|
|
91
|
+
if (location.type !== 'thymianFormat') {
|
|
92
|
+
return formatLocation(location);
|
|
93
|
+
}
|
|
94
|
+
const cacheKey = cacheKeyFor(runVersion);
|
|
95
|
+
let format;
|
|
96
|
+
if (formatCache.has(cacheKey)) {
|
|
97
|
+
format = formatCache.get(cacheKey);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
format = resolveThymianFormatForRun(report.thymianFormat, runVersion);
|
|
101
|
+
formatCache.set(cacheKey, format);
|
|
102
|
+
}
|
|
103
|
+
return formatThymianFormatLocation(location, format);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=location-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location-format.js","sourceRoot":"","sources":["../../src/report/location-format.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAcrB,SAAS,6BAA6B,CACpC,QAAsD;IAEtD,OAAO,UAAU,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAsD,EACtD,MAAsB;IAEtB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,QAAQ,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,C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C;QAClC,CAAC;QAED,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,MAAiC,CAAC;QACtC,IAAI,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,0BAA0B,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;YACtE,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,2BAA2B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThymianFormat } from '../format/index.js';
|
|
2
2
|
import type { HttpTestCaseResult } from '../http-testing/http-test/http-test-case-result.js';
|
|
3
3
|
import type { Rule } from '../rules/rule.js';
|
|
4
4
|
import type { RunRulesResult } from '../rules/rule-runner.js';
|
|
5
5
|
import type { EvaluatedRuleViolation, RuleFinding } from '../rules/rule-violation.js';
|
|
6
|
-
import type { Execution, FindingRecord, Location, Report, ReportHttpTransaction, RuleDescriptor, Tool, ToolRun } from './report.js';
|
|
7
|
-
export declare function createReport(runs: ToolRun[], thymianFormat?:
|
|
6
|
+
import type { AnalyzeExecution, Execution, ExecutionStatus, FindingRecord, LintExecution, Location, Report, ReportHttpTransaction, RuleDescriptor, TestCaseExecution, TestStep, Tool, ToolRun } from './report.js';
|
|
7
|
+
export declare function createReport(runs: ToolRun[], thymianFormat?: Report['thymianFormat']): Report;
|
|
8
8
|
export declare function createToolRun(opts: {
|
|
9
9
|
tool: Tool;
|
|
10
|
-
runType:
|
|
10
|
+
runType: 'lint' | 'test' | 'analyze';
|
|
11
11
|
executions?: Execution[];
|
|
12
12
|
rules?: ToolRun['rules'];
|
|
13
13
|
duration?: number;
|
|
@@ -15,27 +15,60 @@ export declare function createToolRun(opts: {
|
|
|
15
15
|
artifacts?: ToolRun['artifacts'];
|
|
16
16
|
invocations?: ToolRun['invocations'];
|
|
17
17
|
}): ToolRun;
|
|
18
|
-
|
|
18
|
+
/** Build a {@link LintExecution} (one rule evaluated against one location). */
|
|
19
|
+
export declare function createLintExecution(opts: {
|
|
20
|
+
location: Location;
|
|
21
|
+
status: ExecutionStatus;
|
|
22
|
+
ruleId?: string;
|
|
23
|
+
findings?: FindingRecord[];
|
|
24
|
+
}): LintExecution;
|
|
25
|
+
/** Build an {@link AnalyzeExecution} (one rule evaluated against one location). */
|
|
26
|
+
export declare function createAnalyzeExecution(opts: {
|
|
27
|
+
location: Location;
|
|
28
|
+
status: ExecutionStatus;
|
|
29
|
+
ruleId?: string;
|
|
30
|
+
findings?: FindingRecord[];
|
|
31
|
+
}): AnalyzeExecution;
|
|
32
|
+
/** Build a {@link TestCaseExecution}; findings live on its {@link TestStep}s. */
|
|
33
|
+
export declare function createTestCaseExecution(opts: {
|
|
34
|
+
name: string;
|
|
35
|
+
status: ExecutionStatus;
|
|
36
|
+
ruleId?: string;
|
|
37
|
+
steps?: TestStep[];
|
|
38
|
+
}): TestCaseExecution;
|
|
39
|
+
/** Build a {@link TestStep}. */
|
|
40
|
+
export declare function createTestStep(opts: {
|
|
41
|
+
name: string;
|
|
19
42
|
location: Location;
|
|
20
43
|
findings?: FindingRecord[];
|
|
21
|
-
children?: Execution[];
|
|
22
44
|
httpTransactions?: ReportHttpTransaction[];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
45
|
+
}): TestStep;
|
|
46
|
+
/**
|
|
47
|
+
* Build lint executions from resolved rule violations. Each violation becomes a
|
|
48
|
+
* single failed {@link LintExecution} keyed by its `(rule × location)`. The
|
|
49
|
+
* resolved severity is preserved via the `failed` status override.
|
|
50
|
+
*/
|
|
26
51
|
export declare function executionsFromViolations(violations: EvaluatedRuleViolation[], format: ThymianFormat): Execution[];
|
|
27
52
|
/**
|
|
28
|
-
* Build report {@link Execution}s from a full {@link RunRulesResult}
|
|
29
|
-
*
|
|
53
|
+
* Build report {@link Execution}s from a full {@link RunRulesResult}. Emits one
|
|
54
|
+
* flat leaf execution per `(rule × location)` entry — there is no per-rule
|
|
55
|
+
* grouping wrapper. Passing entries are emitted as `passed` executions (they are
|
|
56
|
+
* no longer skipped as noise); violations become `failed` status and `rule-skip`
|
|
57
|
+
* becomes `skipped` status.
|
|
58
|
+
*/
|
|
59
|
+
export declare function executionsFromRunRulesResult<TDiagnostics>(result: RunRulesResult<TDiagnostics>, rules: Rule[], format: ThymianFormat, kind?: 'lint' | 'analyze'): Execution[];
|
|
60
|
+
/**
|
|
61
|
+
* Map a rule-author {@link RuleFinding} to a report {@link FindingRecord}, or
|
|
62
|
+
* `undefined` when the finding is a producer-only signal that must not surface as
|
|
63
|
+
* a report finding.
|
|
30
64
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
65
|
+
* `rule-skip` is filtered out here: it is a signal the builder maps to
|
|
66
|
+
* `status: skipped`, never a report finding. Report findings also carry neither
|
|
67
|
+
* `ruleId` (inherited from the execution) nor `severity` (a violation's severity
|
|
68
|
+
* is resolved from the execution's `ruleId`/`status`).
|
|
35
69
|
*/
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
38
|
-
export declare function ruleFindingsToFindingRecords(findings: RuleFinding[], fallbackRuleId?: string): FindingRecord[];
|
|
70
|
+
export declare function ruleFindingToFindingRecord(finding: RuleFinding): FindingRecord | undefined;
|
|
71
|
+
export declare function ruleFindingsToFindingRecords(findings: RuleFinding[]): FindingRecord[];
|
|
39
72
|
/**
|
|
40
73
|
* Map executed rules to report {@link RuleDescriptor}s for `ToolRun.rules`.
|
|
41
74
|
* Applies the same filter as `runRules` (enabled, not informational-only) plus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-builder.d.ts","sourceRoot":"","sources":["../../src/report/report-builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"report-builder.d.ts","sourceRoot":"","sources":["../../src/report/report-builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AAC7F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAM9D,OAAO,KAAK,EACV,sBAAsB,EACtB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,aAAa,EACb,aAAa,EACb,QAAQ,EACR,MAAM,EACN,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,IAAI,EACJ,OAAO,EACR,MAAM,aAAa,CAAC;AAErB,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,EAAE,EACf,aAAa,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,GACtC,MAAM,CAOR;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACrC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACtC,GAAG,OAAO,CAaV;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,IAA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