Skip to content

feat(deps): migrate @hey-api/openapi-ts from 0.71.1 to 0.96.1#143

Open
dtoxvanilla1991 wants to merge 5 commits into
mainfrom
feat/migrate/openapi-ts-0.96
Open

feat(deps): migrate @hey-api/openapi-ts from 0.71.1 to 0.96.1#143
dtoxvanilla1991 wants to merge 5 commits into
mainfrom
feat/migrate/openapi-ts-0.96

Conversation

@dtoxvanilla1991

Copy link
Copy Markdown
Contributor

Summary

Full migration of @hey-api/openapi-ts from 0.71.10.96.1.

Closes #121.


Breaking changes in @hey-api/openapi-ts 0.96

Plugin system overhaul

  • legacy/fetch plugin removed entirely — replaced by bundled @hey-api/client-fetch
  • Config option format: "prettier"postProcess: ["prettier"]
  • Config option asClass: true / classNameBuilderoperations: { strategy: "byTags" }
  • Config option exportFromIndex: trueincludeInEntry: true
  • Config option responseStyle: "data" removed from SDK plugin (now a client-level config)

New client architecture

  • Old: OpenAPI singleton from core/OpenAPI.ts configured with BASE and TOKEN
  • New: client singleton from client.gen.ts configured with baseUrl and auth callback
  • Old core files deleted: ApiError.ts, ApiRequestOptions.ts, ApiResult.ts, CancelablePromise.ts, OpenAPI.ts, request.ts
  • New generated files: client.gen.ts, client/ directory, core/auth.gen.ts, core/bodySerializer.gen.ts, core/pathSerializer.gen.ts, core/utils.gen.ts, etc.

Method signature changes

  • Old: static getCallbackUrls(data: GetCallbackUrlsData): CancelablePromise<GetCallbackUrlsResponse>
  • New: static getCallbackUrls<ThrowOnError>(options: Options<GetCallbackUrlsData, ThrowOnError>)
  • Return type: CancelablePromise<T>RequestResult<TResponses, TErrors, ThrowOnError>

Data type shape changes

  • Old flat shape: { appId: "123", requestBody: { urls: [...] } }
  • New structured shape: { path: { app_id: "123" }, body: { urls: [...] } }
  • Query params now under query sub-object: { query: { phone: "..." } }

Changes made

openapi-ts.config.ts

  • Migrated all deprecated config options to new equivalents

lib/api/ (generated)

  • Regenerated all files via pnpm exec openapi-ts
  • Old core (CancelablePromise, OpenAPI, ApiError, etc.) removed
  • New client architecture files added

lib/api/callbacks-compat.ts & callbacks-compat.d.ts

  • Removed CancelablePromise dependency (file no longer exists)
  • Updated deprecated method aliases to use new Options<Data, ThrowOnError> signatures
  • Compat layer still provides backward-compatible method name aliases (getCallbackUrLs, addRedirectCallbackUrLs, etc.)

lib/config.ts

  • Replaced import { OpenAPI } from "./api/index" with import { client } from "./api/client.gen"
  • Replaced _merge(OpenAPI, { BASE, TOKEN }) with client.setConfig({ baseUrl, auth })

lib/utilities/getToken.ts

  • Removed import { OpenAPI } from "../api" (file deleted)
  • Replaced OpenAPI.BASE + "/api" with kindeConfig.kindeDomain + "/api"

lib/main.ts

  • Changed export * from "./api/index"export * from "./api/schemas.gen" (avoids Applications2/Permissions2/etc. naming pollution from index.ts conflicts)
  • Explicitly exports all SDK classes from ./api/sdk.gen (avoiding Callbacks conflict with compat layer)

Tests

  • lib/main.test.ts: Removed ApiError, CancelablePromise, CancelError, OpenAPI from expected exports
  • tests/regressions.test.ts: Updated all call sites to use new path/query/body arg shapes

Verification

tsc --noEmit  → 0 errors
pnpm build    → ✓ built in 1.82s (177.59 kB mjs + 101.30 kB cjs)
pnpm test     → 51/51 tests passed

Complete architectural migration from the legacy fetch client to the new
bundled @hey-api/client-fetch client in openapi-ts v0.96.

