Skip to content

fix: Add new query pattern for getTokensBySiteIdByCycle#2298

Open
sandsinh wants to merge 7 commits intomainfrom
SITES-43808
Open

fix: Add new query pattern for getTokensBySiteIdByCycle#2298
sandsinh wants to merge 7 commits intomainfrom
SITES-43808

Conversation

@sandsinh
Copy link
Copy Markdown
Contributor

@sandsinh sandsinh commented Apr 30, 2026

Related Issues

SITES-43808

Summary

  • Adds GET /sites/:siteId/tokens endpoint to list all token allocations for a site with cursor-based pagination and optional filtering by tokenTypes (comma-separated or repeated query param) and cycle
  • Registers the new route with token:read capability in required-capabilities.js
  • Achieves 100% statement/function/line coverage and 100% branch coverage on tokens.js (38 unit tests)

Endpoints

Method Path Description
GET /sites/:siteId/tokens List tokens with optional tokenTypes, cycle, limit, cursor filters
GET /sites/:siteId/tokens/by-type/:tokenType Get current-cycle token by type (pre-existing)
GET /sites/:siteId/tokens/:tokenId/grants Get suggestion grants for a token (pre-existing)

Response shape (getAll)

{
  "tokens": [ { "id": "...", "siteId": "...", "tokenType": "...", "cycle": "...", "total": 100, "used": 25, "remaining": 75, ... } ],
  "pagination": { "limit": 100, "cursor": "<opaque>", "hasMore": true }
}

Test plan

  • Unit tests cover all happy paths and error branches (400 / 403 / 404 / 500) for all three controller methods
  • Tests verify tokenTypes normalisation for both comma-separated strings and repeated-param arrays
  • Tests verify cursor forwarding and hasMore flag in pagination response
  • Tests verify fallback behaviour when context.data is absent and when results.data is missing

🤖 Generated with Claude Code

@sandsinh sandsinh changed the title fix: fix: Add new query pattern for getTokensBySiteIdByCycle fix: Add new query pattern for getTokensBySiteIdByCycle May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

This PR will trigger a patch release when merged.

Sandesh Sinha and others added 2 commits May 5, 2026 22:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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