@hyper-fetch/hono 10.0.0 โ†’ 10.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,39 +1,31 @@
1
- # ๐Ÿฏ Hyper Fetch Hono
1
+ <p align="center">
2
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/.github/assets/packages/hono.png" alt="Hyper Fetch Hono. Your Hono app. Typed on the client. Route, validator and param types read from typeof app with no codegen and no runtime." /></a>
3
+ </p>
2
4
 
3
5
  <p align="center">
4
- <b>Call your Hono backend from a fully typed HyperFetch SDK. No codegen, no duplicated types.</b>
6
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><b>Quick Start</b></a> ยท
7
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview">Documentation</a> ยท
8
+ <a href="https://hyperfetch.bettertyped.com/docs/api/hono/Types/HonoSchema">API Reference</a> ยท
9
+ <a href="https://github.com/BetterTyped/hyper-fetch">GitHub</a> ยท
10
+ <a href="https://discord.gg/7upC2kVmyM">Discord</a>
5
11
  </p>
6
12
 
7
13
  <p align="center">
8
- <a href="https://github.com/BetterTyped/hyper-fetch">
9
- <img src="https://img.shields.io/github/stars/BetterTyped/hyper-fetch?logo=github&color=118ab2" alt="GitHub stars" />
10
- </a>
11
- <a href="https://www.npmjs.com/package/@hyper-fetch/hono">
12
- <img src="https://img.shields.io/npm/v/@hyper-fetch/hono?logo=npm&color=e76f51" alt="npm version" />
13
- </a>
14
- <a href="https://www.npmjs.com/package/@hyper-fetch/hono">
15
- <img src="https://img.shields.io/npm/dm/@hyper-fetch/hono?logo=npm" alt="npm downloads" />
16
- </a>
17
- <a href="https://bundlephobia.com/package/@hyper-fetch/hono">
18
- <img src="https://img.shields.io/bundlephobia/minzip/@hyper-fetch/hono?color=64BC4B" alt="bundle size" />
19
- </a>
20
- <a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md">
21
- <img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch?color=yellow" alt="license" />
22
- </a>
23
- <a href="https://github.com/BetterTyped/hyper-fetch">
24
- <img src="https://img.shields.io/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" alt="TypeScript" />
25
- </a>
26
- <a href="https://hono.dev/">
27
- <img src="https://img.shields.io/badge/hono-E36002?logo=hono&logoColor=white" alt="Hono" />
28
- </a>
14
+ <a href="https://github.com/BetterTyped/hyper-fetch"><img src="https://img.shields.io/github/stars/BetterTyped/hyper-fetch?style=flat&logo=github&color=333" alt="GitHub stars" /></a>
15
+ <a href="https://www.npmjs.com/package/@hyper-fetch/hono"><img src="https://img.shields.io/npm/v/@hyper-fetch/hono?logo=npm&color=e76f51" alt="npm version" /></a>
16
+ <a href="https://www.npmjs.com/package/@hyper-fetch/hono"><img src="https://api.maciejpyrc.com/portfolio/npm/downloads.svg?packages=@hyper-fetch/hono&color=fbc646" alt="Monthly downloads" /></a>
17
+ <a href="https://bundlejs.com/?q=@hyper-fetch/hono"><img src="https://api.maciejpyrc.com/portfolio/npm/size.svg?package=@hyper-fetch/hono&external=@hyper-fetch/core,hono" alt="Bundle size" /></a>
18
+ <a href="https://github.com/BetterTyped/hyper-fetch"><img src="https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white" alt="TypeScript" /></a>
19
+ <a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><img src="https://img.shields.io/badge/Hono-4%2B-E36002?logo=hono&logoColor=white" alt="Hono" /></a>
20
+ <a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md"><img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch?color=blue" alt="License" /></a>
29
21
  </p>
30
22
 
31
23
  ## ๐Ÿ“– About
32
24
 
33
- `@hyper-fetch/hono` turns the type of a Hono app into a HyperFetch SDK schema. Your frontend calls the backend through
34
- `createSdk` with response, payload, query and param types read straight from your Hono routes and validators, and its
35
- sockets connect to `upgradeWebSocket()` and `streamSSE()` routes at type-checked paths. It ships types only, so nothing
36
- from your server ends up in the client bundle.
25
+ `@hyper-fetch/hono` turns the type of a Hono app into a Hyper Fetch SDK schema. Your frontend calls the backend
26
+ through `createSdk` with response, payload, query and param types read straight from your Hono routes and validators,
27
+ and its sockets connect to `upgradeWebSocket()` and `streamSSE()` routes at type-checked paths. It ships types only, so
28
+ nothing from your server ends up in the client bundle.
37
29
 
38
30
  ## ๐ŸŽฏ Key Capabilities
39
31
 
@@ -42,10 +34,10 @@ from your server ends up in the client bundle.
42
34
  - ๐Ÿ›‚ **Validators drive the payload** - `json` and `query` validators type `setPayload()` and `setQueryParams()`
43
35
  - ๐Ÿงฉ **Mounted routers included** - `app.route()` and `basePath()` prefixes land in the endpoint and the nesting
44
36
  - ๐Ÿงท **Every path shape** - Optional `:id?` and regex `:id{[0-9]+}` params, `.all()` and `app.on()` get typed accessors
45
- - ๐Ÿ“ก **Realtime routes too** - `HonoWebSocketPath` rejects socket URLs that match no `upgradeWebSocket()` route
37
+ - ๐Ÿ“ก **Realtime routes too** - `HonoSocketPath` rejects socket URLs that match no `upgradeWebSocket()` route
46
38
  - ๐Ÿšซ **No fake requests** - WebSocket routes stay out of the HTTP SDK, so nobody calls `send()` on them
47
39
  - ๐Ÿชถ **Zero runtime** - Type exports only, so it adds no code to your bundle
48
- - โšก **Every HyperFetch feature** - Cache, retries, deduplication, offline and React hooks work on every route
40
+ - โšก **Every HyperFetch feature** - Cache, retries, deduplication, offline replay and React hooks on every route
49
41
 
50
42
  ## ๐Ÿš€ Quick Start
51
43
 
@@ -56,11 +48,11 @@ npm install @hyper-fetch/core @hyper-fetch/hono
56
48
  ```ts
57
49
  // backend
58
50
  import { Hono } from "hono";
59
- import type { HonoAppToHyperFetch } from "@hyper-fetch/hono";
51
+ import type { HonoSchema } from "@hyper-fetch/hono";
60
52
 
61
53
  const app = new Hono().get("/users/:userId", (c) => c.json({ id: c.req.param("userId"), name: "Ann" }));
62
54
 
63
- export type AppSchema = HonoAppToHyperFetch<typeof app>;
55
+ export type AppSchema = HonoSchema<typeof app>;
64
56
  ```
65
57
 
66
58
  ```ts
@@ -71,15 +63,16 @@ import type { AppSchema } from "@my-app/backend";
71
63
  const client = createClient({ url: "https://api.example.com" });
72
64
  const sdk = createSdk<typeof client, AppSchema>(client);
73
65
 
66
+ // data is { id: string; name: string } | null
74
67
  const { data } = await sdk.users.$userId.$get.setParams({ userId: "1" }).send();
75
68
  ```
76
69
 
77
70
  ## ๐Ÿ“š Documentation
78
71
 
