refactor: split api-client.ts into focused domain modules#405
Merged
Conversation
Split the 1977-line src/lib/api-client.ts monolith into 11 domain modules under src/lib/api/: - infrastructure.ts: shared helpers, types, constants, raw request fns - organizations.ts: org CRUD and region discovery - projects.ts: project CRUD, search, DSN keys - teams.ts: team CRUD, project teams - repositories.ts: repository listing - issues.ts: issue listing, lookup, status updates - events.ts: event retrieval and resolution - traces.ts: trace details and transactions - logs.ts: log listing, detailed fetch, trace-logs - seer.ts: Seer AI root cause analysis and planning - trials.ts: product trial management - users.ts: current user info The original api-client.ts becomes a pure barrel re-export (~100 lines) so all 52+ existing imports remain unchanged. Zero test files modified. No functional changes — this is a pure structural refactor.
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Init
Other
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 99.41%. Project has 697 uncovered lines. Files with missing lines (4)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.58% 96.65% +1.07%
==========================================
Files 147 159 +12
Lines 20755 20784 +29
Branches 0 0 —
==========================================
+ Hits 19838 20087 +249
- Misses 917 697 -220
- Partials 0 0 —Generated by Codecov Action |
Add comprehensive tests for the uncovered functions across all 12 domain modules in src/lib/api/. Brings line coverage to 80%+ on every module: - issues.ts: 25% → 99% (listIssuesAllPages, getIssue, getIssueInOrg, etc.) - teams.ts: 28% → 100% (listTeams, createTeam, addMemberToTeam, etc.) - projects.ts: 42% → 87% (listProjects, createProject, getProjectKeys, etc.) - users.ts: 33% → 100% (getCurrentUser) - events.ts: 56% → 99% (getLatestEvent, getEvent, resolveEventInOrg) - traces.ts: 71% → 100% (getDetailedTrace) - repositories.ts: 65% → 100% (listRepositories) - logs.ts: 73% → 100% (listLogs) - infrastructure.ts: 89% → 99% (apiRequest, error paths, Zod validation) 86 new tests, all passing.
betegon
added a commit
that referenced
this pull request
Mar 13, 2026
Dashboard API functions now live in src/lib/api/dashboards.ts following the domain module pattern from #405. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
betegon
added a commit
that referenced
this pull request
Mar 13, 2026
Resolve conflict from api-client split (#405). Move normalizeTraceSpan and the getDetailedTrace normalization call into src/lib/api/traces.ts. Rename test file to kebab-case to satisfy lint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 tasks
BYK
pushed a commit
that referenced
this pull request
Mar 17, 2026
Dashboard API functions now live in src/lib/api/dashboards.ts following the domain module pattern from #405. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Split the 1,977-line
src/lib/api-client.tsinto 12 focused domain modules undersrc/lib/api/:infrastructure.tsorganizations.tsprojects.tsteams.tsrepositories.tsissues.tsevents.tstraces.tslogs.tsseer.tstrials.tsusers.tsThe original
api-client.tsis now a 100-line barrel re-export, preserving all existing import paths (import { ... } from "./api-client.js"andimport * as apiClientfor spyOn mocking). No consumer changes required.Pure refactor — no functional changes.