th-1b445c: paginate th api crm {contacts,companies,deals} list#188
Open
brentrager wants to merge 1 commit into
Open
th-1b445c: paginate th api crm {contacts,companies,deals} list#188brentrager wants to merge 1 commit into
brentrager wants to merge 1 commit into
Conversation
These list commands only sent `?limit=` (default 50; the API clamps to a 200-row max page) with no offset and no auto-paginate, so they silently returned just the first page — `contacts list --limit 1000` came back with 200 rows while the endpoint's x-total-count said 267, dropping 67 contacts with no warning. The endpoint was always fine; the CLI was the bug. Each `list` now takes `--offset <N>` and `--all` (fetch every page). `--all` reuses the offset-paginating loop the import scan already used, generalized into `fetch_all_resource` and paced to stay under the 100-req/60s limit; `fetch_all` now delegates to it so import behavior is unchanged. The deals `--stage` filter is not applied in `--all` mode (the endpoint filters by `stage`, not the paginator's `search`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NckP97y2ADKRwq5kkRSdPz
🦋 Changeset detectedLatest commit: af20787 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Problem
th api crm contacts|companies|deals listonly sent?limit=(default 50; the API clamps to a 200-row max page) with no--offsetand no auto-paginate, so they silently returned only the first page. Real example:contacts list --limit 1000returned 200 rows while the endpoint'sx-total-countheader said 267 — 67 contacts silently dropped. The API endpoint was always fine (it supportslimit+offsetand returnsx-total-count); the bug was CLI-only.Fix
Each
listcommand gains two flags:--offset <N>— page past the first page (default 0).--all— fetch every page, ignoring--limit/--offset.--allreuses the offset-paginating loop that theimportscan already used. That loop is generalized into a singlefetch_all_resource(client, org, resource, search, rate)helper (loopsGET /organizations/{org}/crm/{resource}?limit=200&offset={offset}until a short page, url-encoding&search=when present). The existingfetch_allnow delegates to it — import behavior is unchanged, including its rate pacing so the existing-contacts scan stays under the 100-req/60s limit.Notes:
--alllist now appends&offset={offset}to the single-page request; existing search/stage/json behavior is preserved.--allprints the aggregated JSON array rather than trying to render the full pull.--stagefilter is not applied in--allmode — the endpoint filters bystage, not the shared paginator'ssearch. This is documented in the flag help.Verification
cargo build -p smooai-smooth-cli— passes (exit 0).cargo clippy -p smooai-smooth-cli— 0 errors, no new lints incrm.rs.cargo fmt -p smooai-smooth-cli— applied.th api crm contacts list --helpnow shows:--offset/--allpresent oncompanies listanddeals list.Changeset:
@smooai/smooth(minor).🤖 Generated with Claude Code