refactor(api): extend #206 type-safety to replication (#359 batch 4)#380
Merged
refactor(api): extend #206 type-safety to replication (#359 batch 4)#380
Conversation
…batch 4) Apply the #206 playbook to replication.ts. 11 `as never` casts removed. src/lib/api/replication.ts: + adaptPeerInstance / adaptPeerInstanceList — narrowEnum the PeerStatus union ("online" | "offline" | "syncing" | "degraded"), normalize SDK's `?: string | null` to local type's `: string | null` + adaptPeerConnection — coerce optional latency_ms / bandwidth_estimate_bps (`?: number | null`) to `0` so the connection table doesn't render "undefined ms" + adaptIdentity — explicit field forwarding + adaptRegisterRequest / adaptAssignRequest — explicit field forwarding so a future local-type addition surfaces at typecheck + assertData on every successful read Type honesty: - Dropped api_key, sync_filter, updated_at from PeerInstance — three fields declared on the local type pre-#359, never populated by the SDK, and never read by any consumer (grep -rn '\.api_key\|...' against src/ returns hits only on form state, not PeerInstance). - Dropped source_peer_id from PeerConnection (same reasoning). Tests rewritten with realistic SDK fixtures (typed as Sdk* for compile- time drift detection) and assertions on adapter output. New regression tests for: empty response body, status enum fallback, undefined→null nullable normalization, register-body shape, assign-body shape, latency/bandwidth → 0 coercion. CHANGELOG entry under [Unreleased] / Changed. Closes #359 (partial — batch 4 of N). Remaining: dependency-track, promotion (medium), sbom, security, sso (large).
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
This was referenced May 9, 2026
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 4). Same playbook as batches 1-3 (PRs #376/#377/#379) for
src/lib/api/replication.ts. 11as neverremoved; zero retained casts. Also drops 4 dead fields from local types (api_key/sync_filter/updated_aton PeerInstance,source_peer_idon PeerConnection) — all declared but unpopulated and unread.Acceptance criteria
as unknown as/as neverin changed filesTest plan
npm test— 2068/2068npm run lint— 0 errorsnpm run build— succeeds (TypeScript checked, Next prerender clean)Remaining
dependency-track / promotion (medium); sbom / security / sso (large) — to be split across subsequent PRs to keep review tractable.
🤖 Generated with Claude Code