@@ -11,7 +11,7 @@ export interface PackageMetrics {
1111 criticalPackages : number
1212}
1313
14- export async function getPackageMetrics ( qx : QueryExecutor ) : Promise {
14+ export async function getPackageMetrics ( qx : QueryExecutor ) : Promise < PackageMetrics > {
1515 const row : { total : string ; critical : string } = await qx . selectOne ( `
1616 SELECT
1717 COUNT(*) AS total,
@@ -34,7 +34,10 @@ export interface PackageStewardshipRow {
3434 stewardshipStatus : string | null
3535}
3636
37- export async function getPackagesByStewardshipPurls ( qx : QueryExecutor , purls : string [ ] ) : Promise {
37+ export async function getPackagesByStewardshipPurls (
38+ qx : QueryExecutor ,
39+ purls : string [ ] ,
40+ ) : Promise < PackageStewardshipRow [ ] > {
3841 if ( purls . length === 0 ) return [ ]
3942 return qx . select (
4043 `
@@ -65,7 +68,7 @@ export interface OsspreyMetrics {
6568}
6669
6770// TODO[deprecate]: rename to getAkritesMetrics once /v1/ossprey is removed
68- export async function getOsspreyMetrics ( qx : QueryExecutor ) : Promise {
71+ export async function getOsspreyMetrics ( qx : QueryExecutor ) : Promise < OsspreyMetrics > {
6972 const [ counts , stewardRow ] : [
7073 {
7174 totalPackages : string
@@ -138,7 +141,7 @@ export interface PackageListRow {
138141 lifecycleLabel : string | null
139142 lastActivityType ?: string | null
140143 lastActivityContent ?: string | null
141- lastActivityMetadata ?: Record | null
144+ lastActivityMetadata ?: Record < string , unknown > | null
142145 lastActivityAt ?: Date | null
143146 stewards ?: StewardEntry [ ]
144147 total : string
@@ -196,7 +199,10 @@ export interface PackageStatusCounts {
196199 inactive : number
197200}
198201
199- export type StatusCountsOptions = Omit
202+ export type StatusCountsOptions = Omit <
203+ ListPackagesOptions ,
204+ 'status' | 'page' | 'pageSize' | 'sortBy' | 'sortDir'
205+ >
200206
201207const ALL_STEWARDSHIP_STATUSES = [
202208 'unassigned' ,
@@ -216,9 +222,9 @@ const ALL_STEWARDSHIP_STATUSES = [
216222export async function getPackageStatusCounts (
217223 qx : QueryExecutor ,
218224 opts : StatusCountsOptions ,
219- ) : Promise {
225+ ) : Promise < PackageStatusCounts > {
220226 const conditions : string [ ] = [ 'p.is_critical = true' ]
221- const params : Record = { }
227+ const params : Record < string , unknown > = { }
222228
223229 if ( opts . ecosystem ) {
224230 conditions . push ( 'p.ecosystem = $(ecosystem)' )
@@ -315,7 +321,7 @@ export async function getPackageStatusCounts(
315321 params ,
316322 )
317323
318- const countsMap : Record = { }
324+ const countsMap : Record < string , number > = { }
319325 let all = 0
320326 for ( const row of rows ) {
321327 countsMap [ row . status ] = row . count
@@ -339,9 +345,12 @@ export async function getPackageStatusCounts(
339345 return result
340346}
341347
342- export async function listPackagesForApi ( qx : QueryExecutor , opts : ListPackagesOptions ) : Promise {
348+ export async function listPackagesForApi (
349+ qx : QueryExecutor ,
350+ opts : ListPackagesOptions ,
351+ ) : Promise < { rows : PackageListRow [ ] ; total : number } > {
343352 const conditions : string [ ] = [ 'p.is_critical = true' ]
344- const params : Record = { }
353+ const params : Record < string , unknown > = { }
345354
346355 if ( opts . ecosystem ) {
347356 conditions . push ( 'p.ecosystem = $(ecosystem)' )
@@ -444,7 +453,7 @@ export async function listPackagesForApi(qx: QueryExecutor, opts: ListPackagesOp
444453 const sortDir = opts . sortDir === 'desc' ? 'DESC' : 'ASC'
445454
446455 // Separate paginated params from filter-only params used by the fallback COUNT query
447- const queryParams : Record = {
456+ const queryParams : Record < string , unknown > = {
448457 ...params ,
449458 limit : opts . pageSize ,
450459 offset : ( opts . page - 1 ) * opts . pageSize ,
@@ -551,8 +560,8 @@ export async function listPackagesForApi(qx: QueryExecutor, opts: ListPackagesOp
551560 r_sc.scorecard_score AS "scorecardScore",
552561 p.health_score AS "healthScore",
553562 p.health_label AS "healthLabel",
554- p.latest_release_at AS "latestReleaseAt",
555563 p.lifecycle_label AS "lifecycleLabel",
564+ p.latest_release_at AS "latestReleaseAt",
556565 ${ opts . includeLastActivity === true ? `last_act.activity_type AS "lastActivityType", last_act.content AS "lastActivityContent", last_act.metadata AS "lastActivityMetadata", last_act.created_at AS "lastActivityAt",` : '' }
557566 ${ opts . includeStewards === true ? 'ss_agg.stewards AS stewards,' : '' }
558567 COUNT(*) OVER() AS total
@@ -626,7 +635,7 @@ export interface PackageDetailRow {
626635 securitySupplyChainScore : number | null
627636 developmentActivityScore : number | null
628637 lifecycleLabel : string | null
629- signalCoverageHealth : Record | null
638+ signalCoverageHealth : Record < string , unknown > | null
630639}
631640
632641export interface AdvisoryRow {
@@ -636,7 +645,10 @@ export interface AdvisoryRow {
636645 isCritical : boolean
637646}
638647
639- export async function getPackageDetailByPurl ( qx : QueryExecutor , purl : string ) : Promise {
648+ export async function getPackageDetailByPurl (
649+ qx : QueryExecutor ,
650+ purl : string ,
651+ ) : Promise < PackageDetailRow | null > {
640652 return qx . selectOneOrNone (
641653 `
642654 SELECT
@@ -727,7 +739,7 @@ export interface ScatterPoint {
727739export async function listPackagesForScatter (
728740 qx : QueryExecutor ,
729741 options : { status ?: string [ ] ; ecosystem ?: string } = { } ,
730- ) : Promise {
742+ ) : Promise < ScatterPoint [ ] > {
731743 const { status, ecosystem } = options
732744
733745 // 'unassigned' covers packages with no stewardship row (s.id IS NULL) in addition
@@ -739,7 +751,16 @@ export async function listPackagesForScatter(
739751 : ''
740752 const ecosystemFilter = ecosystem ? `AND p.ecosystem = $(ecosystem)` : ''
741753
742- const rows : Array = await qx . select (
754+ const rows : Array < {
755+ purl : string
756+ name : string
757+ criticalityScore : number
758+ healthScore : number
759+ scorecardScoreRaw : number | null
760+ stewardshipId : string | null
761+ stewardshipStatus : string | null
762+ openVulns : number
763+ } > = await qx . select (
743764 `
744765 SELECT
745766 p.purl,
@@ -795,7 +816,7 @@ export async function getAdvisoriesByPackageId(
795816 resolutions ?: ( 'open' | 'patched' ) [ ]
796817 critical ?: boolean
797818 } ,
798- ) : Promise {
819+ ) : Promise < { rows : AdvisoryRow [ ] ; total : number } > {
799820 const cte = `
800821 WITH advisory_data AS (
801822 SELECT
0 commit comments