Commit 618671d
authored
fix(project-list): add pagination and flexible target parsing (#221)
## Summary
Fixes three bugs in `sentry project list`:
- **No pagination** — showed "displaying 30 out of 100 projects" with no
way to see the rest. Added `--cursor/-c` flag with a `last` magic value
that resumes from where you left off.
- **API pagination not followed** — setting `-n 200` still capped at 100
because the Sentry API paginates and we never followed cursor links.
Added `orgScopedPaginateAll()` so `listProjects()` transparently fetches
all pages.
- **`project list sentry/sentry`** said "No projects found in
organization 'sentry/sentry'" — now uses `parseOrgProjectArg()` (same as
`issue list`) to handle `org/project`, `org/`, and bare-word targets.
## Changes
### `src/lib/api-client.ts` — Pagination infrastructure
- `PaginatedResponse<T>` type, `parseLinkHeader()`,
`orgScopedRequestPaginated()`, `orgScopedPaginateAll()`
- `listProjects()` now auto-paginates transparently (all 6 callers
unchanged)
- New `listProjectsPaginated()` for explicit single-page fetches with
cursor control
### `src/commands/project/list.ts` — Rewritten command
- 4 target modes: `auto-detect`, `explicit` (org/project), `org-all`
(org/), `project-search` (bare slug)
- `--cursor/-c` flag with `last` magic value for easy page navigation
- JSON output returns `{ data, nextCursor?, hasMore }` in paginated mode
### `src/lib/db/schema.ts` — Schema v6
- Added `pagination_cursors` table for cursor caching
### `src/lib/db/pagination.ts` — New module
- Cursor cache with TTL (default 5 min) and context validation
### Tests
- Updated `test/e2e/project.test.ts` and `test/e2e/multiregion.test.ts`
for new `org/` syntax and paginated JSON format1 parent 395aede commit 618671d
File tree
16 files changed
+2955
-223
lines changed- plugins/sentry-cli/skills/sentry-cli
- src
- commands/project
- lib
- db
- test
- commands
- cli
- issue
- project
- e2e
- lib
- db
16 files changed
+2955
-223
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| |||
600 | 601 | | |
601 | 602 | | |
602 | 603 | | |
603 | | - | |
| 604 | + | |
604 | 605 | | |
605 | 606 | | |
606 | 607 | | |
607 | 608 | | |
608 | 609 | | |
609 | 610 | | |
| 611 | + | |
610 | 612 | | |
611 | 613 | | |
612 | 614 | | |
| |||
0 commit comments