Skip to content

fix(sdk): expose clients' additional-types through @epilot/sdk - #457

Closed
josecarneiro wants to merge 1 commit into
mainfrom
claude/conditional-pricing-sdk-qt65gj
Closed

fix(sdk): expose clients' additional-types through @epilot/sdk#457
josecarneiro wants to merge 1 commit into
mainfrom
claude/conditional-pricing-sdk-qt65gj

Conversation

@josecarneiro

@josecarneiro josecarneiro commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

@epilot/sdk/{api} only ever re-exported the types generated from an API's OpenAPI specification. Types a client declares by hand in clients/{api}-client/src/additional-types.ts were silently dropped, even though @epilot/{api}-client exports them from its package root.

That is why epilot-dev/pricing#292 had to re-declare PriceTierEnhanced locally when it migrated from @epilot/pricing-client to @epilot/sdk/pricing — the type exists in clients/pricing-client/src/additional-types.ts, but nothing carried it into the SDK.

Root cause is scripts/generate-sdk-v2.ts: copyTypes() copies only src/openapi.d.ts into packages/epilot-sdk-v2/src/types/, and the generated src/apis/{api}.ts re-exports just ../types/{api}.

Changes

  • scripts/generate-sdk-v2.ts
    • discovers src/additional-types.ts per client (hasAdditionalTypes)
    • new copyAdditionalTypes() copies it to packages/epilot-sdk-v2/src/types/{api}-additional.d.ts, rewriting its from './openapi' import to from './{api}' (where the copied generated types live)
    • the generated src/apis/{api}.ts gains export type * from '../types/{api}-additional' when the client has such a file
  • regenerated output: src/types/pricing-additional.d.ts (new) and src/apis/pricing.ts (one added re-export). pricing-client is currently the only client with an additional-types.ts, so nothing else changes.
  • __tests__/additional-types.test.ts — regression guard: for every client that has an additional-types.ts, asserts the copied .d.ts exists, no longer points at ./openapi, and is re-exported from the API module; plus a type-level check that PriceTierEnhanced, Cart and AvailabilityDate are reachable from @epilot/sdk/pricing.
  • changeset (@epilot/sdk patch).

After this, dist/apis/pricing.d.ts exports AvailabilityDate, Cart and PriceTierEnhanced, matching the surface of @epilot/pricing-client.

({api} above is a placeholder for an API name, e.g. pricing.)

Test plan

  • pnpm generate-sdk produces exactly the two file changes above (no unrelated drift)
  • pnpm build in packages/epilot-sdk-v2dist/apis/pricing.d.ts re-exports the three types
  • npx vitest run __tests__/additional-types.test.ts — 3 passed; verified it fails when src/types/pricing-additional.d.ts is removed
  • pnpm lint (biome) clean
  • full pnpm test — 25 pre-existing failures in dist-integration / operations from the sandbox HTTP proxy rewriting axios base URLs (http://127.0.0.1:PORT + https://…); identical count on an untouched tree, so unrelated to this change. Needs a CI run to confirm green.

Follow-up (not in this PR)

Once a version with this fix is published, github/pricing's local PriceTierEnhanced in src/shared/types.ts can go back to being a re-export from @epilot/sdk/pricing.

Side note: the legacy Cart.status doc comment in additional-types.ts still describes open | complete | expired, but OrderStatus in the current spec is draft | quote | placed | cancelled | completed. Left as-is here.

The v2 SDK generator only copied each client's generated `src/openapi.d.ts`
into `packages/epilot-sdk-v2/src/types/`, so the hand-written types a client
declares in `src/additional-types.ts` never reached `@epilot/sdk/<api>`.
Code migrating from `@epilot/<api>-client` to the SDK therefore had to
re-declare them — e.g. `@epilot/pricing` re-declaring `PriceTierEnhanced`
after moving to `@epilot/sdk/pricing`.

`generate-sdk-v2.ts` now copies `additional-types.ts` to
`src/types/<api>-additional.d.ts`, rewriting its `./openapi` import to the
copied generated types, and re-exports it from `src/apis/<api>.ts`.
`@epilot/sdk/pricing` regains `PriceTierEnhanced`, `Cart` and
`AvailabilityDate`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JEMqupBjKVAzXWYDJvrdJc
@jnmau jnmau closed this Aug 27, 2026
@jnmau
jnmau deleted the claude/conditional-pricing-sdk-qt65gj branch August 27, 2026 09:38
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.

3 participants