## Config changes (openapi-ts.config.ts)
- Replace legacy/fetch plugin with @hey-api/client-fetch
- Replace format: 'prettier' with postProcess: ['prettier']
- Replace asClass/classNameBuilder with operations.strategy: 'byTags'
- Replace exportFromIndex with includeInEntry: true
- Replace responseStyle: 'data' option (removed from SDK plugin)

## Generated files (lib/api/)
- Deleted: core/ApiError.ts, ApiRequestOptions.ts, ApiResult.ts,
  CancelablePromise.ts, OpenAPI.ts, request.ts (old fetch core)
- Added: client.gen.ts, client/ directory (new client singleton)
- Added: core/auth.gen.ts, bodySerializer.gen.ts, params.gen.ts,
  pathSerializer.gen.ts, queryKeySerializer.gen.ts,
  serverSentEvents.gen.ts, types.gen.ts, utils.gen.ts
- Regenerated: index.ts, sdk.gen.ts, types.gen.ts, schemas.gen.ts

## Method signature changes (sdk.gen.ts)
- Old: static method(data: XxxData): CancelablePromise<XxxResponse>
- New: static method<ThrowOnError>(options: Options<XxxData, ThrowOnError>)
- Data types now use path/query/body sub-objects instead of flat args
  e.g. { appId } -> { path: { app_id } }

## Hand-maintained file updates
- lib/api/callbacks-compat.ts: Removed CancelablePromise dependency;
  deprecated method aliases now use new Options<Data> signatures
- lib/api/callbacks-compat.d.ts: Updated to new type signatures
- lib/config.ts: Replace OpenAPI singleton with client.setConfig()
  using new baseUrl and auth callback pattern
- lib/utilities/getToken.ts: Replace OpenAPI.BASE with kindeConfig.kindeDomain
- lib/main.ts: Explicitly export all SDK classes from sdk.gen (avoiding
  index.ts naming conflicts); export schemas directly from schemas.gen

## Test updates
- lib/main.test.ts: Remove ApiError, CancelablePromise, CancelError,
  OpenAPI from expected exports (no longer generated)
- tests/regressions.test.ts: Update all method call args to new
  path/query/body format; update type check tests

Closes #121
@dtoxvanilla1991 dtoxvanilla1991 requested review from a team as code owners April 27, 2026 23:41
@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Rate limit exceeded

@dtoxvanilla1991 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 3 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9a2db542-c89d-4eac-85b7-eb924573a6ab

📥 Commits

Reviewing files that changed from the base of the PR and between ff4a7a0 and b295ad7.

⛔ Files ignored due to path filters (2)
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
📒 Files selected for processing (8)
  • lib/api/index.ts
  • lib/api/sdk.gen.ts
  • lib/api/types.gen.ts
  • lib/config.ts
  • lib/main.test.ts
  • lib/main.ts
  • lib/utilities/ApiError.ts
  • tests/regressions.test.ts

Walkthrough

Replaces the legacy OpenAPI runtime with a generated client factory and utilities, updates deprecated Callbacks aliases to accept typed Options<T, ThrowOnError>, removes legacy cancelable/error/OpenAPI artifacts, and adjusts exports, config initialization, and tests to the new client shapes.

Changes

Client generation & migration

Layer / File(s) Summary
Client public types and Options
lib/api/client/types.gen.ts
Adds Config, RequestOptions/ResolvedRequestOptions, conditional RequestResult, Client generic, CreateClientConfig, and endpoint Options typing used by the new client.
Path parameter serialization
lib/api/core/pathSerializer.gen.ts
Adds serializer option types and functions to serialize arrays, primitives, and objects for OpenAPI-style path template substitution.
Runtime client initialization
lib/config.ts
Switches initialization to client.setConfig, sets baseUrl from config, and provides async auth callback using getToken().
Public API export surface
lib/main.ts
Replaces blanket export * from "./api/index" with explicit schema/type/sdk exports and omits Callbacks from the SDK named exports (keeps compatibility export).
Token audience & imports
lib/utilities/getToken.ts
Removes old OpenAPI import and derives OAuth audience from kindeConfig.kindeDomain (fallback to configured audience).
OpenAPI generator config
openapi-ts.config.ts
Updates codegen formatting and plugin settings (switch to @hey-api/client-fetch, set operations strategy, and include schemas in entry).
Tests: callback & query param shape updates
tests/regressions.test.ts
Adjusts regression tests to new endpoint parameter shapes (use path: { app_id }, body: { urls }, query: { urls }) and nests Users query params under query.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • Koosha-Owji
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: migrating @hey-api/openapi-ts from version 0.71.1 to 0.96.1.
Description check ✅ Passed The PR description is comprehensive and directly related to the changeset, covering breaking changes, implementation details, verification results, and rationale.
Linked Issues check ✅ Passed The PR successfully addresses all coding objectives from linked issue #121: upgrades @hey-api/openapi-ts, migrates config options, updates client architecture, regenerates API files, adapts compatibility layer, updates tests, and verifies via build/test pipeline.
Out of Scope Changes check ✅ Passed All changes are in-scope: generated file regeneration (lib/api/), config migration (openapi-ts.config.ts), client usage updates (lib/config.ts, utilities/getToken.ts), compatibility layer (callbacks-compat.ts/d.ts), exports reorganization (lib/main.ts), and test updates align with the stated migration objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/migrate/openapi-ts-0.96

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Set output.clean: false in openapi-ts.config.ts so that
spec:generate does not delete callbacks-compat.ts and
callbacks-compat.d.ts on every run.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openapi-ts.config.ts (1)

