Skip to content

feat(api): Add a type-only ApiRoutes map by path and method - #131221

Merged
BYK merged 1 commit into
masterfrom
feat/api-route-map
Nov 16, 2026
Merged

BYK merged 1 commit into
masterfrom
feat/api-route-map

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

This is the SDK half of #131202. @sentry/api now exports ApiRoutes, a type-only interface generated from the SDK operations. It's keyed by canonical path (relative to API_BASE_PATH) and then by HTTP method. Each entry gives the operation's name, its <Operation>Data type, and its status-keyed <Operation>Responses and <Operation>Errors. Operations with no documented errors get {}.

type ListProjects = ApiRoutes["/organizations/{organization_id_or_slug}/projects/"]["GET"];
type Projects = ListProjects["responses"][200];
  • scripts/generate-api-routes.mjs builds the interface with the TypeScript factory from sdk.gen.ts and types.gen.ts. It runs as a build step, and the root entry re-exports it with export type, so it adds no runtime code.
  • It only references existing generated types, so the response unions and status keys stay intact.
  • The README documents it under "Types by path".

A separate frontend PR will use this map in apiOptions / apiOptionsInfinite. That PR maps {organization_id_or_slug} to the frontend's $organizationIdOrSlug routes and removes the todo: infer the actual data type from the ApiMapping comments that the map covers.

via @BYK.

--

View Session [Sentry]

Generate ApiRoutes from the SDK operations: each canonical path and HTTP
method maps to the operation's name, Data type, and status-keyed
Responses and Errors. Callers that build requests from a path, such as
the frontend's apiOptions, can infer types without importing an
operation function.

Refs #131202

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested review from a team as code owners November 16, 2026 11:56
@sentry-junior
sentry-junior Bot requested a review from BYK November 16, 2026 11:56
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 16, 2026
@BYK
BYK merged commit e75b5f5 into master Nov 16, 2026
88 checks passed
@BYK
BYK deleted the feat/api-route-map branch November 16, 2026 13:17

This branch was successfully deployed

1 active deployment
Preview — 10097aa0 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant