fix(sdk): expose clients' additional-types through @epilot/sdk - #457
Closed
josecarneiro wants to merge 1 commit into
Closed
fix(sdk): expose clients' additional-types through @epilot/sdk#457josecarneiro wants to merge 1 commit into
josecarneiro wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@epilot/sdk/{api}only ever re-exported the types generated from an API's OpenAPI specification. Types a client declares by hand inclients/{api}-client/src/additional-types.tswere silently dropped, even though@epilot/{api}-clientexports them from its package root.That is why epilot-dev/pricing#292 had to re-declare
PriceTierEnhancedlocally when it migrated from@epilot/pricing-clientto@epilot/sdk/pricing— the type exists inclients/pricing-client/src/additional-types.ts, but nothing carried it into the SDK.Root cause is
scripts/generate-sdk-v2.ts:copyTypes()copies onlysrc/openapi.d.tsintopackages/epilot-sdk-v2/src/types/, and the generatedsrc/apis/{api}.tsre-exports just../types/{api}.Changes
scripts/generate-sdk-v2.tssrc/additional-types.tsper client (hasAdditionalTypes)copyAdditionalTypes()copies it topackages/epilot-sdk-v2/src/types/{api}-additional.d.ts, rewriting itsfrom './openapi'import tofrom './{api}'(where the copied generated types live)src/apis/{api}.tsgainsexport type * from '../types/{api}-additional'when the client has such a filesrc/types/pricing-additional.d.ts(new) andsrc/apis/pricing.ts(one added re-export).pricing-clientis currently the only client with anadditional-types.ts, so nothing else changes.__tests__/additional-types.test.ts— regression guard: for every client that has anadditional-types.ts, asserts the copied.d.tsexists, no longer points at./openapi, and is re-exported from the API module; plus a type-level check thatPriceTierEnhanced,CartandAvailabilityDateare reachable from@epilot/sdk/pricing.@epilot/sdkpatch).After this,
dist/apis/pricing.d.tsexportsAvailabilityDate,CartandPriceTierEnhanced, matching the surface of@epilot/pricing-client.(
{api}above is a placeholder for an API name, e.g.pricing.)Test plan
pnpm generate-sdkproduces exactly the two file changes above (no unrelated drift)pnpm buildinpackages/epilot-sdk-v2—dist/apis/pricing.d.tsre-exports the three typesnpx vitest run __tests__/additional-types.test.ts— 3 passed; verified it fails whensrc/types/pricing-additional.d.tsis removedpnpm lint(biome) cleanpnpm test— 25 pre-existing failures indist-integration/operationsfrom 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 localPriceTierEnhancedinsrc/shared/types.tscan go back to being a re-export from@epilot/sdk/pricing.Side note: the legacy
Cart.statusdoc comment inadditional-types.tsstill describesopen | complete | expired, butOrderStatusin the current spec isdraft | quote | placed | cancelled | completed. Left as-is here.