-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathaudit-output.ts
More file actions
63 lines (58 loc) · 1.79 KB
/
Copy pathaudit-output.ts
File metadata and controls
63 lines (58 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { z } from 'zod';
import { createDuplicateSlugsCheck } from './implementation/checks.js';
import {
nonnegativeNumberSchema,
scoreSchema,
scoreTargetSchema,
slugSchema,
} from './implementation/schemas.js';
import { issueSchema } from './issue.js';
import { tableSchema } from './table.js';
import { treeSchema } from './tree.js';
export const auditValueSchema = nonnegativeNumberSchema.meta({
description: 'Raw numeric value',
});
export const auditDisplayValueSchema = z
.string()
.optional()
.meta({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" });
export const auditDetailsSchema = z
.object({
issues: z
.array(issueSchema)
.meta({ description: 'List of findings' })
.optional(),
table: tableSchema('Table of related findings').optional(),
trees: z
.array(treeSchema)
.meta({ description: 'Findings in tree structure' })
.optional(),
})
.meta({
title: 'AuditDetails',
description: 'Detailed information',
});
export type AuditDetails = z.infer<typeof auditDetailsSchema>;
export const auditOutputSchema = z
.object({
slug: slugSchema.meta({ description: 'Reference to audit' }),
displayValue: auditDisplayValueSchema,
value: auditValueSchema,
score: scoreSchema,
scoreTarget: scoreTargetSchema,
details: auditDetailsSchema.optional(),
})
.meta({
title: 'AuditOutput',
description: 'Audit information',
});
export type AuditOutput = z.infer<typeof auditOutputSchema>;
export const auditOutputsSchema = z
.array(auditOutputSchema)
.check(createDuplicateSlugsCheck('Audit'))
.meta({
title: 'AuditOutputs',
description:
'List of JSON formatted audit output emitted by the runner process of a plugin',
});
export type AuditOutputs = z.infer<typeof auditOutputsSchema>;