Skip to content

Add list pagination, --owner filter, ds->on download redirect - #320

Merged
neuromechanist merged 4 commits into
devfrom
feature/issue-319-list-download-improvements
Mar 21, 2026
Merged

neuromechanist merged 4 commits into
devfrom
feature/issue-319-list-download-improvements

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Backend: GET /datasets now returns total_count, limit, offset for proper pagination; adds owner query param and includes source/source_id fields. New GET /datasets/resolve/:sourceId endpoint for ds->on lookup.
  • CLI list: Default 20 results/page (was 50). Adds -n/--limit, --page, --offset, --all pagination and --owner <username> filter. Shows pagination footer.
  • CLI download: When downloading ds###### (OpenNeuro), checks for NEMAR on###### counterpart. If found, prompts to download from NEMAR instead (git-annex version tracking).

Test plan

  • CLI builds successfully (bun run build)
  • OpenNeuro tests pass (bun test test/openneuro.test.ts)
  • Manual: nemar dataset list shows 20 results by default
  • Manual: nemar dataset list --page 2 shows next page
  • Manual: nemar dataset list -n 50 shows 50 results
  • Manual: nemar dataset list --owner yahya filters by owner
  • Manual: nemar dataset list --all shows all (up to 200)
  • Manual: nemar dataset download ds007315 checks for on counterpart
  • Backend deploy and verify /datasets?limit=20&offset=0 returns total_count
  • Backend verify /datasets/resolve/ds007315 returns on counterpart

Closes #319

Backend:
- GET /datasets: add owner query param, return total_count/limit/offset
- GET /datasets: include source/source_id in managed dataset responses
- GET /datasets/resolve/:sourceId: new endpoint for ds->on lookup
- executeAndReturn: parallel COUNT query for total_count

CLI list:
- Default to 20 results per page (was 50)
- Add -n/--limit, --page, --offset, --all pagination options
- Add --owner <username> filter
- Show pagination footer with page info and next page hint
- JSON output includes total_count, limit, offset

CLI download:
- For ds###### datasets, check for on###### NEMAR counterpart
- If found, prompt user to download from NEMAR instead (git-annex)
- Falls through to OpenNeuro download if no counterpart or declined

Closes #319
- Separate API call from inquirer prompt in resolveOpenNeuroId
  so Ctrl+C propagates correctly instead of being swallowed
- Add try-catch and input validation to resolve endpoint
- Use Promise.allSettled so COUNT query failure does not crash
  the main dataset list query
- Fix NaN propagation when limit/offset are non-numeric strings
- Use != null check for limit param in API client
- Fallback query now respects user's limit/offset
- Update JSDoc to document new params and pagination response
@github-actions

github-actions Bot commented Mar 21, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR320

Version: 0.7.22-PR320.a6f023f
Commit: a6f023f


🤖 Updated on each push.

- Resolve endpoint only matches public datasets to prevent
  leaking private dataset metadata via source ID enumeration
- Remove visibility from resolve response (always public)
- Make --mine and --owner mutually exclusive with clear error
The list --json output changed from a plain array to
{ datasets, total_count, limit, offset }. Update tests
to match the new pagination-aware response shape.
@neuromechanist
neuromechanist merged commit 8d49876 into dev Mar 21, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-319-list-download-improvements branch March 21, 2026 06:30

This branch was previously deployed

1 inactive deployment
npm — a6f023f9 Deployed Mar 21, 2026 by neuromechanist via publish #561
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant