@hyper-fetch/hono 10.1.0 → 10.2.0
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 +10 -9
- package/__tests__/features/deprecated/deprecated.types.spec.ts +26 -0
- package/__tests__/features/inputs/inputs.sdk.spec.ts +3 -3
- package/__tests__/features/inputs/inputs.types.spec.ts +4 -4
- package/__tests__/features/paths/paths.sdk.spec.ts +3 -3
- package/__tests__/features/paths/paths.types.spec.ts +15 -15
- package/__tests__/features/realtime/realtime.react.spec.tsx +2 -2
- package/__tests__/features/realtime/realtime.sse.spec.ts +2 -2
- package/__tests__/features/realtime/realtime.types.spec.ts +14 -14
- package/__tests__/features/realtime/realtime.websocket.spec.ts +3 -3
- package/__tests__/features/responses/responses.sdk.spec.ts +3 -3
- package/__tests__/features/responses/responses.types.spec.ts +8 -8
- package/__tests__/features/schema/schema.sdk.spec.ts +3 -3
- package/__tests__/features/schema/schema.types.spec.ts +13 -13
- package/dist/hono.types.d.ts +14 -5
- package/dist/hono.types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/hono.types.ts +20 -5
- package/src/index.ts +6 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview"><b>Quick Start</b></a> ·
|
|
7
7
|
<a href="https://hyperfetch.bettertyped.com/docs/integrations/hono/overview">Documentation</a> ·
|
|
8
|
-
<a href="https://hyperfetch.bettertyped.com/docs/api/hono/Types/
|
|
8
|
+
<a href="https://hyperfetch.bettertyped.com/docs/api/hono/Types/HonoSchema">API Reference</a> ·
|
|
9
9
|
<a href="https://github.com/BetterTyped/hyper-fetch">GitHub</a> ·
|
|
10
10
|
<a href="https://discord.gg/7upC2kVmyM">Discord</a>
|
|
11
11
|
</p>
|
|
@@ -34,7 +34,7 @@ nothing from your server ends up in the client bundle.
|
|
|
34
34
|
- 🛂 **Validators drive the payload** - `json` and `query` validators type `setPayload()` and `setQueryParams()`
|
|
35
35
|
- 🧩 **Mounted routers included** - `app.route()` and `basePath()` prefixes land in the endpoint and the nesting
|
|
36
36
|
- 🧷 **Every path shape** - Optional `:id?` and regex `:id{[0-9]+}` params, `.all()` and `app.on()` get typed accessors
|
|
37
|
-
- 📡 **Realtime routes too** - `
|
|
37
|
+
- 📡 **Realtime routes too** - `HonoSocketPath` rejects socket URLs that match no `upgradeWebSocket()` route
|
|
38
38
|
- 🚫 **No fake requests** - WebSocket routes stay out of the HTTP SDK, so nobody calls `send()` on them
|
|
39
39
|
- 🪶 **Zero runtime** - Type exports only, so it adds no code to your bundle
|
|
40
40
|
- ⚡ **Every HyperFetch feature** - Cache, retries, deduplication, offline replay and React hooks on every route
|
|
@@ -48,11 +48,11 @@ npm install @hyper-fetch/core @hyper-fetch/hono
|
|
|
48
48
|
```ts
|
|
49
49
|
// backend
|
|
50
50
|
import { Hono } from "hono";
|
|
51
|
-
import type {
|
|
51
|
+
import type { HonoSchema } from "@hyper-fetch/hono";
|
|
52
52
|
|
|
53
53
|
const app = new Hono().get("/users/:userId", (c) => c.json({ id: c.req.param("userId"), name: "Ann" }));
|
|
54
54
|
|
|
55
|
-
export type AppSchema =
|
|
55
|
+
export type AppSchema = HonoSchema<typeof app>;
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
```ts
|
|
@@ -72,7 +72,7 @@ const { data } = await sdk.users.$userId.$get.setParams({ userId: "1" }).send();
|
|
|
72
72
|
- **[Hono Integration](https://hyperfetch.bettertyped.com/docs/integrations/hono/overview)** - Setup, routes, validators and path shapes
|
|
73
73
|
- **[Hono Realtime](https://hyperfetch.bettertyped.com/docs/integrations/hono/realtime)** - WebSocket and Server-Sent Events routes
|
|
74
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/
|
|
75
|
+
- **[API Reference](https://hyperfetch.bettertyped.com/docs/api/hono/Types/HonoSchema)** - Every exported type
|
|
76
76
|
|
|
77
77
|
## 💡 Examples
|
|
78
78
|
|
|
@@ -81,7 +81,7 @@ const { data } = await sdk.users.$userId.$get.setParams({ userId: "1" }).send();
|
|
|
81
81
|
```ts
|
|
82
82
|
import { Hono } from "hono";
|
|
83
83
|
import { validator } from "hono/validator";
|
|
84
|
-
import type {
|
|
84
|
+
import type { HonoSchema } from "@hyper-fetch/hono";
|
|
85
85
|
|
|
86
86
|
const users = new Hono()
|
|
87
87
|
.get("/", (c) => c.json([{ id: "1", name: "Ann" }]))
|
|
@@ -95,7 +95,7 @@ const auth = new Hono().get("/google-login", (c) => c.json({ authUrl: "https://a
|
|
|
95
95
|
|
|
96
96
|
const app = new Hono().route("/users", users).route("/auth", auth);
|
|
97
97
|
|
|
98
|
-
export type AppSchema =
|
|
98
|
+
export type AppSchema = HonoSchema<typeof app>;
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
```ts
|
|
@@ -147,9 +147,9 @@ export type ChatSchema = { message: { $listener: ListenerModel<{ response: { tex
|
|
|
147
147
|
```ts
|
|
148
148
|
// frontend
|
|
149
149
|
import { createSocketSdk, Socket } from "@hyper-fetch/sockets";
|
|
150
|
-
import type {
|
|
150
|
+
import type { HonoSocketPath } from "@hyper-fetch/hono";
|
|
151
151
|
|
|
152
|
-
const path:
|
|
152
|
+
const path: HonoSocketPath<AppType> = `/chat/${roomId}`; // "/rooms/1" would not compile
|
|
153
153
|
const socket = new Socket({ url: `wss://api.example.com${path}` });
|
|
154
154
|
const chat = createSocketSdk<typeof socket, ChatSchema>(socket);
|
|
155
155
|
|
|
@@ -192,6 +192,7 @@ One typed client for every backend. Swap the adapter and keep the same `createRe
|
|
|
192
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
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
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/db"><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>DB</b></sub></a></td>
|
|
195
196
|
<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
197
|
<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
198
|
<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>
|
|
@@ -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 {
|
|
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 =
|
|
8
|
+
type Schema = HonoSchema<typeof inputsApp>;
|
|
9
9
|
|
|
10
|
-
describe("
|
|
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 {
|
|
5
|
+
import type { HonoSchema } from "../../../src";
|
|
6
6
|
import type { inputsApp } from "../../utils/inputs.app";
|
|
7
7
|
|
|
8
|
-
type Schema =
|
|
8
|
+
type Schema = HonoSchema<typeof inputsApp>;
|
|
9
9
|
|
|
10
|
-
describe("
|
|
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("
|
|
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 {
|
|
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 =
|
|
8
|
+
type Schema = HonoSchema<typeof pathsApp>;
|
|
9
9
|
|
|
10
|
-
describe("
|
|
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 {
|
|
6
|
+
import type { HonoSchema } from "../../../src";
|
|
7
7
|
import type { pathsApp, rootOptionalApp } from "../../utils/paths.app";
|
|
8
8
|
|
|
9
|
-
type Schema =
|
|
9
|
+
type Schema = HonoSchema<typeof pathsApp>;
|
|
10
10
|
|
|
11
|
-
describe("
|
|
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 =
|
|
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("
|
|
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 =
|
|
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 =
|
|
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("
|
|
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 =
|
|
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 =
|
|
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("
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 {
|
|
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:
|
|
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 {
|
|
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,
|
|
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 {
|
|
8
|
+
import type { HonoSchema, HonoSocketPath } from "../../../src";
|
|
9
9
|
import type { ChatMessage, RealtimeApp } from "../../utils/realtime-server";
|
|
10
10
|
|
|
11
|
-
describe("
|
|
11
|
+
describe("HonoSocketPath [ Types ]", () => {
|
|
12
12
|
it("should list the WebSocket routes of the app", () => {
|
|
13
|
-
expectTypeOf<
|
|
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:
|
|
21
|
+
const path: HonoSocketPath<RealtimeApp> = `/chat/${roomId}`;
|
|
22
22
|
|
|
23
|
-
expectTypeOf(path).toExtend<
|
|
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:
|
|
29
|
+
const http: HonoSocketPath<RealtimeApp> = "/health";
|
|
30
30
|
// @ts-expect-error - /events is a Server-Sent Events route, not a WebSocket
|
|
31
|
-
const sse:
|
|
31
|
+
const sse: HonoSocketPath<RealtimeApp> = "/events";
|
|
32
32
|
// @ts-expect-error - the app has no /rooms route
|
|
33
|
-
const typo:
|
|
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<
|
|
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<
|
|
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<
|
|
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 =
|
|
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<
|
|
98
|
-
expectTypeOf<
|
|
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 {
|
|
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:
|
|
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):
|
|
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 {
|
|
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 =
|
|
8
|
+
type Schema = HonoSchema<typeof responsesApp>;
|
|
9
9
|
|
|
10
|
-
describe("
|
|
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 {
|
|
6
|
+
import type { HonoSchema } from "../../../src";
|
|
7
7
|
import type { Result, responsesApp } from "../../utils/responses.app";
|
|
8
8
|
|
|
9
|
-
type Schema =
|
|
9
|
+
type Schema = HonoSchema<typeof responsesApp>;
|
|
10
10
|
|
|
11
|
-
describe("
|
|
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 =
|
|
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("
|
|
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 =
|
|
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 =
|
|
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("
|
|
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 {
|
|
6
|
+
import type { HonoSchema } from "../../../src";
|
|
7
7
|
import { app } from "../../utils/app";
|
|
8
8
|
|
|
9
|
-
type Schema =
|
|
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("
|
|
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 {
|
|
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 =
|
|
22
|
+
type Schema = HonoSchema<typeof app>;
|
|
23
23
|
|
|
24
|
-
describe("
|
|
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 =
|
|
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 =
|
|
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<
|
|
70
|
-
expectTypeOf<
|
|
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("
|
|
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 =
|
|
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("
|
|
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("
|
|
168
|
-
type RealtimeSchema =
|
|
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 =
|
|
184
|
+
type MixedSchema = HonoSchema<typeof mixed>;
|
|
185
185
|
|
|
186
186
|
expectTypeOf<keyof MixedSchema>().toEqualTypeOf<"live">();
|
|
187
187
|
expectTypeOf<keyof MixedSchema["live"]>().toEqualTypeOf<"$post">();
|
package/dist/hono.types.d.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
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
|
|
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:
|
|
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
|
|
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
|
package/dist/hono.types.d.ts.map
CHANGED
|
@@ -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,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;AAMpH;;;GAGG;AACH,KAAK,SA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G,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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,
|
|
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.
|
|
4
|
-
"description": "Turn a Hono app type into a fully typed
|
|
3
|
+
"version": "10.2.0",
|
|
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
|
-
"
|
|
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
|
|
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 =
|
|
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
|
|
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:
|
|
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
|
|
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>;
|