@@ -20,33 +20,38 @@ const LIFECYCLE_SET = new Set<string>(LIFECYCLE_VALUES)
2020
2121const boolParam = z . preprocess ( ( v ) => v === 'true' , z . boolean ( ) ) . default ( false )
2222
23- const querySchema = z . object ( {
24- page : z . coerce . number ( ) . int ( ) . min ( 1 ) . default ( 1 ) ,
25- pageSize : z . coerce . number ( ) . int ( ) . min ( 1 ) . max ( MAX_PAGE_SIZE ) . default ( 25 ) ,
26- ecosystem : z . string ( ) . trim ( ) . optional ( ) ,
27- lifecycle : z . enum ( LIFECYCLE_VALUES ) . optional ( ) ,
28- name : z . string ( ) . trim ( ) . optional ( ) ,
29- purl : purlFilterSchema ,
30- status : z
31- . enum ( [
32- 'unassigned' ,
33- 'open' ,
34- 'assessing' ,
35- 'active' ,
36- 'needs_attention' ,
37- 'escalated' ,
38- 'blocked' ,
39- 'inactive' ,
40- ] )
41- . optional ( ) ,
42- healthBand : z . enum ( HEALTH_BAND_VALUES ) . optional ( ) ,
43- vulnSeverity : z . enum ( [ 'any' , 'high' , 'critical' , 'none' ] ) . optional ( ) ,
44- staleOnly : boolParam ,
45- unstewardedOnly : boolParam ,
46- busFactor1Only : boolParam ,
47- sortBy : z . enum ( [ 'name' , 'risk' , 'impact' , 'openVulns' , 'health' ] ) . default ( 'risk' ) ,
48- sortDir : z . enum ( [ 'asc' , 'desc' ] ) . default ( 'desc' ) ,
49- } )
23+ const querySchema = z
24+ . object ( {
25+ page : z . coerce . number ( ) . int ( ) . min ( 1 ) . default ( 1 ) ,
26+ pageSize : z . coerce . number ( ) . int ( ) . min ( 1 ) . max ( MAX_PAGE_SIZE ) . default ( 25 ) ,
27+ ecosystem : z . string ( ) . trim ( ) . optional ( ) ,
28+ lifecycle : z . enum ( LIFECYCLE_VALUES ) . optional ( ) ,
29+ name : z . string ( ) . trim ( ) . optional ( ) ,
30+ purl : purlFilterSchema ,
31+ status : z
32+ . enum ( [
33+ 'unassigned' ,
34+ 'open' ,
35+ 'assessing' ,
36+ 'active' ,
37+ 'needs_attention' ,
38+ 'escalated' ,
39+ 'blocked' ,
40+ 'inactive' ,
41+ ] )
42+ . optional ( ) ,
43+ healthBand : z . enum ( HEALTH_BAND_VALUES ) . optional ( ) ,
44+ vulnSeverity : z . enum ( [ 'any' , 'high' , 'critical' , 'none' ] ) . optional ( ) ,
45+ staleOnly : boolParam ,
46+ unstewardedOnly : boolParam ,
47+ busFactor1Only : boolParam ,
48+ sortBy : z . enum ( [ 'name' , 'risk' , 'impact' , 'openVulns' , 'health' ] ) . default ( 'risk' ) ,
49+ sortDir : z . enum ( [ 'asc' , 'desc' ] ) . optional ( ) ,
50+ } )
51+ . transform ( ( data ) => ( {
52+ ...data ,
53+ sortDir : data . sortDir ?? ( data . sortBy === 'name' || data . sortBy === 'health' ? 'asc' : 'desc' ) ,
54+ } ) )
5055
5156export async function packageListHandler ( req : Request , res : Response ) : Promise < void > {
5257 const params = validateOrThrow ( querySchema , req . query )
0 commit comments