79
- - [Hono Integration Docs](https://hyperfetch.bettertyped.com/docs/integrations/hono/overview)
80
- - [Hono Realtime](https://hyperfetch.bettertyped.com/docs/integrations/hono/realtime)
81
- - [SDK Guide](https://hyperfetch.bettertyped.com/docs/core/sdk)
82
- - [Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)
72
+ - **[Hono Integration](https://hyperfetch.bettertyped.com/docs/integrations/hono/overview)** - Setup, routes, validators and path shapes
73
+ - **[Hono Realtime](https://hyperfetch.bettertyped.com/docs/integrations/hono/realtime)** - WebSocket and Server-Sent Events routes
74
+ - **[SDK](https://hyperfetch.bettertyped.com/docs/core/sdk)** - How `createSdk` turns a schema into requests
75
+ - **[API Reference](https://hyperfetch.bettertyped.com/docs/api/hono/Types/HonoSchema)** - Every exported type
83
76
 
84
77
  ## ๐Ÿ’ก Examples
85
78
 
@@ -88,7 +81,7 @@ const { data } = await sdk.users.$userId.$get.setParams({ userId: "1" }).send();
88
81
  ```ts
89
82
  import { Hono } from "hono";
90
83
  import { validator } from "hono/validator";
91
- import type { HonoAppToHyperFetch } from "@hyper-fetch/hono";
84
+ import type { HonoSchema } from "@hyper-fetch/hono";
92
85
 
93
86
  const users = new Hono()
94
87
  .get("/", (c) => c.json([{ id: "1", name: "Ann" }]))
@@ -102,13 +95,15 @@ const auth = new Hono().get("/google-login", (c) => c.json({ authUrl: "https://a
102
95
 
103
96
  const app = new Hono().route("/users", users).route("/auth", auth);
104
97
 
105
- export type AppSchema = HonoAppToHyperFetch<typeof app>;
98
+ export type AppSchema = HonoSchema<typeof app>;
106
99
  ```
107
100
 
108
101
  ```ts
109
102
  const sdk = createSdk<typeof client, AppSchema>(client);
110
103
 
104
+ // the payload is typed by the json validator
111
105
  await sdk.users.$post.setPayload({ name: "Bob" }).send();
106
+
112
107
  // kebab-case paths become camelCase properties: GET /auth/google-login
113
108
  await sdk.auth.googleLogin.$get.send();
114
109
  ```
@@ -123,7 +118,7 @@ import { sdk } from "./api";
123
118
  export const UserName = ({ userId }: { userId: string }) => {
124
119
  const { data, loading } = useFetch(sdk.users.$userId.$get.setParams({ userId }));
125
120
 
126
- if (loading) return <p>Loading...</p>;
121
+ if (loading) return <Spinner />;
127
122
  return <p>{data?.name}</p>;
128
123
  };
129
124
  ```
@@ -152,9 +147,9 @@ export type ChatSchema = { message: { $listener: ListenerModel<{ response: { tex
152
147
  ```ts
153
148
  // frontend
154
149
  import { createSocketSdk, Socket } from "@hyper-fetch/sockets";
155
- import type { HonoWebSocketPath } from "@hyper-fetch/hono";
150
+ import type { HonoSocketPath } from "@hyper-fetch/hono";
156
151
 
157
- const path: HonoWebSocketPath<AppType> = `/chat/${roomId}`; // "/rooms/1" would not compile
152
+ const path: HonoSocketPath<AppType> = `/chat/${roomId}`; // "/rooms/1" would not compile
158
153
  const socket = new Socket({ url: `wss://api.example.com${path}` });
159
154
  const chat = createSocketSdk<typeof socket, ChatSchema>(socket);
160
155
 
@@ -164,7 +159,7 @@ chat.message.$listener.listen(({ data }) => console.log(data.text));
164
159
  ### Server-Sent Events with named events
165
160
 
166
161
  ```ts
167
- // backend: named events reach the listeners of the event name, JSON data is parsed
162
+ // backend: named events reach the listeners of that event name, JSON data is parsed
168
163
  app.get("/events", (c) =>
169
164
  streamSSE(c, async (stream) => {
170
165
  await stream.writeSSE({ id: "1", event: "tick", data: JSON.stringify({ symbol: "BTC", price: 100 }) });
@@ -179,17 +174,46 @@ import { ServerSentEventsAdapter, Socket } from "@hyper-fetch/sockets";
179
174
 
180
175
  const events = new Socket({
181
176
  url: "http://localhost:3000/events",
182
- adapter: ServerSentEventsAdapter,
177
+ adapter: ServerSentEventsAdapter(),
183
178
  adapterOptions: { EventSource },
184
179
  });
185
180
 
186
181
  events
187
182
  .createListener<{ symbol: string; price: number }>()({ topic: "tick" })
188
- .listen(({ data }) => {
189
- console.log(data.price);
190
- });
183
+ .listen(({ data }) => console.log(data.price));
191
184
  ```
192
185
 
186
+ ## ๐Ÿงฉ Hyper Fetch Ecosystem
187
+
188
+ One typed client for every backend. Swap the adapter and keep the same `createRequest()` everywhere.
189
+
190
+ <table align="center">
191
+ <tr>
192
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/core"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-hyper-fetch.svg" width="36" height="36" alt="" /><br /><sub><b>Core</b></sub></a></td>
193
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/react"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-react.svg" width="36" height="36" alt="" /><br /><sub><b>React</b></sub></a></td>
194
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/sockets"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-sockets.svg" width="36" height="36" alt="" /><br /><sub><b>Sockets</b></sub></a></td>
195
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/cli"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-openapi.svg" width="36" height="36" alt="" /><br /><sub><b>OpenAPI CLI</b></sub></a></td>
196
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-graphql"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-graphql.svg" width="36" height="36" alt="" /><br /><sub><b>GraphQL</b></sub></a></td>
197
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-trpc"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-trpc.svg" width="36" height="36" alt="" /><br /><sub><b>tRPC</b></sub></a></td>
198
+ </tr>
199
+ <tr>
200
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-orpc"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-orpc-dark.svg" /><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-orpc.svg" width="36" height="36" alt="" /></picture><br /><sub><b>oRPC</b></sub></a></td>
201
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/hono"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-hono.svg" width="36" height="36" alt="" /><br /><sub><b>Hono</b></sub></a></td>
202
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/elysia"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-elysia.svg" width="36" height="36" alt="" /><br /><sub><b>Elysia</b></sub></a></td>
203
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-firebase"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-firebase.svg" width="36" height="36" alt="" /><br /><sub><b>Firebase</b></sub></a></td>
204
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-axios"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-axios.svg" width="36" height="36" alt="" /><br /><sub><b>Axios</b></sub></a></td>
205
+ <td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/hyper-flow"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/hyper-flow.svg" width="36" height="36" alt="" /><br /><sub><b>HyperFlow</b></sub></a></td>
206
+ </tr>
207
+ </table>
208
+
209
+ ## ๐Ÿ’– Sponsors
210
+
211
+ <p align="center">
212
+ <a href="https://github.com/sponsors/prc5">
213
+ <img src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/other/sponsorkit/sponsors.svg?raw=true" alt="Sponsors" />
214
+ </a>
215
+ </p>
216
+
193
217
  ## License
194
218
 
195
219
  [Apache-2.0](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)
@@ -0,0 +1,26 @@
1
+ import { expectTypeOf } from "vitest";
2
+
3
+ import type {
4
+ HonoAppToHyperFetch,
5
+ HonoSchema,
6
+ HonoSocketPath,
7
+ HonoWebSocketPath,
8
+ } from "../../../src";
9
+ import type { app } from "../../utils/app";
10
+ import type { RealtimeApp } from "../../utils/realtime-server";
11
+
12
+ describe("Hono [ Deprecated names ]", () => {
13
+ it("should keep HonoAppToHyperFetch as an alias of HonoSchema", () => {
14
+ expectTypeOf<HonoAppToHyperFetch<typeof app>>().toEqualTypeOf<
15
+ HonoSchema<typeof app>
16
+ >();
17
+ expect(true).toBe(true);
18
+ });
19
+
20
+ it("should keep HonoWebSocketPath as an alias of HonoSocketPath", () => {
21
+ expectTypeOf<HonoWebSocketPath<RealtimeApp>>().toEqualTypeOf<
22
+ HonoSocketPath<RealtimeApp>
23
+ >();
24
+ expect(true).toBe(true);
25
+ });
26
+ });
@@ -1,13 +1,13 @@
1
1
  import type { ServerType } from "@hono/node-server";
2
2
  import { createClient, createSdk } from "@hyper-fetch/core";
3
3
 
4
- import type { HonoAppToHyperFetch } from "../../../src";
4
+ import type { HonoSchema } from "../../../src";
5
5
  import { inputsApp } from "../../utils/inputs.app";
6
6
  import { startServer, stopServer } from "../../utils/server";
7
7
 
8
- type Schema = HonoAppToHyperFetch<typeof inputsApp>;
8
+ type Schema = HonoSchema<typeof inputsApp>;
9
9
 
10
- describe("HonoAppToHyperFetch [ Validator inputs against a Hono server ]", () => {
10
+ describe("HonoSchema [ Validator inputs against a Hono server ]", () => {
11
11
  let server: ServerType;
12
12
  let url: string;
13
13
 
@@ -2,12 +2,12 @@ import { createClient, createSdk } from "@hyper-fetch/core";
2
2
  import type { ExtractPayloadType, ExtractQueryParamsType, ExtractResponseType } from "@hyper-fetch/core";
3
3
  import { expectTypeOf } from "vitest";
4
4
 
5
- import type { HonoAppToHyperFetch } from "../../../src";
5
+ import type { HonoSchema } from "../../../src";
6
6
  import type { inputsApp } from "../../utils/inputs.app";
7
7
 
8
- type Schema = HonoAppToHyperFetch<typeof inputsApp>;
8
+ type Schema = HonoSchema<typeof inputsApp>;
9
9
 
10
- describe("HonoAppToHyperFetch [ Validator inputs ]", () => {
10
+ describe("HonoSchema [ Validator inputs ]", () => {
11
11
  it("should take the payload from the json validator, optional fields included", () => {
12
12
  expectTypeOf<ExtractPayloadType<Schema["posts"]["$post"]>>().toEqualTypeOf<{ title: string; draft?: boolean }>();
13
13
  expect(true).toBe(true);
@@ -53,7 +53,7 @@ describe("HonoAppToHyperFetch [ Validator inputs ]", () => {
53
53
  });
54
54
  });
55
55
 
56
- describe("HonoAppToHyperFetch [ Validator inputs on createSdk ]", () => {
56
+ describe("HonoSchema [ Validator inputs on createSdk ]", () => {
57
57
  const client = createClient({ url: "http://localhost" });
58
58
  const sdk = createSdk<typeof client, Schema>(client);
59
59
 
@@ -1,13 +1,13 @@
1
1
  import type { ServerType } from "@hono/node-server";
2
2
  import { createClient, createSdk } from "@hyper-fetch/core";
3
3
 
4
- import type { HonoAppToHyperFetch } from "../../../src";
4
+ import type { HonoSchema } from "../../../src";
5
5
  import { pathsApp } from "../../utils/paths.app";
6
6
  import { startServer, stopServer } from "../../utils/server";
7
7
 
8
- type Schema = HonoAppToHyperFetch<typeof pathsApp>;
8
+ type Schema = HonoSchema<typeof pathsApp>;
9
9
 
10
- describe("HonoAppToHyperFetch [ Paths against a Hono server ]", () => {
10
+ describe("HonoSchema [ Paths against a Hono server ]", () => {
11
11
  let server: ServerType;
12
12
  let url: string;
13
13
 
@@ -3,12 +3,12 @@ import type { ClientInstance, ExtractClientType, ExtractEndpointType, ExtractRes
3
3
  import { Hono } from "hono";
4
4
  import { expectTypeOf } from "vitest";
5
5
 
6
- import type { HonoAppToHyperFetch } from "../../../src";
6
+ import type { HonoSchema } from "../../../src";
7
7
  import type { pathsApp, rootOptionalApp } from "../../utils/paths.app";
8
8
 
9
- type Schema = HonoAppToHyperFetch<typeof pathsApp>;
9
+ type Schema = HonoSchema<typeof pathsApp>;
10
10
 
11
- describe("HonoAppToHyperFetch [ Optional params ]", () => {
11
+ describe("HonoSchema [ Optional params ]", () => {
12
12
  it("should add a route with an optional param both without and with the param", () => {
13
13
  expectTypeOf<keyof Schema["files"]>().toEqualTypeOf<"$get" | "$fileId">();
14
14
  expectTypeOf<ExtractEndpointType<Schema["files"]["$get"]>>().toEqualTypeOf<"/files">();
@@ -32,7 +32,7 @@ describe("HonoAppToHyperFetch [ Optional params ]", () => {
32
32
  });
33
33
 
34
34
  it("should put the route without an optional root param at the top level", () => {
35
- type RootSchema = HonoAppToHyperFetch<typeof rootOptionalApp>;
35
+ type RootSchema = HonoSchema<typeof rootOptionalApp>;
36
36
 
37
37
  expectTypeOf<keyof RootSchema>().toEqualTypeOf<"$get" | "$lang">();
38
38
  expectTypeOf<ExtractEndpointType<RootSchema["$get"]>>().toEqualTypeOf<"/">();
@@ -49,7 +49,7 @@ describe("HonoAppToHyperFetch [ Optional params ]", () => {
49
49
  });
50
50
  });
51
51
 
52
- describe("HonoAppToHyperFetch [ Regex params ]", () => {
52
+ describe("HonoSchema [ Regex params ]", () => {
53
53
  it("should drop the pattern from the key and the endpoint", () => {
54
54
  expectTypeOf<keyof Schema["posts"]>().toEqualTypeOf<"$postId">();
55
55
  expectTypeOf<ExtractEndpointType<Schema["posts"]["$postId"]["$get"]>>().toEqualTypeOf<"/posts/:postId">();
@@ -66,7 +66,7 @@ describe("HonoAppToHyperFetch [ Regex params ]", () => {
66
66
 
67
67
  it("should drop a pattern that holds a slash", () => {
68
68
  const app = new Hono().get("/docs/:path{.+/.+}/raw", (c) => c.json({ path: c.req.param("path") }));
69
- type DocsSchema = HonoAppToHyperFetch<typeof app>;
69
+ type DocsSchema = HonoSchema<typeof app>;
70
70
 
71
71
  expectTypeOf<keyof DocsSchema["docs"]>().toEqualTypeOf<"$path">();
72
72
  expectTypeOf<ExtractEndpointType<DocsSchema["docs"]["$path"]["raw"]["$get"]>>().toEqualTypeOf<"/docs/:path/raw">();
@@ -75,7 +75,7 @@ describe("HonoAppToHyperFetch [ Regex params ]", () => {
75
75
 
76
76
  it("should split an optional regex param into two routes", () => {
77
77
  const app = new Hono().get("/pages/:page{[0-9]+}?", (c) => c.json({ page: c.req.param("page") ?? "1" }));
78
- type PagesSchema = HonoAppToHyperFetch<typeof app>;
78
+ type PagesSchema = HonoSchema<typeof app>;
79
79
 
80
80
  expectTypeOf<keyof PagesSchema["pages"]>().toEqualTypeOf<"$get" | "$page">();
81
81
  expectTypeOf<ExtractEndpointType<PagesSchema["pages"]["$page"]["$get"]>>().toEqualTypeOf<"/pages/:page">();
@@ -83,7 +83,7 @@ describe("HonoAppToHyperFetch [ Regex params ]", () => {
83
83
  });
84
84
  });
85
85
 
86
- describe("HonoAppToHyperFetch [ Methods ]", () => {
86
+ describe("HonoSchema [ Methods ]", () => {
87
87
  it("should expand an .all() route into every standard method", () => {
88
88
  expectTypeOf<keyof Schema["echo"]>().toEqualTypeOf<
89
89
  "$get" | "$post" | "$put" | "$delete" | "$options" | "$patch" | "$query"
@@ -105,7 +105,7 @@ describe("HonoAppToHyperFetch [ Methods ]", () => {
105
105
  const app = new Hono()
106
106
  .all("/hook", (c) => c.json({ any: true as const }))
107
107
  .get("/hook", (c) => c.json({ read: true as const }));
108
- type HookSchema = HonoAppToHyperFetch<typeof app>;
108
+ type HookSchema = HonoSchema<typeof app>;
109
109
 
110
110
  expectTypeOf<ExtractResponseType<HookSchema["hook"]["$get"]>>().toEqualTypeOf<{ read: true }>();
111
111
  expectTypeOf<ExtractResponseType<HookSchema["hook"]["$post"]>>().toEqualTypeOf<{ any: true }>();
@@ -127,7 +127,7 @@ describe("HonoAppToHyperFetch [ Methods ]", () => {
127
127
 
128
128
  it("should keep a custom method of app.on()", () => {
129
129
  const app = new Hono().on("PURGE", "/cache", (c) => c.json({ purged: true as const }));
130
- type CacheSchema = HonoAppToHyperFetch<typeof app>;
130
+ type CacheSchema = HonoSchema<typeof app>;
131
131
 
132
132
  expectTypeOf<keyof CacheSchema["cache"]>().toEqualTypeOf<"$purge">();
133
133
  expect(true).toBe(true);
@@ -140,7 +140,7 @@ describe("HonoAppToHyperFetch [ Methods ]", () => {
140
140
  });
141
141
  });
142
142
 
143
- describe("HonoAppToHyperFetch [ Path shapes ]", () => {
143
+ describe("HonoSchema [ Path shapes ]", () => {
144
144
  it("should give a path registered without a leading slash the endpoint createSdk sends", () => {
145
145
  expectTypeOf<ExtractEndpointType<Schema["plain"]["$get"]>>().toEqualTypeOf<"/plain">();
146
146
  expect(true).toBe(true);
@@ -188,7 +188,7 @@ describe("HonoAppToHyperFetch [ Path shapes ]", () => {
188
188
  new Hono().get("", (c) => c.json({ name: "hono" })),
189
189
  ),
190
190
  );
191
- type MeSchema = HonoAppToHyperFetch<typeof app>;
191
+ type MeSchema = HonoSchema<typeof app>;
192
192
 
193
193
  expectTypeOf<ExtractEndpointType<MeSchema["api"]["v1"]["me"]["$get"]>>().toEqualTypeOf<"/api/v1/me">();
194
194
  expect(true).toBe(true);
@@ -196,7 +196,7 @@ describe("HonoAppToHyperFetch [ Path shapes ]", () => {
196
196
 
197
197
  it("should prefix routes added after basePath()", () => {
198
198
  const app = new Hono().basePath("/api").get("/search", (c) => c.json({ ok: true as const }));
199
- type SearchSchema = HonoAppToHyperFetch<typeof app>;
199
+ type SearchSchema = HonoSchema<typeof app>;
200
200
 
201
201
  expectTypeOf<ExtractEndpointType<SearchSchema["api"]["search"]["$get"]>>().toEqualTypeOf<"/api/search">();
202
202
  expect(true).toBe(true);
@@ -205,7 +205,7 @@ describe("HonoAppToHyperFetch [ Path shapes ]", () => {
205
205
  it("should prefix a router mounted after basePath()", () => {
206
206
  const book = new Hono().get("/", (c) => c.json({ ok: true as const }));
207
207
  const app = new Hono().basePath("/v1").route("/book", book);
208
- type BookSchema = HonoAppToHyperFetch<typeof app>;
208
+ type BookSchema = HonoSchema<typeof app>;
209
209
 
210
210
  expectTypeOf<ExtractEndpointType<BookSchema["v1"]["book"]["$get"]>>().toEqualTypeOf<"/v1/book">();
211
211
  expect(true).toBe(true);
@@ -215,7 +215,7 @@ describe("HonoAppToHyperFetch [ Path shapes ]", () => {
215
215
  type Env = { Bindings: { TOKEN: string }; Variables: { userId: string } };
216
216
  const api = new Hono<Env>().get("/me", (c) => c.json({ userId: c.get("userId") }));
217
217
  const app = new Hono<Env>().route("/api", api);
218
- type EnvSchema = HonoAppToHyperFetch<typeof app>;
218
+ type EnvSchema = HonoSchema<typeof app>;
219
219
 
220
220
  expectTypeOf<ExtractResponseType<EnvSchema["api"]["me"]["$get"]>>().toEqualTypeOf<{ userId: string }>();
221
221
  expect(true).toBe(true);
@@ -7,7 +7,7 @@ import { createSocketSdk, Socket } from "@hyper-fetch/sockets";
7
7
  import { cleanup, renderHook, waitFor } from "@testing-library/react";
8
8
  import { StrictMode, useEffect } from "react";
9
9
 
10
- import type { HonoWebSocketPath } from "../../../src";
10
+ import type { HonoSocketPath } from "../../../src";
11
11
  import type { ChatMessage, RealtimeApp, RealtimeServer } from "../../utils/realtime-server";
12
12
  import { createRealtimeServer } from "../../utils/realtime-server";
13
13
 
@@ -51,7 +51,7 @@ describe("Hono realtime [ React ]", () => {
51
51
  let server: RealtimeServer;
52
52
  let sockets: Socket[] = [];
53
53
 
54
- const createApi = (path: HonoWebSocketPath<RealtimeApp> = "/ws") => {
54
+ const createApi = (path: HonoSocketPath<RealtimeApp> = "/ws") => {
55
55
  const socket = new Socket({ url: `${server.wsUrl}${path}`, reconnectTime: 10 });
56
56
  sockets.push(socket);
57
57
  return { socket, sdk: createSocketSdk<typeof socket, ChatSchema>(socket) };
@@ -3,7 +3,7 @@ import type { ListenerModel, SSEAdapterOptionsType, SocketInstance } from "@hype
3
3
  import { createSocketSdk, ServerSentEventsAdapter, Socket } from "@hyper-fetch/sockets";
4
4
  import { EventSource } from "eventsource";
5
5
 
6
- import type { HonoAppToHyperFetch } from "../../../src";
6
+ import type { HonoSchema } from "../../../src";
7
7
  import type { FeedEvent, Price, RealtimeApp, RealtimeServer } from "../../utils/realtime-server";
8
8
  import { createRealtimeServer } from "../../utils/realtime-server";
9
9
 
@@ -305,7 +305,7 @@ describe("Hono realtime [ Server-Sent Events ]", () => {
305
305
  describe("when using the SDKs", () => {
306
306
  it("should take the stream path from the HTTP schema", async () => {
307
307
  const client = createClient({ url: server.httpUrl });
308
- const sdk = createSdk<typeof client, HonoAppToHyperFetch<RealtimeApp>>(client);
308
+ const sdk = createSdk<typeof client, HonoSchema<RealtimeApp>>(client);
309
309
  const socket = createSocket({}, `${client.url}${sdk.events.$get.endpoint}`);
310
310
 
311
311
  await waitForStream(socket);
@@ -5,12 +5,12 @@ import { Hono } from "hono";
5
5
  import { defineWebSocketHelper } from "hono/ws";
6
6
  import { expectTypeOf } from "vitest";
7
7
 
8
- import type { HonoAppToHyperFetch, HonoWebSocketPath } from "../../../src";
8
+ import type { HonoSchema, HonoSocketPath } from "../../../src";
9
9
  import type { ChatMessage, RealtimeApp } from "../../utils/realtime-server";
10
10
 
11
- describe("HonoWebSocketPath [ Types ]", () => {
11
+ describe("HonoSocketPath [ Types ]", () => {
12
12
  it("should list the WebSocket routes of the app", () => {
13
- expectTypeOf<HonoWebSocketPath<RealtimeApp>>().toEqualTypeOf<
13
+ expectTypeOf<HonoSocketPath<RealtimeApp>>().toEqualTypeOf<
14
14
  "/ws" | `/chat/${string}` | "/notifications" | "/legacy"
15
15
  >();
16
16
  expect(true).toBe(true);
@@ -18,19 +18,19 @@ describe("HonoWebSocketPath [ Types ]", () => {
18
18
 
19
19
  it("should accept a path with the params filled in", () => {
20
20
  const roomId = "42";
21
- const path: HonoWebSocketPath<RealtimeApp> = `/chat/${roomId}`;
21
+ const path: HonoSocketPath<RealtimeApp> = `/chat/${roomId}`;
22
22
 
23
- expectTypeOf(path).toExtend<HonoWebSocketPath<RealtimeApp>>();
23
+ expectTypeOf(path).toExtend<HonoSocketPath<RealtimeApp>>();
24
24
  expect(path).toBe("/chat/42");
25
25
  });
26
26
 
27
27
  it("should reject HTTP routes and paths the app does not define", () => {
28
28
  // @ts-expect-error - /health is an HTTP route
29
- const http: HonoWebSocketPath<RealtimeApp> = "/health";
29
+ const http: HonoSocketPath<RealtimeApp> = "/health";
30
30
  // @ts-expect-error - /events is a Server-Sent Events route, not a WebSocket
31
- const sse: HonoWebSocketPath<RealtimeApp> = "/events";
31
+ const sse: HonoSocketPath<RealtimeApp> = "/events";
32
32
  // @ts-expect-error - the app has no /rooms route
33
- const typo: HonoWebSocketPath<RealtimeApp> = "/rooms/1";
33
+ const typo: HonoSocketPath<RealtimeApp> = "/rooms/1";
34
34
 
35
35
  expect([http, sse, typo]).toHaveLength(3);
36
36
  });
@@ -43,7 +43,7 @@ describe("HonoWebSocketPath [ Types ]", () => {
43
43
  );
44
44
  const api = new Hono().basePath("/api").route("/live", live);
45
45
 
46
- expectTypeOf<HonoWebSocketPath<typeof api>>().toEqualTypeOf<`/api/live/rooms/${string}/${string}`>();
46
+ expectTypeOf<HonoSocketPath<typeof api>>().toEqualTypeOf<`/api/live/rooms/${string}/${string}`>();
47
47
  expect(true).toBe(true);
48
48
  });
49
49
 
@@ -55,7 +55,7 @@ describe("HonoWebSocketPath [ Types ]", () => {
55
55
  upgradeWebSocket(() => ({})),
56
56
  );
57
57
 
58
- expectTypeOf<HonoWebSocketPath<typeof live>>().toEqualTypeOf<"/live">();
58
+ expectTypeOf<HonoSocketPath<typeof live>>().toEqualTypeOf<"/live">();
59
59
  expect(true).toBe(true);
60
60
  });
61
61
 
@@ -71,7 +71,7 @@ describe("HonoWebSocketPath [ Types ]", () => {
71
71
  upgradeWebSocket(() => ({})),
72
72
  );
73
73
 
74
- expectTypeOf<HonoWebSocketPath<typeof live>>().toEqualTypeOf<
74
+ expectTypeOf<HonoSocketPath<typeof live>>().toEqualTypeOf<
75
75
  "/feeds" | `/feeds/${string}` | `/posts/${string}/live`
76
76
  >();
77
77
  expect(true).toBe(true);
@@ -86,7 +86,7 @@ describe("HonoWebSocketPath [ Types ]", () => {
86
86
  )
87
87
  .post("/chat", (c) => c.json({ sent: true }));
88
88
 
89
- type Schema = HonoAppToHyperFetch<typeof app>;
89
+ type Schema = HonoSchema<typeof app>;
90
90
  expectTypeOf<keyof Schema["chat"]>().toEqualTypeOf<"$post">();
91
91
  expect(true).toBe(true);
92
92
  });
@@ -94,8 +94,8 @@ describe("HonoWebSocketPath [ Types ]", () => {
94
94
  it("should resolve to never for an app without WebSocket routes and for anything that is not an app", () => {
95
95
  const http = new Hono().get("/users", (c) => c.json([]));
96
96
 
97
- expectTypeOf<HonoWebSocketPath<typeof http>>().toBeNever();
98
- expectTypeOf<HonoWebSocketPath<{ routes: [] }>>().toBeNever();
97
+ expectTypeOf<HonoSocketPath<typeof http>>().toBeNever();
98
+ expectTypeOf<HonoSocketPath<{ routes: [] }>>().toBeNever();
99
99
  expect(true).toBe(true);
100
100
  });
101
101
  });
@@ -1,7 +1,7 @@
1
1
  import type { EmitterModel, ListenerModel, SocketInstance, WebsocketAdapterOptionsType } from "@hyper-fetch/sockets";
2
2
  import { createSocketSdk, Socket } from "@hyper-fetch/sockets";
3
3
 
4
- import type { HonoWebSocketPath } from "../../../src";
4
+ import type { HonoSocketPath } from "../../../src";
5
5
  import type { ChatMessage, Notification, Price, RealtimeApp, RealtimeServer } from "../../utils/realtime-server";
6
6
  import { createRealtimeServer } from "../../utils/realtime-server";
7
7
 
@@ -10,7 +10,7 @@ describe("Hono realtime [ WebSocket ]", () => {
10
10
  let sockets: SocketInstance[] = [];
11
11
 
12
12
  const createSocket = (
13
- path: HonoWebSocketPath<RealtimeApp>,
13
+ path: HonoSocketPath<RealtimeApp>,
14
14
  options?: { queryParams?: Record<string, string>; adapterOptions?: WebsocketAdapterOptionsType },
15
15
  ) => {
16
16
  // A short reconnect delay keeps the reconnect tests fast, `connectionTimeout` keeps slow handshakes alive
@@ -199,7 +199,7 @@ describe("Hono realtime [ WebSocket ]", () => {
199
199
  });
200
200
 
201
201
  it("should open one connection per room on a route with path params", async () => {
202
- const roomPath = (roomId: string): HonoWebSocketPath<RealtimeApp> => `/chat/${roomId}`;
202
+ const roomPath = (roomId: string): HonoSocketPath<RealtimeApp> => `/chat/${roomId}`;
203
203
  const socket = createSocket(roomPath("1"));
204
204
  const onMessage = vi.fn();
205
205
  socket.createListener<ChatMessage>()({ topic: "message" }).listen(onMessage);
@@ -1,13 +1,13 @@
1
1
  import type { ServerType } from "@hono/node-server";
2
2
  import { createClient, createSdk } from "@hyper-fetch/core";
3
3
 
4
- import type { HonoAppToHyperFetch } from "../../../src";
4
+ import type { HonoSchema } from "../../../src";
5
5
  import { responsesApp } from "../../utils/responses.app";
6
6
  import { startServer, stopServer } from "../../utils/server";
7
7
 
8
- type Schema = HonoAppToHyperFetch<typeof responsesApp>;
8
+ type Schema = HonoSchema<typeof responsesApp>;
9
9
 
10
- describe("HonoAppToHyperFetch [ Responses against a Hono server ]", () => {
10
+ describe("HonoSchema [ Responses against a Hono server ]", () => {
11
11
  let server: ServerType;
12
12
  let url: string;
13
13
 
@@ -3,12 +3,12 @@ import { Hono } from "hono";
3
3
  import type { ApplyGlobalResponse, PickResponseByStatusCode } from "hono/client";
4
4
  import { expectTypeOf } from "vitest";
5
5
 
6
- import type { HonoAppToHyperFetch } from "../../../src";
6
+ import type { HonoSchema } from "../../../src";
7
7
  import type { Result, responsesApp } from "../../utils/responses.app";
8
8
 
9
- type Schema = HonoAppToHyperFetch<typeof responsesApp>;
9
+ type Schema = HonoSchema<typeof responsesApp>;
10
10
 
11
- describe("HonoAppToHyperFetch [ JSON responses ]", () => {
11
+ describe("HonoSchema [ JSON responses ]", () => {
12
12
  it("should keep the literal type of JSON primitives", () => {
13
13
  expectTypeOf<ExtractResponseType<Schema["json"]["string"]["$get"]>>().toEqualTypeOf<"a-string">();
14
14
  expectTypeOf<ExtractResponseType<Schema["json"]["number"]["$get"]>>().toEqualTypeOf<37>();
@@ -41,14 +41,14 @@ describe("HonoAppToHyperFetch [ JSON responses ]", () => {
41
41
 
42
42
  it("should type a body JSON cannot serialize as never", () => {
43
43
  const app = new Hono().get("/bigint", (c) => c.json({ value: 42n }));
44
- type BigIntSchema = HonoAppToHyperFetch<typeof app>;
44
+ type BigIntSchema = HonoSchema<typeof app>;
45
45
 
46
46
  expectTypeOf<ExtractResponseType<BigIntSchema["bigint"]["$get"]>>().toBeNever();
47
47
  expect(true).toBe(true);
48
48
  });
49
49
  });
50
50
 
51
- describe("HonoAppToHyperFetch [ Statuses ]", () => {
51
+ describe("HonoSchema [ Statuses ]", () => {
52
52
  it("should union the bodies of every status", () => {
53
53
  expectTypeOf<ExtractResponseType<Schema["statuses"]["$get"]>>().toEqualTypeOf<
54
54
  { data: string } | { message: string }
@@ -64,14 +64,14 @@ describe("HonoAppToHyperFetch [ Statuses ]", () => {
64
64
  });
65
65
 
66
66
  it("should keep only the statuses PickResponseByStatusCode picks", () => {
67
- type SuccessSchema = HonoAppToHyperFetch<PickResponseByStatusCode<typeof responsesApp, 200>>;
67
+ type SuccessSchema = HonoSchema<PickResponseByStatusCode<typeof responsesApp, 200>>;
68
68
 
69
69
  expectTypeOf<ExtractResponseType<SuccessSchema["statuses"]["$get"]>>().toEqualTypeOf<{ data: string }>();
70
70
  expect(true).toBe(true);
71
71
  });
72
72
 
73
73
  it("should add the responses ApplyGlobalResponse declares", () => {
74
- type GlobalSchema = HonoAppToHyperFetch<
74
+ type GlobalSchema = HonoSchema<
75
75
  ApplyGlobalResponse<typeof responsesApp, { 500: { json: { error: string } } }>
76
76
  >;
77
77
 
@@ -80,7 +80,7 @@ describe("HonoAppToHyperFetch [ Statuses ]", () => {
80
80
  });
81
81
  });
82
82
 
83
- describe("HonoAppToHyperFetch [ Other response helpers ]", () => {
83
+ describe("HonoSchema [ Other response helpers ]", () => {
84
84
  it("should type c.text() with the literal text", () => {
85
85
  expectTypeOf<ExtractResponseType<Schema["text"]["$get"]>>().toEqualTypeOf<"Hello, Hono!">();
86
86
  expectTypeOf<ExtractResponseType<Schema["text"]["numeric"]["$get"]>>().toEqualTypeOf<"42">();
@@ -3,10 +3,10 @@ import type { ServerType } from "@hono/node-server";
3
3
  import { createClient, createSdk } from "@hyper-fetch/core";
4
4
  import type { AddressInfo } from "node:net";
5
5
 
6
- import type { HonoAppToHyperFetch } from "../../../src";
6
+ import type { HonoSchema } from "../../../src";
7
7
  import { app } from "../../utils/app";
8
8
 
9
- type Schema = HonoAppToHyperFetch<typeof app>;
9
+ type Schema = HonoSchema<typeof app>;
10
10
 
11
11
  const startServer = () =>
12
12
  new Promise<ServerType>((resolve) => {
@@ -18,7 +18,7 @@ const stopServer = (server: ServerType) =>
18
18
  server.close((error) => (error ? reject(error) : resolve()));
19
19
  });
20
20
 
21
- describe("HonoAppToHyperFetch [ Requests against a Hono server ]", () => {
21
+ describe("HonoSchema [ Requests against a Hono server ]", () => {
22
22
  let server: ServerType;
23
23
  let url: string;
24
24
 
@@ -15,13 +15,13 @@ import type {
15
15
  import { Hono } from "hono";
16
16
  import { expectTypeOf } from "vitest";
17
17
 
18
- import type { HonoAppToHyperFetch } from "../../../src";
18
+ import type { HonoSchema } from "../../../src";
19
19
  import type { User, apiApp, app } from "../../utils/app";
20
20
  import type { RealtimeApp } from "../../utils/realtime-server";
21
21
 
22
- type Schema = HonoAppToHyperFetch<typeof app>;
22
+ type Schema = HonoSchema<typeof app>;
23
23
 
24
- describe("HonoAppToHyperFetch [ Schema shape ]", () => {
24
+ describe("HonoSchema [ Schema shape ]", () => {
25
25
  it("should nest mounted routes under their path segments", () => {
26
26
  expectTypeOf<keyof Schema>().toEqualTypeOf<"$get" | "users" | "auth">();
27
27
  expectTypeOf<keyof Schema["users"]>().toEqualTypeOf<"$get" | "$post" | "$userId">();
@@ -50,7 +50,7 @@ describe("HonoAppToHyperFetch [ Schema shape ]", () => {
50
50
  });
51
51
 
52
52
  it("should prefix endpoints with the app basePath", () => {
53
- type ApiSchema = HonoAppToHyperFetch<typeof apiApp>;
53
+ type ApiSchema = HonoSchema<typeof apiApp>;
54
54
 
55
55
  expectTypeOf<keyof ApiSchema>().toEqualTypeOf<"api">();
56
56
  expectTypeOf<ExtractEndpointType<ApiSchema["api"]["users"]["$get"]>>().toEqualTypeOf<"/api/users">();
@@ -59,15 +59,15 @@ describe("HonoAppToHyperFetch [ Schema shape ]", () => {
59
59
 
60
60
  it("should lowercase the method keys", () => {
61
61
  const methods = new Hono().on("PATCH", "/users", (c) => c.json({ patched: true }));
62
- type MethodsSchema = HonoAppToHyperFetch<typeof methods>;
62
+ type MethodsSchema = HonoSchema<typeof methods>;
63
63
 
64
64
  expectTypeOf<keyof MethodsSchema["users"]>().toEqualTypeOf<"$patch">();
65
65
  expect(true).toBe(true);
66
66
  });
67
67
 
68
68
  it("should resolve to an empty schema for anything that is not a Hono app", () => {
69
- expectTypeOf<HonoAppToHyperFetch<{ routes: [] }>>().toEqualTypeOf<{}>();
70
- expectTypeOf<HonoAppToHyperFetch<new () => Hono>>().toEqualTypeOf<{}>();
69
+ expectTypeOf<HonoSchema<{ routes: [] }>>().toEqualTypeOf<{}>();
70
+ expectTypeOf<HonoSchema<new () => Hono>>().toEqualTypeOf<{}>();
71
71
  expect(true).toBe(true);
72
72
  });
73
73
 
@@ -83,7 +83,7 @@ describe("HonoAppToHyperFetch [ Schema shape ]", () => {
83
83
  });
84
84
  });
85
85
 
86
- describe("HonoAppToHyperFetch [ Request types ]", () => {
86
+ describe("HonoSchema [ Request types ]", () => {
87
87
  it("should take the response from the handler output", () => {
88
88
  expectTypeOf<ExtractResponseType<Schema["users"]["$get"]>>().toEqualTypeOf<User[]>();
89
89
  expectTypeOf<ExtractResponseType<Schema["auth"]["session"]["$delete"]>>().toEqualTypeOf<{ loggedOut: true }>();
@@ -116,7 +116,7 @@ describe("HonoAppToHyperFetch [ Request types ]", () => {
116
116
 
117
117
  it("should default the client to ClientInstance and accept a custom one", () => {
118
118
  type AppClient = Client<{ code: string }, HttpAdapterType>;
119
- type TypedSchema = HonoAppToHyperFetch<typeof app, AppClient>;
119
+ type TypedSchema = HonoSchema<typeof app, AppClient>;
120
120
 
121
121
  expectTypeOf<ExtractClientType<Schema["users"]["$get"]>>().toEqualTypeOf<ClientInstance>();
122
122
  expectTypeOf<ExtractClientType<TypedSchema["users"]["$get"]>>().toEqualTypeOf<AppClient>();
@@ -124,7 +124,7 @@ describe("HonoAppToHyperFetch [ Request types ]", () => {
124
124
  });
125
125
  });
126
126
 
127
- describe("HonoAppToHyperFetch [ createSdk ]", () => {
127
+ describe("HonoSchema [ createSdk ]", () => {
128
128
  const client = createClient({ url: "http://localhost" });
129
129
  const sdk = createSdk<typeof client, Schema>(client);
130
130
 
@@ -164,8 +164,8 @@ describe("HonoAppToHyperFetch [ createSdk ]", () => {
164
164
  });
165
165
  });
166
166
 
167
- describe("HonoAppToHyperFetch [ Realtime routes ]", () => {
168
- type RealtimeSchema = HonoAppToHyperFetch<RealtimeApp>;
167
+ describe("HonoSchema [ Realtime routes ]", () => {
168
+ type RealtimeSchema = HonoSchema<RealtimeApp>;
169
169
 
170
170
  it("should leave WebSocket routes out of the schema", () => {
171
171
  // /ws, /chat/:roomId, /notifications and /legacy are upgradeWebSocket() routes
@@ -181,7 +181,7 @@ describe("HonoAppToHyperFetch [ Realtime routes ]", () => {
181
181
  upgradeWebSocket(() => ({})),
182
182
  )
183
183
  .post("/live", (c) => c.json({ posted: true }));
184
- type MixedSchema = HonoAppToHyperFetch<typeof mixed>;
184
+ type MixedSchema = HonoSchema<typeof mixed>;
185
185
 
186
186
  expectTypeOf<keyof MixedSchema>().toEqualTypeOf<"live">();
187
187
  expectTypeOf<keyof MixedSchema["live"]>().toEqualTypeOf<"$post">();
@@ -105,7 +105,7 @@ type ConvertSchema<Schema extends Record<string, any>, Client extends ClientInst
105
105
  * `app.route()` and `basePath()`. Anything that is not a Hono app resolves to `{}`.
106
106
  *
107
107
  * Routes handled by `upgradeWebSocket()` are not requests, so they are left out - connect to them with a
108
- * `Socket` and check the address with {@link HonoWebSocketPath}. Server-Sent Events routes (`streamSSE()`)
108
+ * `Socket` and check the address with {@link HonoSocketPath}. Server-Sent Events routes (`streamSSE()`)
109
109
  * stay in the schema as a `$get` with an untyped response: Hono types them like any other raw `Response`.
110
110
  *
111
111
  * @typeParam App - The Hono app type, usually `typeof app`.
@@ -116,14 +116,14 @@ type ConvertSchema<Schema extends Record<string, any>, Client extends ClientInst
116
116
  * ```ts
117
117
  * // backend
118
118
  * const app = new Hono().get("/users/:userId", (c) => c.json({ id: c.req.param("userId") }));
119
- * export type AppSchema = HonoAppToHyperFetch<typeof app>;
119
+ * export type AppSchema = HonoSchema<typeof app>;
120
120
  *
121
121
  * // frontend
122
122
  * const sdk = createSdk<typeof client, AppSchema>(client);
123
123
  * const { data } = await sdk.users.$userId.$get.send({ params: { userId: "1" } });
124
124
  * ```
125
125
  */
126
- export type HonoAppToHyperFetch<App, Client extends ClientInstance = ClientInstance> = App extends HonoBase<any, infer S, any, any> ? Prettify<ConvertSchema<MergeUnionToRecord<S>, Client>> : {};
126
+ export type HonoSchema<App, Client extends ClientInstance = ClientInstance> = App extends HonoBase<any, infer S, any, any> ? Prettify<ConvertSchema<MergeUnionToRecord<S>, Client>> : {};
127
127
  type ExtractAppSchema<App> = App extends HonoBase<any, infer S, any, any> ? MergeUnionToRecord<S> : never;
128
128
  /** `path -> endpoint` of the routes that upgrade a GET to a WebSocket - the routes `hc` exposes as `$ws`. */
129
129
  type ExtractWebSocketEndpoints<Schema> = {
@@ -158,12 +158,21 @@ type ToPathPattern<Path extends string> = ExpandPath<Path> extends infer Routes
158
158
  * export type AppType = typeof app;
159
159
  *
160
160
  * // frontend
161
- * const path: HonoWebSocketPath<AppType> = `/chat/${roomId}`;
161
+ * const path: HonoSocketPath<AppType> = `/chat/${roomId}`;
162
162
  * const socket = new Socket({ url: `wss://api.example.com${path}` });
163
163
  * ```
164
164
  */
165
- export type HonoWebSocketPath<App> = {
165
+ export type HonoSocketPath<App> = {
166
166
  [Path in keyof WebSocketEndpoints<App> & string]: ToPathPattern<Path>;
167
167
  }[keyof WebSocketEndpoints<App> & string];
168
+ /**
169
+ * @deprecated Renamed to {@link HonoSchema}, to match `TrpcSchema` and `OrpcSchema`. This alias will be removed in
170
+ * the next major version.
171
+ */
172
+ export type HonoAppToHyperFetch<App, Client extends ClientInstance = ClientInstance> = HonoSchema<App, Client>;
173
+ /**
174
+ * @deprecated Renamed to {@link HonoSocketPath}. This alias will be removed in the next major version.
175
+ */
176
+ export type HonoWebSocketPath<App> = HonoSocketPath<App>;
168
177
  export {};
169
178
  //# sourceMappingURL=hono.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hono.types.d.ts","sourceRoot":"","sources":["../src/hono.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,QAAQ,CAAC,CAAC,IAAI;KAChB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAC;AAEP,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,GAAG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AAM,EAAE,GAClD,MAAM,SAAS,MAAM,EAAE,GACrB,cAAc,CAAC,MAAM,CAAC,GACtB,KAAK,GACP,KAAK,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,cAAc,CAAC,GAAG,IAAI;KAC/B,IAAI,IAAI,MAAM,kBAAkB,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;CACtE,CAAC,MAAM,kBAAkB,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;AAM1C;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,GAAG,EAAE,MAAM,SAAS,cAAc,GAAG,cAAc,IAAI,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type { HonoAppToHyperFetch, HonoWebSocketPath } from './hono.types';
1
+ export type { HonoSchema, HonoSocketPath, HonoAppToHyperFetch, HonoWebSocketPath, } from './hono.types';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@hyper-fetch/hono",
3
- "version": "10.0.0",
4
- "description": "Turn a Hono app type into a fully typed Hyper Fetch SDK schema",
3
+ "version": "10.1.1",
4
+ "description": "Turn a Hono app type into a fully typed HyperFetch SDK schema, a typed Hono client with caching and React hooks",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
- "homepage": "https://hyperfetch.bettertyped.com/",
6
+ "homepage": "https://hyperfetch.bettertyped.com/docs/integrations/hono/overview/",
7
7
  "license": "Apache-2.0",
8
8
  "main": "dist/index.mjs",
9
9
  "module": "dist/index.mjs",
@@ -54,10 +54,12 @@
54
54
  },
55
55
  "keywords": [
56
56
  "hono",
57
+ "hono-client",
57
58
  "sdk",
58
59
  "rpc",
59
60
  "type-safe",
60
- "hyper fetch"
61
+ "typescript",
62
+ "hyperfetch"
61
63
  ],
62
64
  "devDependencies": {
63
65
  "@hono/node-server": "^2.1.9",
package/src/hono.types.ts CHANGED
@@ -171,7 +171,7 @@ type ConvertSchema<Schema extends Record<string, any>, Client extends ClientInst
171
171
  * `app.route()` and `basePath()`. Anything that is not a Hono app resolves to `{}`.
172
172
  *
173
173
  * Routes handled by `upgradeWebSocket()` are not requests, so they are left out - connect to them with a
174
- * `Socket` and check the address with {@link HonoWebSocketPath}. Server-Sent Events routes (`streamSSE()`)
174
+ * `Socket` and check the address with {@link HonoSocketPath}. Server-Sent Events routes (`streamSSE()`)
175
175
  * stay in the schema as a `$get` with an untyped response: Hono types them like any other raw `Response`.
176
176
  *
177
177
  * @typeParam App - The Hono app type, usually `typeof app`.
@@ -182,14 +182,14 @@ type ConvertSchema<Schema extends Record<string, any>, Client extends ClientInst
182
182
  * ```ts
183
183
  * // backend
184
184
  * const app = new Hono().get("/users/:userId", (c) => c.json({ id: c.req.param("userId") }));
185
- * export type AppSchema = HonoAppToHyperFetch<typeof app>;
185
+ * export type AppSchema = HonoSchema<typeof app>;
186
186
  *
187
187
  * // frontend
188
188
  * const sdk = createSdk<typeof client, AppSchema>(client);
189
189
  * const { data } = await sdk.users.$userId.$get.send({ params: { userId: "1" } });
190
190
  * ```
191
191
  */
192
- export type HonoAppToHyperFetch<App, Client extends ClientInstance = ClientInstance> =
192
+ export type HonoSchema<App, Client extends ClientInstance = ClientInstance> =
193
193
  // Match `HonoBase` with all four generics: `.route()` returns `HonoBase<E, S, BasePath, CurrentPath>`,
194
194
  // so matching against `Hono<E, S, BasePath>` fails to infer the schema and resolves to `{}`.
195
195
  App extends HonoBase<any, infer S, any, any> ? Prettify<ConvertSchema<MergeUnionToRecord<S>, Client>> : {};
@@ -243,10 +243,25 @@ type ToPathPattern<Path extends string> =
243
243
  * export type AppType = typeof app;
244
244
  *
245
245
  * // frontend
246
- * const path: HonoWebSocketPath<AppType> = `/chat/${roomId}`;
246
+ * const path: HonoSocketPath<AppType> = `/chat/${roomId}`;
247
247
  * const socket = new Socket({ url: `wss://api.example.com${path}` });
248
248
  * ```
249
249
  */
250
- export type HonoWebSocketPath<App> = {
250
+ export type HonoSocketPath<App> = {
251
251
  [Path in keyof WebSocketEndpoints<App> & string]: ToPathPattern<Path>;
252
252
  }[keyof WebSocketEndpoints<App> & string];
253
+
254
+ /* -------------------------------------------------------------------------------------------------
255
+ * Deprecated names
256
+ * -----------------------------------------------------------------------------------------------*/
257
+
258
+ /**
259
+ * @deprecated Renamed to {@link HonoSchema}, to match `TrpcSchema` and `OrpcSchema`. This alias will be removed in
260
+ * the next major version.
261
+ */
262
+ export type HonoAppToHyperFetch<App, Client extends ClientInstance = ClientInstance> = HonoSchema<App, Client>;
263
+
264
+ /**
265
+ * @deprecated Renamed to {@link HonoSocketPath}. This alias will be removed in the next major version.
266
+ */
267
+ export type HonoWebSocketPath<App> = HonoSocketPath<App>;
package/src/index.ts CHANGED
@@ -1 +1,6 @@
1
- export type { HonoAppToHyperFetch, HonoWebSocketPath } from "./hono.types";
1
+ export type {
2
+ HonoSchema,
3
+ HonoSocketPath,
4
+ HonoAppToHyperFetch,
5
+ HonoWebSocketPath,
6
+ } from "./hono.types";