refactor: split billConverters into focused, testable modules#75
Open
mikaalnaik wants to merge 1 commit into
Open
refactor: split billConverters into focused, testable modules#75mikaalnaik wants to merge 1 commit into
mikaalnaik wants to merge 1 commit into
Conversation
Break the single billConverters.ts into a billConverters/ directory with one responsibility per file (types, default analysis, the two converters, and a shared final_judgment normalizer). An index.ts barrel preserves the existing @/utils/billConverters import path. Unify the two duplicated, slightly-inconsistent final_judgment normalizers into a single pure normalizeFinalJudgment() and add unit tests for it and for fromBuildCanadaDbBill. Co-Authored-By: Claude Opus 4.8 <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.
What
Refactors the single 298-line
src/utils/billConverters.tsinto abillConverters/directory with one responsibility per file, and adds unit tests.index.ts@/utils/billConvertersimport working unchangedtypes.tsUnifiedBillinterfacenormalize-final-judgment.tsdefault-analysis.tsBillAnalysisfactory + tenet constantfrom-build-canada-db-bill.tsfrom-civics-project-api-bill.tsWhy
The converters were a single large file with no tests and duplicated logic. Splitting them makes the pure pieces individually testable.
Notable change
The
final_judgmentlogic was duplicated inline in both converters with a subtle inconsistency — the DB version cast the raw value (so"YES"passed through un-lowercased) while the API version lowercased it. Both now use a single purenormalizeFinalJudgment(value, fallback)returning a clean lowercase"yes" | "no" | "abstain". Behaviorally equivalent downstream (consumers likeshouldShowDeterminationalready lowercase); thefallbackparam preserves the API converter's behavior of falling back to the default analysis judgment rather than always"abstain".Tests
12 new tests (5 for
normalizeFinalJudgment, 7 forfromBuildCanadaDbBill). Full suite: 41 passing.type-checkandbiomeclean.🤖 Generated with Claude Code