Skip to content

refactor(api): extend #206 type-safety to dependency-track (#359 batch 6)#382

Merged
brandonrc merged 1 commit intomainfrom
harden/359-type-safety-dependency-track
May 9, 2026
Merged

refactor(api): extend #206 type-safety to dependency-track (#359 batch 6)#382
brandonrc merged 1 commit intomainfrom
harden/359-type-safety-dependency-track

Conversation

@brandonrc
Copy link
Copy Markdown
Contributor

Summary

Closes #359 (partial — batch 6). Same playbook as batches 1-5 for src/lib/api/dependency-track.ts. 12 as never removed; zero retained casts. 16 nested adapters for the DT graph (findings → components → vulnerabilities → CWEs → licenses → policies → metrics).

Acceptance criteria

  • No uncommented as unknown as / as never in changed files
  • All tests pass (2077/2077)
  • New code coverage on changed lines ≥ 80%

Test plan

  • npm test — 2077/2077
  • npm run lint — 0 errors
  • npm run build — succeeds (TypeScript + Next prerender clean)

Remaining

promotion (medium); security / sso (large).

🤖 Generated with Claude Code

…359 batch 6)

Apply the #206 playbook to dependency-track.ts. 12 `as never` casts removed.

src/lib/api/dependency-track.ts — 16 nested adapters covering the full DT
graph: status, project, component, componentFull (with resolvedLicense),
vulnerability (with cwe), analysis, attribution, finding, projectMetrics,
portfolioMetrics, policyCondition, policyConditionFull, policyViolation,
policyFull, analysisResponse, license. Each normalizes SDK's optional+
nullable shape to local required-but-nullable, plus per-counter undefined
→ 0 for the metrics types whose every counter the SDK declares optional.

updateAnalysis: forward fields explicitly via adaptUpdateAnalysisRequest
typed as the SDK's UpdateAnalysisBody (the SDK doesn't expose a typed
"UpdateAnalysisRequest" — the body is just an inline UpdateAnalysisBody).

Tests rewritten with realistic SDK fixtures (typed as Sdk* for compile-
time drift detection). New regression tests:
  - status: url undefined → null
  - findings: null analysis/attribution
  - components: null resolvedLicense
  - projectMetrics / portfolioMetrics: empty SDK response → 0 counters
  - updateAnalysis body shape forwarding

CHANGELOG entry under [Unreleased] / Changed.

Closes #359 (partial — batch 6 of N). Remaining: promotion (medium),
security, sso (large).
@brandonrc brandonrc requested a review from a team as a code owner May 9, 2026 19:51
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@brandonrc brandonrc merged commit 4f696eb into main May 9, 2026
18 checks passed
@brandonrc brandonrc deleted the harden/359-type-safety-dependency-track branch May 9, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend #206 type-safety hardening to remaining lib/api modules

1 participant