1-30: ⚠️ Potential issue | 🔴 Critical

Add Node.js engine constraint and update CI to version >=22.13.

The migration to @hey-api/openapi-ts requires Node >= 22.13, but the repository has no enforcement:

  • package.json is missing engines.node
  • GitHub CI workflows are set to Node 20.x (incompatible)

Add "engines": { "node": ">=22.13" } to package.json and update .github/workflows to use Node 22.x or later.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openapi-ts.config.ts` around lines 1 - 30, Add a Node.js engine constraint
and update CI to Node >=22.13: add an "engines" entry to package.json with
"node": ">=22.13" (so package.json enforces runtime), and update all GitHub
Actions workflow files under .github/workflows that use actions/setup-node or a
node-version matrix to use 22.x or a literal >=22.13 (e.g., node-version: '22.x'
or matrix value '22.x') so CI runs on Node 22+. Locate package.json and
workflows that reference Node versions (search for "actions/setup-node",
"node-version", or job names like "test" / "build") and update them accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/api/client/types.gen.ts`:
- Around line 169-176: The SseFn type incorrectly treats TError as the second
generic for ServerSentEventsResult (which expects the stream return slot as the
second generic). Update SseFn to remove TError and introduce proper generics for
the stream return/next slots; for example declare SseFn as <TData = unknown,
TReturn = void, TNext = unknown, ThrowOnError extends boolean = false,
TResponseStyle extends ResponseStyle = "fields">(...) =>
Promise<ServerSentEventsResult<TData, TReturn, TNext>> so the second generic
maps to the generator return type (TReturn) and the third maps to the next/emit
payload (TNext), while keeping the same options parameter shape
(Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, "method">).

In `@lib/api/client/utils.gen.ts`:
- Around line 114-131: The checkForExistence function incorrectly treats falsy
query values as absent and can false-match cookie name substrings; update it to
detect query keys using a proper key-existence check (e.g.,
Object.prototype.hasOwnProperty.call(options.query, name) or equivalent) instead
of truthiness, keep headers.has(name) as-is, and replace the naive
options.headers.get("Cookie")?.includes(`${name}=`) with a cookie-name boundary
check (parse the Cookie header into key=value pairs or use a regex that enforces
start-or-semicolon boundary like /(?:^|;\s*)NAME=/ with NAME replaced safely) so
only exact cookie names match.

In `@lib/api/core/bodySerializer.gen.ts`:
- Around line 54-69: The bodySerializer currently calls Object.entries(body) and
will throw for null or non-object inputs; update bodySerializer to first guard
that body is a plain object (e.g., typeof body === "object" && body !== null)
and if not, return an empty FormData immediately, then proceed to iterate and
call serializeFormDataPair; apply the same guard to the other generated
serializer in this file (the block referenced at lines ~80-95) and ideally fix
the generator/template that emits these serializers so future regenerations
include this non-object guard.
- Around line 41-50: In serializeUrlSearchParamsPair handle Date explicitly:
inside the function serializeUrlSearchParamsPair check if value is an instance
of Date and if so call value.toISOString() and append that string to data;
otherwise keep the existing string branch and fall back to JSON.stringify for
other types—update the generator/template so the serializeUrlSearchParamsPair
function treats Date the same way as the FormData path by emitting ISO strings
instead of JSON-quoted values.

