Skip to content

Move report row parsing into adapters#139

Merged
asizikov merged 1 commit into
mainfrom
asizikov/adapter-owned-parsing
Jun 6, 2026
Merged

Move report row parsing into adapters#139
asizikov merged 1 commit into
mainfrom
asizikov/adapter-owned-parsing

Conversation

@asizikov

@asizikov asizikov commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Adapter-owned parsing lets runPipeline use 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

Commit Change
refactor: move report row parsing into adapters Extends UsageReportAdapter with parseRecord, routes transition-period parsing through existing normalization/backfill behavior, exposes a native parse hook, and keeps native validation throwing before production processing reaches aggregators.
  • Return the selected adapter from file-format validation so the processing pass does not re-detect report format from rows.
  • Use reportAdapter.parseRecord(...) in runPipeline instead of directly calling transition-period parsing.
  • Add adapter tests covering transition-period normalization/backfill and the native unsupported boundary.

Testing

  • npm test -- --run src/pipeline/reportAdapters.test.ts src/pipeline/runPipeline.test.ts src/pipeline/parser.test.ts
  • npm test
  • npm run lint
  • npm run build

Checklist

  • Specs lint passes (npm run lint)
  • Tests updated if applicable
  • Documentation updated if applicable

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UsageReportAdapter with parseRecord(...) and implement adapter-specific parsing for transition-period vs native AI Credits.
  • Update runPipeline to reuse the adapter returned from file-format validation and call reportAdapter.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

@asizikov asizikov merged commit 26fc1ef into main Jun 6, 2026
10 checks passed
@asizikov asizikov deleted the asizikov/adapter-owned-parsing branch June 6, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants