refactor: typegen improvements (OpenAPI-generated Cloudflare types, openapi-fetch, node scripts)#784
refactor: typegen improvements (OpenAPI-generated Cloudflare types, openapi-fetch, node scripts)#784andykenward wants to merge 9 commits into
Conversation
🦋 Changeset detectedLatest commit: bef996d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Cloudflare Pages DeploymentEvent Name: pull_request Wrangler Output⛅️ wrangler 4.86.0 ✨ Uploading _headers |
| } | ||
|
|
||
| const fetchSchema = async (): Promise<JsonObject> => { | ||
| const response = await fetch(SCHEMA_URL) |
|
@claude review the pull request |
|
Claude finished @andykenward's task in 2m 37s —— View job PR Review
Overall this is a solid, well-scoped refactor. The three themes (OpenAPI codegen, typed client, Security: SSRF warning (CodeQL) —
|
Summary
Tooling and type-safety improvements for the Cloudflare Pages integration. Two themes:
@cloudflare/types.tsxto nativenodetype-stripping where possible.No user-facing behavior change — internal refactors only.
Cloudflare types from OpenAPI (
refactor: generate cloudflare types from openapi schema)pnpm run codegen:cloudflare) fetches Cloudflare's canonical OpenAPI schema (cloudflare/api-schemas), ref-walks from the Pages operations this action uses to prune to only the referenced components, and runsopenapi-typescripton that subset → a focused__generated__/types/cloudflare/pages.tsrather than a ~10 MB dump of the whole API.PagesDeploymentnow sources from the generated schema;@cloudflare/typesis removed (and its orphanedpnpm.peerDependencyRules). The hand-rolledaliases: string[] | nullpatch is dropped — the schema already models it correctly.statusnever includesskipped, so the deadcase 'skipped'instatus.tsis removed.openapi-fetchfor REST calls (feat: openapi-fetch)paths, with middleware injecting auth once per request.fetch-result.tsreduced from raw-fetch +as FetchResult<T>casts tounwrap/unwrapSuccess— a thin layer applying Cloudflare's{success, result, errors}envelope semantics over the client's{data, error, response}. Response types are now inferred from the endpoint instead of asserted.getCloudflareApiEndpoint(manual URL builder) retired;getCloudflareLogEndpoint(dashboard URL) kept.Tooling migrations (
tsx→node)codegen:events,deployments:delete, anddownloadscripts now run with nativenodetype-stripping (notsx).bin/codegenflattened (index.ts+types/→ flat*.ts).CLAUDE.md).Validation
pnpm run allpasses end to end: sync-versions → knip → codegen → codegen:events → codegen:cloudflare → tsc → format → lint → 79 tests → build.Bundle grew ~10 kB (deploy) from
openapi-fetch, as expected.Notes / follow-ups
privatepackage; no changeset added (internal refactor, no user-facing change).fetch— could move to the typed client for consistency.🤖 Generated with Claude Code