In `@lib/api/core/serverSentEvents.gen.ts`:
- Around line 241-258: The catch block currently retries on all errors; change
it to detect cancellation/abort and stop retrying immediately by returning or
breaking before calling retry logic. In the catch(error) where onSseError is
called, add a guard that checks for abort conditions (e.g.
controller.signal?.aborted or error.name === 'AbortError' or a provider-specific
aborted flag) and if true, call onSseError?.(error) and then exit the loop
(break/return) without computing backoff or awaiting sleep; keep the existing
retry behavior only for non-abort errors (still honoring sseMaxRetryAttempts,
attempt, backoff, retryDelay, sseMaxRetryDelay, sleep).

In `@lib/utilities/getToken.ts`:
- Line 51: The audience value is built from kindeConfig.kindeDomain on line 51
but elsewhere (line 21) token validation expects kindeConfig.audience, creating
a drift risk; to fix, pick a single source of truth by changing the constructed
audience assignment in getToken (the place that currently sets audience:
kindeConfig.kindeDomain + "/api") to use kindeConfig.audience instead, or
alternately update the validation to compare against the constructed
value—ensure both the audience assignment and the validation reference the same
symbol (kindeConfig.audience) so they cannot diverge.

In `@tests/regressions.test.ts`:
- Around line 457-461: Prettier is failing because of repeated inline type casts
around result; refactor by introducing a local typed alias for the expected
shape (e.g., declare a local type or interface for { users?: { billing?: {
customer_id?: string } }[] } and cast result once), then replace the inline
casts in the checks where you access users and create the users variable (the
current usages referencing result and users). This will simplify the if checks
and remove the long inline cast blocks that break formatting; ensure you replace
both occurrences (the creation of users and the later similar block) with the
new alias and a single cast.

---

Outside diff comments:
In `@openapi-ts.config.ts`:
- Around line 1-30: Add a Node.js engine constraint and update CI to Node
>=22.13: add an "engines" entry to package.json with "node": ">=22.13" (so
package.json enforces runtime), and update all GitHub Actions workflow files
under .github/workflows that use actions/setup-node or a node-version matrix to
use 22.x or a literal >=22.13 (e.g., node-version: '22.x' or matrix value
'22.x') so CI runs on Node 22+. Locate package.json and workflows that reference
Node versions (search for "actions/setup-node", "node-version", or job names
like "test" / "build") and update them accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8d09a37f-11ce-4a81-9058-5ec9451bcfdf

📥 Commits

Reviewing files that changed from the base of the PR and between c621a99 and 3e89aa4.

⛔ Files ignored due to path filters (2)
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
📒 Files selected for processing (30)
  • lib/api/callbacks-compat.d.ts
  • lib/api/callbacks-compat.ts
  • lib/api/client.gen.ts
  • lib/api/client/client.gen.ts
  • lib/api/client/index.ts
  • lib/api/client/types.gen.ts
  • lib/api/client/utils.gen.ts
  • lib/api/core/ApiError.ts
  • lib/api/core/ApiRequestOptions.ts
  • lib/api/core/ApiResult.ts
  • lib/api/core/CancelablePromise.ts
  • lib/api/core/OpenAPI.ts
  • lib/api/core/auth.gen.ts
  • lib/api/core/bodySerializer.gen.ts
  • lib/api/core/params.gen.ts
  • lib/api/core/pathSerializer.gen.ts
  • lib/api/core/queryKeySerializer.gen.ts
  • lib/api/core/request.ts
  • lib/api/core/serverSentEvents.gen.ts
  • lib/api/core/types.gen.ts
  • lib/api/core/utils.gen.ts
  • lib/api/index.ts
  • lib/api/sdk.gen.ts
  • lib/api/types.gen.ts
  • lib/config.ts
  • lib/main.test.ts
  • lib/main.ts
  • lib/utilities/getToken.ts
  • openapi-ts.config.ts
  • tests/regressions.test.ts
💤 Files with no reviewable changes (7)
  • lib/api/core/ApiResult.ts
  • lib/api/core/ApiRequestOptions.ts
  • lib/api/core/ApiError.ts
  • lib/main.test.ts
  • lib/api/core/OpenAPI.ts
  • lib/api/core/CancelablePromise.ts
  • lib/api/core/request.ts

