refactor(router): extract platformClients.ts to eliminate credential resolution duplication#494
refactor(router): extract platformClients.ts to eliminate credential resolution duplication#494
Conversation
…resolution duplication
|
@aaight resolve conflicts and explain how did they happen |
Request AddressedWhat was askedResolve merge conflicts with the Changes Made
Root CausePR #492 ( Verification
|
Merge dev into refactor/platform-clients, resolving conflicts in all 5 files (platformClients.ts, acknowledgments.ts, reactions.ts, notifications.ts, and the test file). Conflicts arose because PR #492 (refactor/router-platform-clients) was merged to dev while this PR was open. Both PRs extracted credential resolution into platformClients.ts but with different naming conventions and scope. Resolution adopts dev's naming (resolveTrelloCredentials, resolveJiraCredentials, resolveGitHubHeaders, JiraCredentials.auth) and layers on this PR's additional features (bot identity caches, JIRA cloudId cache, GitHub token resolution, resolveGitHubTokenForAck). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Conflicts resolved and pushed! ✅ What caused the conflicts: PR #492 () was merged to
Resolution strategy: Adopted dev's naming/interface for the overlapping credential resolution helpers (since PR #492 was already merged and has consumers), then layered on this PR's unique contributions (bot identity caches, JIRA cloudId cache, GitHub token resolution in All 5 conflicted files resolved: |
Summary
Refactors the
src/router/platform-dispatch files to eliminate ~20× duplicated credential resolution scaffolding acrossacknowledgments.ts,reactions.ts, andnotifications.ts.src/router/platformClients.ts: Centralized credential resolution helpers for Trello (getTrelloCredentialsForProject), JIRA (getJiraAuthForProject), and GitHub (getGitHubTokenForProject). Also moved bot identity caches (resolveTrelloBotMemberId,resolveJiraBotAccountId) and the JIRA cloudId cache (getJiraCloudId) to this shared module.acknowledgments.ts: Replaced 6× duplicatedlet x; try { x = await getIntegrationCredential(...)blocks with 2-line platform client calls (~333→197 lines).reactions.ts: Replaced credential scaffolding in 3 platform senders with platform client calls (~283→229 lines).notifications.ts: Replaced credential scaffolding in Trello and JIRA timeout notifiers with platform client calls (~221→205 lines).tests/unit/router/platformClients.test.ts: 30 new tests covering credential resolution, caching, TTL expiry, and error handling for all platform client helpers.acknowledgments.tsso existing callers are unaffected.Test plan
platformClients.test.tstests)config/projects.test.tsconfirmed to be pre-existing (not introduced by this PR)Card
https://trello.com/c/7lj1Vu6W/80-find-top-candidate-for-refactoring-and-plan-clean-refactoring-of-it-look-for-god-classes-modules-functions-files-and-code-duplic
🤖 Generated with Claude Code