[codex] Add generated permissive MTA input types#4
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds generated permissive TypeScript types for known MTA routes and stops, then applies them to SDK query inputs while preserving arbitrary string support for newer values.
Changes:
- Adds generated
Known*route/stop literal unions andAutocompleteStringwrapper aliases. - Narrows public query input types for subway, bus, alerts, and nearby stops.
- Adds a Bun generation script, package script, README note, and root type re-export.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/types.ts |
Introduces permissive autocomplete aliases and applies them to query interfaces. |
src/generated.ts |
Adds generated literal unions for known routes and stops. |
scripts/generate-known-types.ts |
Adds hosted snapshot-based type generation. |
README.md |
Documents generated autocomplete and refresh command. |
package.json |
Adds generation script and includes scripts in package files. |
index.ts |
Uses the named subway query type and re-exports generated types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return /^[A-Z0-9]{1,2}$/.test(routeId) | ||
| } | ||
|
|
||
| const routeIds = routeEntries.flatMap(([routeId]) => aliasesForRoute(routeId)) |
| Route and stop inputs include generated autocomplete for known MTA values while | ||
| remaining permissive for future route and stop additions. Refresh the generated | ||
| types from the hosted stops snapshot with `bun run generate:types`. |
| @@ -0,0 +1,105 @@ | |||
| import { writeFileSync } from "node:fs" | |||
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3a9e0680a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| const routeIds = routeEntries.flatMap(([routeId]) => aliasesForRoute(routeId)) | ||
| const subwayRoutes = routeIds.filter((routeId) => routeType(routeId) === 1 || looksLikeSubwayRoute(routeId)) |
There was a problem hiding this comment.
Include SIR in generated subway route union
Treating subway routes as routeType === 1 or a 1–2 character fallback excludes the Staten Island Railway route IDs (SI/SIR) from KnownSubwayRoute, even though this SDK’s subway client supports SIR in defaultEndpoints.subwayFeeds and SubwayArrivalQuery accepts subway feed routes. As generated, KnownRoute includes SI/SIR but KnownSubwayRoute does not, so typed consumers lose autocomplete for a valid subway route and may incorrectly assume it is unsupported.
Useful? React with 👍 / 👎.
fix: require snapshot URL for type generation
e847f3a to
3debc79
Compare
Summary
Verification