Comment thread lib/api/client/types.gen.ts
Comment thread lib/api/client/utils.gen.ts
Comment thread lib/api/core/bodySerializer.gen.ts
Comment thread lib/api/core/bodySerializer.gen.ts
Comment thread lib/api/core/serverSentEvents.gen.ts
Comment thread lib/utilities/getToken.ts Outdated
Comment thread tests/regressions.test.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the generated Management API client from @hey-api/openapi-ts 0.71.1 to 0.96.1, updating generation config, replacing the old OpenAPI singleton-based runtime with the new client runtime, and adapting library/test call sites to the new { path, query, body } request shapes.

Changes:

  • Upgraded @hey-api/openapi-ts to ^0.96.0 and refreshed the lockfile with new transitive dependencies/engine requirements.
  • Updated codegen configuration and regenerated lib/api/** to the new client architecture (new core/client runtime files; old core removed).
  • Updated SDK initialization and regression tests to use the new client + new parameter shapes; maintained deprecated Callbacks method aliases via a compat layer.

Reviewed changes

Copilot reviewed 28 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/regressions.test.ts Updates request argument shapes for new SDK; currently weak assertions around new RequestResult return shape.
pnpm-lock.yaml Locks new @hey-api/openapi-ts dependency tree (includes new Node engine requirements).
package.json Bumps @hey-api/openapi-ts to ^0.96.0.
openapi-ts.config.ts Migrates config to new options (postProcess, operations.strategy, includeInEntry, new fetch client plugin).
lib/utilities/getToken.ts Removes OpenAPI dependency; computes audience from config domain (but should respect kindeConfig.audience).
lib/main.ts Changes public exports to avoid index conflicts; now exports schemas + explicit SDK classes + compat Callbacks.
lib/main.test.ts Updates expected top-level exports after removal of old OpenAPI core exports.
lib/config.ts Switches initialization from OpenAPI merge to client.setConfig({ baseUrl, auth }).
lib/api/index.ts Regenerated entry exports; now includes renamed exports (Applications2, etc.) due to name conflicts.
lib/api/core/utils.gen.ts New generated runtime utilities (URL/path serialization, request body normalization).
lib/api/core/types.gen.ts New generated core types (client/config primitives).
lib/api/core/serverSentEvents.gen.ts New generated SSE client support.
lib/api/core/request.ts Old generated request pipeline removed.
lib/api/core/queryKeySerializer.gen.ts New generated query-key serialization helpers.
lib/api/core/pathSerializer.gen.ts New generated path/query serialization utilities.
lib/api/core/params.gen.ts New generated args→{body,query,path,headers} mapping utilities.
lib/api/core/bodySerializer.gen.ts New generated body/query serializer implementations.
lib/api/core/auth.gen.ts New generated auth token helper.
lib/api/core/OpenAPI.ts Old OpenAPI singleton removed.
lib/api/core/CancelablePromise.ts Old cancelable promise runtime removed.
lib/api/core/ApiResult.ts Old API result type removed.
lib/api/core/ApiRequestOptions.ts Old request options type removed.
lib/api/core/ApiError.ts Old API error type removed.
lib/api/client/utils.gen.ts New generated fetch-client helpers (auth injection, header merge, interceptors, config creation).
lib/api/client/types.gen.ts New generated client request/response typings (RequestResult, Options, etc.).
lib/api/client/index.ts New generated client barrel exports.
lib/api/client/client.gen.ts New generated fetch client implementation (request pipeline, parsing, interceptors, throwOnError support).
lib/api/client.gen.ts New generated singleton client instance.
lib/api/callbacks-compat.ts Updates compat layer to new Options<..., ThrowOnError> signatures and new return types.
lib/api/callbacks-compat.d.ts Updates type augmentation for deprecated Callbacks method aliases under the new client types.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/regressions.test.ts Outdated
Comment thread tests/regressions.test.ts Outdated
Comment thread lib/main.ts
Comment thread package.json
Comment thread lib/config.ts
Comment thread lib/utilities/getToken.ts
- Use kindeConfig.audience as primary audience source in generateM2MToken,
  falling back to kindeDomain + "/api" (guards against external mutation drift)
- Add export type * from ./api/types.gen to lib/main.ts to restore the
  full request/response type surface in the public API entry point
- Set responseStyle: "data" and throwOnError: true in client.setConfig()
  to preserve backwards-compatible call semantics from the old OpenAPI client
- Fix dead billing-expand test assertions: replace double inline casts with
  local type aliases so assertions actually execute under the new client shape
- Format lib/api/client/types.gen.ts and lib/api/core/pathSerializer.gen.ts
  to unblock the Prettier CI gate
- Bump CI node-version to 22.x and add engines.node >=22.13.0 to package.json
  to match @hey-api/openapi-ts@0.96.x runtime requirement

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/regressions.test.ts`:
- Around line 459-464: The test currently guards core assertions with "if
(users?.length)" which can silently skip checks; change the test to explicitly
assert that "users" is defined and non-empty (for example assert users is
defined and expect(users.length).toBeGreaterThan(0)) before accessing users[0];
then remove the conditional and run the existing assertions on users[0].billing
and users[0].billing?.customer_id so failures are deterministic. Ensure you
update both occurrences that use the same pattern around the "users" variable
and the BillingUser type check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55e3a67d-b3d4-4662-9f9d-e00f74a32730

📥 Commits

Reviewing files that changed from the base of the PR and between 3e89aa4 and ff4a7a0.

⛔ Files ignored due to path filters (2)
  • .github/workflows/build-test-ci.yml is excluded by !**/*.yml
  • package.json is excluded by !**/*.json
📒 Files selected for processing (7)
  • lib/api/client/types.gen.ts
  • lib/api/core/pathSerializer.gen.ts
  • lib/config.ts
  • lib/main.ts
  • lib/utilities/getToken.ts
  • openapi-ts.config.ts
  • tests/regressions.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • lib/config.ts
  • lib/utilities/getToken.ts
  • lib/main.ts
  • openapi-ts.config.ts
  • lib/api/core/pathSerializer.gen.ts
  • lib/api/client/types.gen.ts

Comment thread tests/regressions.test.ts Outdated
- Replace if (users?.length) guards with explicit expect(users).toBeDefined()
  and expect(users!.length).toBeGreaterThan(0) so billing assertion failures
  are deterministic rather than silently skipped
- Add parseAs: 'json' to client.setConfig() so responses are always parsed
  as JSON; fixes test environment where vitest-fetch-mock does not set
  Content-Type header, causing parseAs: auto to fall back to stream mode
- Merge origin/main (commits up to 899f5a6) into feat/migrate/openapi-ts-0.96
- Take updated kinde-mgmt-api-specs.yaml (+977 lines) from main
- Regenerate lib/api/{sdk,types,schemas,index}.gen.ts with openapi-ts 0.96.1
  against the updated spec (adds Directories class and new endpoints)
- Add Directories to lib/main.ts SDK class exports
- Add ApiError class (lib/utilities/ApiError.ts) with error interceptor in
  config.ts so non-2xx responses throw ApiError instances with .status property
- Add ApiError to lib/main.ts exports and lib/main.test.ts expected list
- Take pnpm@10.33.4 packageManager from main; retain engines node>=22.13.0
- Upgrade @hey-api/client-fetch to ^0.13.0 from main; retain openapi-ts ^0.96.0

Tests: 68/68 passing, lint clean, tsc --noEmit clean
@shafaladhikari

Copy link
Copy Markdown
Contributor

Hi @dtoxvanilla1991, I found a issue of typescript and runtime mismatch happening in the returned response from the sdk methods.

Root Cause

responseStyle: "data" was present in the @hey-api/sdk plugin config before the 0.96.1 migration (55f5b93) but was dropped in the migration commit (3e89aa4) when switching from legacy/fetch + asClass: true to @hey-api/client-fetch + strategy: "byTags".

Without it, the generated types default to the "fields" shape — methods typed as returning { data: T, request, response } — while responseStyle: "data" in client.setConfig() makes the runtime return T directly. TypeScript and runtime disagree.

Fix

Add responseStyle: "data" back to the @hey-api/sdk plugin in openapi-ts.config.ts:

{
  name: "@hey-api/sdk",
  operations: { strategy: "byTags" },
  responseStyle: "data", // restores correct types
}

This makes the generated types correctly reflect the runtime shape. Any wrong access pattern (e.g. destructuring { data } from the result) will then be caught by TypeScript rather than silently failing at runtime.

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.

4 participants