You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
client: keep pagination metadata without --all (#45)
## Description
Replaces PR #31 (which added `--all` auto-pagination) with a minimal version that keeps only what downstream PRs depend on. James flagged `--all` as an anti-pattern ripe for abuse — agents that need multiple pages should paginate explicitly with `--token`.
**What changed:**
The `Spec` struct previously carried `TokenField` and `DataField` — per-spec strings that named the cursor field and data envelope field. In practice, every HeyGen v3 endpoint uses the same values (`"next_token"` and `"data"`), so these were redundant. This PR:
1. **Replaces `TokenField`/`DataField` with `Paginated bool`** on `command.Spec`. Codegen sets `Paginated: true` for list endpoints (detected by the presence of a `next_token` response field + `token` query param). The bool is metadata only — it marks which commands support cursor pagination but doesn't drive any runtime behavior yet.
2. **Exports `client.APIDataField` constant** (`"data"`) — a single source of truth for the response envelope field name. The builder passes this to `formatter.Data()` for `--human` table rendering. Downstream PRs (polling, auth status) also use it.
3. **Updates codegen** — `detectPagination()` now returns `bool` instead of `(bool, string, string)`. Checks both response schema (has `next_token`) and request params (has `token` query param) before marking as paginated. Golden files updated.
4. **Documents the pagination contract** in CLAUDE.md and AGENTS.md: manual pagination via `--limit` and `--token`, no `--all`.
**What was removed vs PR #31:** `ExecuteAll()`, `extractPage()`, `marshalItems()`, `cloneInvocation()`, `--all` flag registration, `--all`/`--token` mutual exclusion, and all associated tests.
**What was kept:** `Paginated bool` (used by downstream PRs for flag presence detection), `APIDataField` (used by builder, polling, and auth status), and `detectPagination()` in codegen.
## Testing
- All existing tests pass — `make test` across linux/macos/windows
- `TestGroupEndpoints_Pagination` updated to assert `Paginated: true` instead of `TokenField`/`DataField` strings
- `videoListSpec` in builder tests updated to use `Paginated: true`
- Golden files regenerated and verified
- `./bin/heygen video list --all` → unknown flag error (confirmed removed)
- `./bin/heygen video list --limit 5` → works (manual pagination unchanged)
-`JSONFormatter` ignores `dataField` and `columns` — always renders the full response. No contract change from the agent's perspective.
63
63
-`HumanFormatter` uses `dataField` to unwrap the envelope, then renders a table (array) or key-value (object).
64
64
65
+
### Pagination
66
+
- List commands paginate manually via API query flags like `--limit` and `--token`.
67
+
- Do not add a generic `--all` mode. If an agent needs multiple pages, it should read `next_token` from the JSON response and request the next page explicitly.
68
+
65
69
### Auth and `skipAuth`
66
70
`initContext()` resolves credentials via `ChainCredentialResolver` (env → file). Commands that don't need auth (e.g., `auth login`, `config set`) annotate with `skipAuth: true` in Cobra `Annotations`. Check `skipAuth` before adding new non-auth commands.
-`JSONFormatter` ignores `dataField` and `columns` — always renders the full response. No contract change from the agent's perspective.
61
61
-`HumanFormatter` uses `dataField` to unwrap the envelope, then renders a table (array) or key-value (object).
62
62
63
+
### Pagination
64
+
- List commands paginate manually via API query flags like `--limit` and `--token`.
65
+
- Do not add a generic `--all` mode. If an agent needs multiple pages, it should read `next_token` from the JSON response and request the next page explicitly.
66
+
63
67
### Auth and `skipAuth`
64
68
`initContext()` resolves credentials via `ChainCredentialResolver` (env → file). Commands that don't need auth (e.g., `auth login`, `config set`) annotate with `skipAuth: true` in Cobra `Annotations`. Check `skipAuth` before adding new non-auth commands.
0 commit comments