Skip to content

perf: narrow generated SDK runtime error imports - #23

Open
petebacondarwin wants to merge 1 commit into
mainfrom
codex/narrow-sdk-error-imports
Open

petebacondarwin wants to merge 1 commit into
mainfrom
codex/narrow-sdk-error-imports

Conversation

@petebacondarwin

Copy link
Copy Markdown
Collaborator

Generated TypeScript SDK clients import the full API barrel to construct HTTP errors, pulling request and resource barrels into consumers' runtime import graphs. Make the API namespace type-only and import the existing error constructors from the narrow errors barrel instead. This upstreams the SDK normalization introduced in cloudflare/cf#160.

Apply one shared normalization to standalone TypeScript SDK generation and the SDK transformer, including freshly generated SDKs and copied packaged baselines. Bundle the normalization entry point with the transformer. Use the existing TypeScript dependency to distinguish runtime references from types and edit syntax without changing comments or literals; preserve unfamiliar runtime uses. Error implementations, class identity, response data, and public SDK barrels stay unchanged. No new dependencies are required.

Validation:

  • pnpm check, pnpm typecheck, and pnpm test pass, including 20 new normalization regression tests.
  • Built and packed the transformer; verified baseline normalization from both the built CLI and an extracted npm tarball with only its declared TypeScript dependency available.
  • Generated a two-operation OpenAPI fixture through both the standalone SDK pipeline and the packaged transformer using Docker. Root and nested clients avoid a throwing API-barrel sentinel and preserve HTTP error identity, status, body, and raw response for 400, 401, and unknown statuses. The freshly generated transformer SDK also type-checks.
  • Reconstructed pre-normalization inputs for cf's 1,127 committed normalized clients and reproduced their output exactly.

After cf re-vendors this transformer and regenerates its SDK, it can remove its local normalizer and generation hook. Its direct client/environment imports and consumer regression test should remain.

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