Repository navigation
Conversation
- Retry when fetch itself throws (ECONNRESET, DNS, TLS), not only on
429/5xx. The final error names the attempt count and the cause.
- Empty response bodies return { success: true }; the old fallback
reported campaignId "delete" for the delete endpoint.
- The client no longer reads process.env. loadConfig() is the single
source of precedence (env, then file, then defaults) and now fills
in region NA and sandbox false.
- A config file that is not valid JSON prints a warning instead of
being silently treated as missing.
- Type the Login with Amazon token response.
getCampaignPerformance had its own copy of the create/poll/download flow with a 5-second cap, so it almost always returned PENDING and asked the user to poll by hand. It also used 14-day attribution while the reports command uses 7-day, so ACoS differed between the two. Reuse createReport, the campaign preset, and waitForReport. The command waits up to --timeout seconds (default 600) and reads cost and sales7d.
--type, --state, and --targeting were free text. A typo fell through to the Sponsored Products code path silently, and campaigns create accepted sponsoredBrands/sponsoredDisplay even though only the SP request body is implemented, so those calls failed at the API with an opaque error. Add choiceOption(), a case-insensitive commander Option that lists the allowed values in --help and in the error, and restrict create to sponsoredProducts until the SB/SD payloads exist.
- Send a random state value on the consent URL and refuse callbacks whose state does not match, as Amazon's docs recommend, so a forged redirect cannot hand the CLI someone else's authorization code. - Escape everything interpolated into the callback HTML page; the provider's error string was previously reflected verbatim. - Explain EADDRINUSE on the callback port instead of printing the raw listen error, since port 3000 is a common dev-server port. - Move the config save out of the server close callback so the promise resolves with the refresh token and the flow reads top-down.
Every action repeated the same try/catch that printed the error and called process.exit(1). Replace it with runAction(), which prints once and sets process.exitCode so stdout is flushed before exit, and fail() for validation messages that are already user-facing. Also add a prettier config and format src/ with it, and build the CSV header set with a Set instead of repeated includes() scans.
- eslint with typescript-eslint (flat config) and a lint script. Fixes the findings it raised: unused test spies, a dropped error cause, and unused imports. - prettier --check over the whole repo; README table reformatted. - tsconfig.test.json so tsc covers the test files, which the build config excludes and vitest does not typecheck. Fixes two spy typings. - npm run check runs all of the above plus tests; CI and the release workflow call it. - Release workflow refuses a tag that does not match package.json and pins npm to the 11 line instead of latest. - engines.node >=20 to match the CI matrix; README said 18+.
Stacked PRs target a feature branch rather than main and were getting no checks.
2 of 3 tasks
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.
Stacked on #4. Remaining items from the review pass, each its own commit with tests written first.
Client and config
fetchthrowing (ECONNRESET, DNS, TLS) is now retried with the same backoff as 429/5xx. Final error names the attempt count and keeps the cause.process.env;loadConfig()applies env → file → defaults (region NA, sandbox false). A config file that is not valid JSON prints a warning instead of being silently ignored.{ success: true }rather thancampaignId: "delete".Commands
campaigns performancereusescreateReport+ the campaign preset +waitForReport, so it waits up to--timeout(default 600s) instead of giving up after 5s, and uses the same 7-day attribution asreports create.--type,--state,--targetingare restricted to known values (case-insensitive, listed in--helpand in the error).campaigns createonly acceptssponsoredProducts, since only that request body is implemented.runActionwrapper replaces eleven copies of the same try/catch. Errors setprocess.exitCodeso stdout flushes before exit.OAuth login
stateon the consent URL, verified on callback (CSRF).EADDRINUSEon port 3000 gets an actionable message.Tooling
--check,tsconfig.test.jsonso tests are typechecked.npm run checkruns them all; CI and release call it.package.json; npm pinned to the 11 line.engines.node >= 20.Test plan
npm run check— lint, format, typecheck, 74 tests passnpm run buildamazonads auth loginend to end (state round-trip) against a real account