Move report row parsing into adapters#139
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors usage-report row parsing so it is owned by the selected UsageReportAdapter, allowing runPipeline to use the adapter chosen during preflight/format validation for consistent row normalization and unsupported-format handling.
Changes:
- Extend
UsageReportAdapterwithparseRecord(...)and implement adapter-specific parsing for transition-period vs native AI Credits. - Update
runPipelineto reuse the adapter returned from file-format validation and callreportAdapter.parseRecord(...)for row parsing. - Add/adjust adapter tests to cover transition-period normalization/backfill behavior and the native unsupported boundary (including date normalization via the native parse hook).
Show a summary per file
| File | Description |
|---|---|
| src/pipeline/runPipeline.ts | Returns the selected adapter from format validation and uses adapter-owned parseRecord during processing. |
| src/pipeline/reportAdapters.ts | Adds parseRecord to the adapter interface and wires parsing implementations for each adapter. |
| src/pipeline/reportAdapters.test.ts | Adds tests asserting adapter parsing behavior for transition-period normalization and native AI Credits unsupported handling. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
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
Adapter-owned parsing lets
runPipelineuse the report adapter selected during preflight for row parsing, keeping format validation and row normalization on the same adapter boundary. This preserves transition-period billing preview behavior while keeping native AI Credits uploads unsupported until native UI mode is ready.Changes
refactor: move report row parsing into adaptersUsageReportAdapterwithparseRecord, routes transition-period parsing through existing normalization/backfill behavior, exposes a native parse hook, and keeps native validation throwing before production processing reaches aggregators.reportAdapter.parseRecord(...)inrunPipelineinstead of directly calling transition-period parsing.Testing
npm test -- --run src/pipeline/reportAdapters.test.ts src/pipeline/runPipeline.test.ts src/pipeline/parser.test.tsnpm testnpm run lintnpm run buildChecklist
npm run lint)