Skip to content

Commit 4a6e8da

Browse files
committed
refactor(ui): Refactor some schemas
In an earlier commit [1], the Zod enum schema for the repository type was already refactored. Continue by also changing (hopefully only temporarily) the enum schemas of the run status, severity and vulnerability rating, to decouple from the old query client. For the justification of this, see [1]. [1]: 06c287a Signed-off-by: Jyrki Keisala <[email protected]>
1 parent 3d3db5f commit 4a6e8da

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

ui/src/schemas/index.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,13 @@
1919

2020
import z from 'zod';
2121

22-
import {
23-
$OrtRunStatus,
24-
$Severity,
25-
$VulnerabilityRating,
26-
} from '@/api/requests/schemas.gen';
27-
2822
// Enum schema for the groupId parameter of the Groups endpoints
2923
export const groupsSchema = z.enum(['admins', 'writers', 'readers']);
3024

31-
// Enum schema for the possible values of the status parameter of the ORT run
32-
export const runStatusSchema = z.enum($OrtRunStatus.enum);
33-
34-
// Enum schema for the possible values of the severities
35-
export const severitySchema = z.enum($Severity.enum);
36-
3725
// Enum schema and type for the resolved statuses of issues, vulnerabilites, and rule violations
3826
export const itemResolvedSchema = z.enum(['Resolved', 'Unresolved']);
3927
export type ItemResolved = z.infer<typeof itemResolvedSchema>;
4028

41-
// Enum schema for the possible values of the advisory overall vulnerability ratings
42-
export const vulnerabilityRatingSchema = z.enum($VulnerabilityRating.enum);
43-
4429
// Enum schema and type for the possible values of the issue categories.
4530
export const issueCategorySchema = z.enum([
4631
'Build System',
@@ -70,6 +55,27 @@ export const repositoryTypeSchema = z.enum([
7055
'SUBVERSION',
7156
]);
7257

58+
// Enum schema for the possible values of the status parameter of the ORT run
59+
export const runStatusSchema = z.enum([
60+
'CREATED',
61+
'ACTIVE',
62+
'FINISHED',
63+
'FAILED',
64+
'FINISHED_WITH_ISSUES',
65+
]);
66+
67+
// Enum schema for the possible values of the severities
68+
export const severitySchema = z.enum(['HINT', 'WARNING', 'ERROR']);
69+
70+
// Enum schema for the possible values of the advisory overall vulnerability ratings
71+
export const vulnerabilityRatingSchema = z.enum([
72+
'NONE',
73+
'LOW',
74+
'MEDIUM',
75+
'HIGH',
76+
'CRITICAL',
77+
]);
78+
7379
// Search parameter validation schemas
7480

7581
export const paginationSearchParameterSchema = z.object({

0 commit comments

Comments
 (0)