-
-
Notifications
You must be signed in to change notification settings - Fork 268
feat: add ky client plugin #2958
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
feat: add ky client plugin #2958
Conversation
Implements @hey-api/client-ky plugin with support for ky HTTP client. Features: - Ky integration with native retry, timeout, and hooks - Standard interceptors pattern (request/response/error) - Configurable retry options (limit, methods, statusCodes) - Raw ky options via kyOptions escape hatch - Full HTTP method support and SSE - Follows established client plugin architecture The implementation maintains consistency with other client plugins while leveraging ky's powerful built-in features.
|
|
🦋 Changeset detectedLatest commit: 212fcaf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@SebastiaanWouters is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2958 +/- ##
==========================================
+ Coverage 28.58% 29.41% +0.83%
==========================================
Files 394 403 +9
Lines 35186 35766 +580
Branches 1938 2066 +128
==========================================
+ Hits 10057 10522 +465
- Misses 25102 25217 +115
Partials 27 27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add test suite for ky client plugin with comprehensive coverage: - buildUrl functionality with various path/query scenarios - zero-length body handling for all content types - unserialized and serialized request body handling - request, response, and error interceptors - error handling with throwOnError option - retry configuration - responseStyle configuration Tests follow patterns from client-fetch and cover all core functionality.
Fix TypeScript compilation errors without using `as any`: - Use inline array type instead of accessing `KyOptions['retry']['methods']` to avoid type error when retry can be number | object - Add type assertion for headers as HeadersInit to satisfy Request constructor - Change body type from `BodyInit | null` to `unknown` for consistency with client-fetch and to allow testing with edge case values - Use `Partial<KyInstance> as KyInstance` pattern in tests (same as client-axios) to properly type mock ky instances without `as any`
Add example project demonstrating ky client usage: - Created @example/openapi-ts-ky package with React/Vite setup - Configured to use @hey-api/client-ky plugin - Includes generated client code from Swagger Petstore OpenAPI spec Updated build configuration: - Added 'client-ky' to tsdown.config.ts plugin list - Ensures ky bundle files are copied to dist/clients/ky during build - Enables runtime access to ky client implementation This example allows typecheck validation in CI and serves as documentation for ky client integration.
commit: |
| * Additional ky-specific options that will be passed directly to ky. | ||
| * This allows you to use any ky option not explicitly exposed in the config. | ||
| */ | ||
| kyOptions?: Omit<import('ky').Options, 'method' | 'prefixUrl'>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SebastiaanWouters why did you decide to namespace these instead of extending Config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vibe coded v0 sometimes contain weird choices, better to expose ky's API directly here indeed.
|
|
||
| export interface Config<T extends ClientOptions = ClientOptions> | ||
| extends Omit< | ||
| import('ky').Options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SebastiaanWouters why use dynamic import instead of importing on top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes import on top is the better choice here 👍
Closes #2794
Implements @hey-api/client-ky plugin with support for ky HTTP client.
Features:
The implementation maintains consistency with other client plugins while leveraging ky's powerful built-in features.