Skip to content

feat(hey-api): improve compatibility #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2025
Merged

Conversation

unnoq
Copy link
Owner

@unnoq unnoq commented Jun 7, 2025

Summary by CodeRabbit

  • New Features

    • Added support for a new response type when updating a planet, including a new "UpdatedPlanet" object with an ID field.
  • Bug Fixes

    • Improved naming consistency for planet-related API endpoints, responses, and types.
  • Documentation

    • Updated API documentation to reflect new operation IDs and response types for planet endpoints.
  • Style

    • Renamed functions and types for better clarity and consistency across the API and SDK.

Copy link

vercel bot commented Jun 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2025 1:18am

Copy link

coderabbitai bot commented Jun 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update renames all planet-related API method and type names for consistency, such as changing listPlanets to planetList and createPlanet to planetCreate. It also updates the OpenAPI spec, introduces a new UpdatedPlanet type and response, and enhances the type mapping utility to support nested SDK structures.

Changes

File(s) Change Summary
.../src/to-orpc-client.test-d.ts
.../src/to-orpc-client.test.ts
Renamed all references from listPlanets/createPlanet to planetList/planetCreate in tests.
.../src/to-orpc-client.ts Updated experimental_ToORPCClientResult type: removed options constraint and added recursive mapping.
.../tests/client/sdk.gen.ts Renamed SDK functions/types: listPlanetsplanetList, createPlanetplanetCreate and related types.
.../tests/client/types.gen.ts Renamed planet-related types, added UpdatedPlanet type and new 200 response for PlanetCreateResponses.
.../tests/spec.json Changed operationIds for /planets endpoints, added 200 response and UpdatedPlanet schema.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant SDK
    participant API

    Client->>SDK: planetList(query?)
    SDK->>API: GET /planets?query
    API-->>SDK: PlanetListResponses
    SDK-->>Client: PlanetListResponses

    Client->>SDK: planetCreate(body)
    SDK->>API: POST /planets (body)
    API-->>SDK: PlanetCreateResponses (200: UpdatedPlanet or 201: Planet)
    SDK-->>Client: PlanetCreateResponses
Loading

Possibly related PRs

  • unnoq/orpc#593: Also modifies experimental_ToORPCClientResult type, focusing on return type inference.
  • unnoq/orpc#547: Introduces the initial integration of Hey API clients and the experimental_toORPCClient function, which is further refined in this PR.
  • unnoq/orpc#611: Contains identical renaming and type mapping changes, indicating a direct relation or overlap with this PR.

Poem

Oh, planets now list and create anew,
With names aligned and types in view!
An update here, a schema there—
Nested clients handled with care.
🪐✨
Hop, hop, hooray,
For tidy code and SDK!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 606bab3 and 81a1749.

📒 Files selected for processing (1)
  • packages/hey-api/tests/spec.json (4 hunks)

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jun 7, 2025

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@611

@orpc/client

npm i https://pkg.pr.new/@orpc/client@611

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@611

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@611

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@611

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@611

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@611

@orpc/react

npm i https://pkg.pr.new/@orpc/react@611

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@611

@orpc/server

npm i https://pkg.pr.new/@orpc/server@611

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@611

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@611

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@611

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@611

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@611

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@611

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@611

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@611

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@611

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@611

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@611

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@611

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@611

commit: 81a1749

Copy link

codecov bot commented Jun 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/hey-api/tests/client/types.gen.ts (1)

44-44: Fix grammatical error in comment.

The comment contains a grammatical error that should be corrected.

-     * A updated planet
+     * An updated planet

Note: Since this is auto-generated code, the fix should be applied to the OpenAPI specification or generator template.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27cdd69 and 606bab3.

