Skip to content

refactor(ui): migrate API client codegen from hey-api to orval - #7023

Draft
luizhf42 wants to merge 3 commits into
masterfrom
feat/ui/orval
Draft

refactor(ui): migrate API client codegen from hey-api to orval#7023
luizhf42 wants to merge 3 commits into
masterfrom
feat/ui/orval

Conversation

@luizhf42

@luizhf42 luizhf42 commented Sep 2, 2026

Copy link
Copy Markdown
Member

Warning

WIP — this branch is under active development and not ready for review.

Migrates the console's OpenAPI client codegen from @hey-api/openapi-ts to Orval. Tracked in shellhub-io/team#236.

Done

  • Commit 1 — added orval + config, customInstance.ts mutator, updated generate-client.sh, adapted tsconfig.json
  • Commit 2 — replaced 14 thin query wrappers with generated orval hooks, updated all call sites
  • Commit 3 — wired mutationInvalidates config for all mutation→query relationships, deleted 17 invalidation-only hook files + 5 obsolete test files, trimmed 6 mixed hooks to custom-logic only, dropped unused Zod runtime validation and its transformer workaround. All call sites rewired to @/client/api.

Left

  • Update remaining domain hook imports from @/client barrel to @/client/api
  • Set up MSW in test setup, delete mockSdkGen infrastructure
  • Add @faker-js/faker to devDependencies
  • Migrate test files to MSW + generated faker factories
  • Delete old sdk.gen references
  • Remove @hey-api/openapi-ts dependency

Orval replaces `@hey-api/openapi-ts` as the OpenAPI client generator.
The config enables react-query hooks, and MSW/faker mock generation from the spec.
The custom mutator merges `fetchClient` and `fetchInterceptors` into
a single function that handles auth, JWT expiry, 401/MFA, connectivity
tracking, and error enrichment. `fetchWithResponse` is exported alongside
for paginated hooks that need access to response headers.
Delete 11 single-purpose query hooks and trim query exports from 2
mixed files, updating ~20 call sites to import directly from the
generated `@/client/api` module.
…lidates`

Orval's `mutationInvalidates` config auto-generates `onSuccess`
invalidation inside each mutation hook, making the hand-written
thin wrappers redundant. This commit drops Zod runtime validation
(unused — zero `.parse()` calls across 6 400 generated lines),
removes the `inlineParameterRefs` transformer that only existed
as a Zod workaround, wires up `mutationInvalidates` for every
mutation→query relationship, deletes 17 invalidation-only hook
files plus 5 obsolete test files, and trims 6 mixed files down
to only the hooks carrying real logic. All call sites now import
generated hooks directly from `@/client/api`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant