·
445 commits
to main
since this release
fix: CLI convert saves the returned .apkg (not a fake job poll) (#3708)
This is the real fix for `2anki convert` — built against the actual
endpoint this time, read from source.
### What was wrong
The convert command assumed `/api/upload/file` returns a JSON job to
poll. It does not. Reading `UploadService.handleUpload`:
- **Single deck** → `200` with raw `application/apkg` **bytes**, plus
`File-Name` and `X-Card-Count` headers.
- **Multiple decks** → `200` with JSON `{ kind:"batch", decks:[{
filename, downloadUrl:"/download/:id/:file" }] }` (that download route
is public — unguessable UUID).
So every successful convert returned a body the CLI blindly
`JSON.parse`d as if binary → threw → `Upload failed.`
### Fix
`client.convert` now branches on `content-type`:
- single → save the bytes to `<deck name>.apkg` (from the `File-Name`
header), report the card count;
- batch → download each deck from its `downloadUrl` and save it.
Tests cover the single-binary path, the batch-JSON path, the `pakker`
field name, and the error path.
no changelog entry — invite-only under-development CLI.
🤖 Generated with [Claude Code](https://claude.com/claude-code)