📒 Files selected for processing (6)
  • packages/hey-api/src/to-orpc-client.test-d.ts (2 hunks)
  • packages/hey-api/src/to-orpc-client.test.ts (9 hunks)
  • packages/hey-api/src/to-orpc-client.ts (1 hunks)
  • packages/hey-api/tests/client/sdk.gen.ts (2 hunks)
  • packages/hey-api/tests/client/types.gen.ts (2 hunks)
  • packages/hey-api/tests/spec.json (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/hey-api/src/to-orpc-client.test-d.ts (2)
packages/client/src/types.ts (1)
  • NestedClient (30-32)
packages/hey-api/tests/client/types.gen.ts (1)
  • Planet (3-6)
packages/hey-api/src/to-orpc-client.ts (1)
packages/client/src/types.ts (1)
  • Client (26-28)
packages/hey-api/tests/client/sdk.gen.ts (1)
packages/hey-api/tests/client/types.gen.ts (4)
  • PlanetListData (16-24)
  • PlanetListResponses (26-31)
  • PlanetCreateData (35-40)
  • PlanetCreateResponses (42-51)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: publish-commit
  • GitHub Check: lint
🔇 Additional comments (12)
packages/hey-api/src/to-orpc-client.test-d.ts (1)

12-12: LGTM: Consistent method renaming applied throughout type tests.

The renaming from listPlanets/createPlanet to planetList/planetCreate is consistently applied across all test cases. The enhanced return type on line 45 correctly reflects the union type Planet | { id: string } which aligns with the new UpdatedPlanet schema added to the OpenAPI spec.

Also applies to: 19-19, 21-26, 28-33, 43-43, 45-45

packages/hey-api/src/to-orpc-client.test.ts (1)

50-50: LGTM: Method renaming consistently applied across all test scenarios.

All test cases have been properly updated to use the new method names planetList and planetCreate. The test logic, assertions, and error handling remain unchanged, ensuring that functionality is preserved while adopting the new naming convention.

Also applies to: 59-59, 72-72, 93-93, 105-105, 119-119, 135-135, 148-148, 157-157

packages/hey-api/src/to-orpc-client.ts (2)

5-5: Improved type inference by removing parameter constraint.

Removing the explicit constraint on the options parameter allows for more flexible type inference of UInput, improving compatibility with various SDK input types.


12-14: Enhanced support for nested SDK structures.

The recursive type mapping now properly handles nested record properties by mapping them to their corresponding client result types, rather than returning never. This enables the type system to correctly represent complex nested SDK structures while maintaining type safety.

packages/hey-api/tests/spec.json (2)

77-86: New 200 response extends API contract for planet creation.

The addition of a 200 response with UpdatedPlanet schema means the POST /planets endpoint can now return either a newly created planet (201) or an updated existing planet (200). This is a valid API design but represents a change in the API contract.


151-159: UpdatedPlanet schema appropriately minimal.

The new UpdatedPlanet schema correctly requires only the id field, which makes sense for an update response where only the identifier might be guaranteed to be present.

packages/hey-api/tests/client/sdk.gen.ts (3)

4-4: LGTM! Consistent type import renaming.

The import statement correctly reflects the renamed types from ListPlanets*/CreatePlanet* to PlanetList*/PlanetCreate* pattern, maintaining consistency with the updated API specification.


21-26: Function renaming follows consistent pattern.

The listPlanets to planetList renaming aligns with the new naming convention. The function implementation remains correct with properly updated type references.

Note: This introduces a breaking change for existing consumers of the SDK.


28-37: Function renaming maintains type safety.

The createPlanet to planetCreate renaming is consistent with the overall refactoring. The function correctly uses the updated PlanetCreateResponses type which now includes both 200 (UpdatedPlanet) and 201 (Planet) responses.

packages/hey-api/tests/client/types.gen.ts (3)

12-14: Good addition of UpdatedPlanet type.

The new UpdatedPlanet type provides clear distinction between created and updated planet responses, enhancing type safety for different API response scenarios.


16-33: Consistent type renaming pattern.

The renaming from ListPlanetsData/ListPlanetsResponses/ListPlanetsResponse to PlanetListData/PlanetListResponses/PlanetListResponse follows a clear, consistent pattern that improves API naming conventions.


35-53: Enhanced response type with proper renaming.

The PlanetCreateResponses type correctly includes both 200 (UpdatedPlanet) and 201 (Planet) responses, providing flexibility for different API behaviors. The renaming pattern is consistently applied.

@unnoq unnoq merged commit 75882c5 into main Jun 7, 2025
4 of 6 checks passed
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