Skip to content

Add reports create, portfolios list, and file output for reports - #1

Merged
cprice70 merged 4 commits into
mainfrom
users/cprice/reports-create
Oct 11, 2026
Merged

cprice70 merged 4 commits into
mainfrom
users/cprice/reports-create

Conversation

@cprice70

Copy link
Copy Markdown
Owner

Summary

  • reports create --type search-term|targeting|campaign --start --end builds a Sponsored Products v3 async report (spSearchTerm / spTargeting / spCampaigns) with 7-day attribution columns, polls until complete, and prints or writes the rows. --daily gives one row per day, --no-wait returns the report ID, --out writes CSV or JSON by extension, --timeout caps the wait.
  • reports get gains --out.
  • portfolios list so report rows can be joined to portfolio names.
  • Client gains createReport, waitForReport, getPortfolios; output gains toCsv.

The campaign preset omits portfolioId because the spCampaigns report type rejects it; join on campaignId against campaigns list instead.

Testing

  • npm run build clean, npx vitest run 31 passing (8 new in reports.test.ts: preset shapes, CSV escaping, create/no-wait, create with --out, bad preset, get with JSON out).
  • Live run against the RedFive US profile: all three report types generated and downloaded for 2026-09-11 to 2026-10-10 (1042 / 1020 / 340 rows); totals matched the console for the same window.

- Update dependency versions: axios ^1.7.7, dotenv ^16.4.0, @types/node ^20.14.0, tsx ^4.18.0, typescript ^5.6.0, vitest ^2.1.0
- Add prettier dev dependency for code formatting
- Update package.json metadata: author, repository, homepage, keywords
- Add npm scripts: 'format' (prettier) and 'clean'
- Fix vitest.config.ts coverage configuration to exclude only node_modules and dist
- Create LICENSE file with MIT license text
- Create .env.example with explanatory comments for required environment variables
Adds `reports create --type search-term|targeting|campaign` which builds a
Sponsored Products v3 async report (spSearchTerm, spTargeting, spCampaigns)
with 7-day attribution columns, polls until complete, and prints or writes the
rows. `--daily` switches to one row per day, `--no-wait` returns the report ID,
and `--out` writes CSV or JSON (by extension). `reports get` gains `--out`.

Adds `portfolios list` so report rows can be joined to portfolio names.

Client gains generic createReport, waitForReport, and getPortfolios methods;
output gains a toCsv helper. The campaign preset omits portfolioId because the
spCampaigns report type rejects it.
The lock file pinned vitest 4.1.0 while package.json asks for ^2.1.0, so
npm ci failed in CI with missing and invalid entries. Regenerated with
npm install; vitest resolves to 2.1.x and npm ci now succeeds.
@cprice70
cprice70 merged commit 4d72288 into main Oct 11, 2026
2 checks passed
@cprice70
cprice70 deleted the users/cprice/reports-create branch October 11, 2026 16:22
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.

1 participant