Skip to content

Commit b319c4e

Browse files
committed
feat: add enriched fields
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 1a3f3bc commit b319c4e

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

backend/src/api/public/v1/packages/getPackage.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,23 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
4040
const scorecardScore = pkg.scorecardScore != null ? Number(pkg.scorecardScore) : null
4141
const mappingConfidence =
4242
pkg.repoMappingConfidence != null ? Number(pkg.repoMappingConfidence) : null
43+
const healthScoreTotal =
44+
pkg.healthScore ?? (scorecardScore !== null ? Math.round(scorecardScore * 10) : null)
4345

4446
ok(res, {
4547
purl: pkg.purl,
4648
name: pkg.name,
4749
ecosystem: pkg.ecosystem,
4850
latestVersion: pkg.latestVersion ?? null,
4951
general: {
50-
healthScore: scorecardScore !== null ? Math.round(scorecardScore * 10) : null,
52+
healthScore: healthScoreTotal,
53+
healthScoreDetails: {
54+
total: healthScoreTotal,
55+
label: pkg.healthLabel,
56+
maintainerHealth: pkg.maintainerHealthScore,
57+
securitySupplyChain: pkg.securitySupplyChainScore,
58+
developmentActivity: pkg.developmentActivityScore,
59+
},
5160
healthBand: computeHealthBand(scorecardScore),
5261
impact: {
5362
impactScore:
@@ -58,7 +67,7 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
5867
transitiveReach: pkg.transitiveReach,
5968
},
6069
riskSignals: {
61-
lifecycle: null,
70+
lifecycle: pkg.lifecycleLabel ?? null,
6271
maintainerBusFactor: pkg.maintainerCount,
6372
lastRelease: pkg.latestReleaseAt ? pkg.latestReleaseAt.toISOString() : null,
6473
hasSecurityFile: pkg.hasSecurityFile,
@@ -67,6 +76,7 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
6776
openSSFScorecard: scorecardScore,
6877
},
6978
},
79+
signalCoverageHealth: pkg.signalCoverageHealth ?? null,
7080
assessment: null,
7181
security: {
7282
securityContacts: null,

backend/src/api/public/v1/packages/openapi.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ components:
291291
- integer
292292
- 'null'
293293
example: 18
294+
label:
295+
type:
296+
- string
297+
- 'null'
298+
example: Good
294299
impact:
295300
type:
296301
- object
@@ -466,6 +471,12 @@ components:
466471
history:
467472
type: object
468473
description: Package history data. Empty in v1.
474+
signalCoverageHealth:
475+
type:
476+
- object
477+
- 'null'
478+
description: Signal coverage health data enriched by Tinybird. Null until enriched.
479+
additionalProperties: true
469480

470481
# ── Metrics ──────────────────────────────────────────────────────────────────
471482

services/libs/data-access-layer/src/osspckgs/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,14 @@ export interface PackageDetailRow {
618618
downloadsLast30d: string | null
619619
maintainerCount: number
620620
transitiveReach: number | null
621+
// Tinybird-enriched health fields
622+
healthScore: number | null
623+
healthLabel: string | null
624+
maintainerHealthScore: number | null
625+
securitySupplyChainScore: number | null
626+
developmentActivityScore: number | null
627+
lifecycleLabel: string | null
628+
signalCoverageHealth: Record<string, unknown> | null
621629
}
622630

623631
export interface AdvisoryRow {
@@ -672,6 +680,13 @@ export async function getPackageDetailByPurl(
672680
LIMIT 1
673681
) AS "downloadsLast30d",
674682
(SELECT COUNT(*)::int FROM package_maintainers pm WHERE pm.package_id = p.id) AS "maintainerCount",
683+
p.health_score AS "healthScore",
684+
p.health_label AS "healthLabel",
685+
p.maintainer_health_score AS "maintainerHealthScore",
686+
p.security_supply_chain_score AS "securitySupplyChainScore",
687+
p.development_activity_score AS "developmentActivityScore",
688+
p.lifecycle_label AS "lifecycleLabel",
689+
p.signal_coverage_health AS "signalCoverageHealth",
675690
-- TODO: precompute and store in packages.transitive_reach_prank; full window scan is too slow at npm scale (~24s for npm)
676691
-- (
677692
-- SELECT r.prank

0 commit comments

Comments
 (0)