refactor(api): extend #206 type-safety to sbom (#359 batch 5)#381
Merged
refactor(api): extend #206 type-safety to sbom (#359 batch 5)#381
Conversation
Apply the #206 playbook to sbom.ts. 21 `as never` casts removed. src/lib/api/sbom.ts: + 9 read adapters: adaptSbom / adaptSbomContent / adaptComponent / adaptCveHistory / adaptCveTimelineEntry / adaptCveTrends / adaptLicensePolicy / adaptLicenseCheckResult — each normalizes SDK's `?: T | null` to local type's `: T | null` + 5 write adapters: adaptGenerateRequest / adaptConvertRequest / adaptUpdateCveStatusRequest / adaptUpsertPolicyRequest / adaptCheckRequest — explicit field forwarding so a future local- type addition surfaces at typecheck + narrowCveStatus / narrowPolicyAction — exported helpers for callers that want a typed enum from the string fields the SDK exposes + assertData on every successful read SDK shape mismatches (now explicit + documented): - LicenseCheckResult: SDK returns `violations: string[]` with no `action`; adapter coerces to `{license, reason: ""}` and derives `action: compliant ? "allow" : "block"`. No app consumer calls this endpoint today, so the synthesis is best-effort. - getByArtifact dropped `format?: string` query param: SDK has no query for that endpoint (the pre-#359 cast bypassed types and sent an unsupported query the backend ignored). No consumer was passing format, so end-to-end no-op. Tests rewritten with realistic SDK fixtures (typed as Sdk* for compile- time drift detection). New regression tests: - undefined → null nullable normalization for SbomResponse - getByArtifact does not pass query - checkCompliance synthesizes action + violation rows - checkCompliance allow path CHANGELOG entry under [Unreleased] / Changed. Closes #359 (partial — batch 5 of N). Remaining: dependency-track, promotion (medium), security, sso (large).
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #359 (partial — batch 5). Same playbook as batches 1-4 (PRs #376/#377/#379/#380) for
src/lib/api/sbom.ts. 21as neverremoved; zero retained casts (SDK type leaks documented in inline comments).Notable shape mismatches surfaced + documented
LicenseCheckResult: SDK hasviolations: string[]and noaction. Adapter synthesizes{license, reason: ""}rows and derivesactionfromcompliant. No app consumer today; best-effort synthesis is documented.getByArtifactdropped its deadformat?: stringparameter — the SDK has no query for this endpoint and the cast was sending an ignored query.Acceptance criteria
as unknown as/as neverin changed filesTest plan
npm test— 2070/2070npm run lint— 0 errorsnpm run build— succeeds (TypeScript + Next prerender clean)Remaining
dependency-track / promotion (medium); security / sso (large).
🤖 Generated with Claude Code