@ts-kizuna/hono 1.59.0 → 1.60.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/dist/index.cjs +2 -0
- package/dist/index.d.cts +8 -2
- package/dist/index.d.mts +8 -2
- package/dist/index.mjs +3 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -46,6 +46,7 @@ function mountHono(api, app, options) {
|
|
|
46
46
|
const pluginExports = (0, _ts_kizuna_core_adapter.pluginExportsOf)(api);
|
|
47
47
|
const jobsMeta = api[_ts_kizuna_core_adapter.JOBS_META];
|
|
48
48
|
const jobRunner = (0, _ts_kizuna_core_adapter.jobRunnerFrom)(jobsMeta);
|
|
49
|
+
const toolRunner = (0, _ts_kizuna_core_adapter.toolRunnerFrom)(api[_ts_kizuna_core_adapter.TOOLS_META]);
|
|
49
50
|
const mountRoute = (routeKey, route, lane, resolvedRouter) => {
|
|
50
51
|
const method = route.method.toLowerCase();
|
|
51
52
|
const kizunaHandler = async (c) => {
|
|
@@ -77,6 +78,7 @@ function mountHono(api, app, options) {
|
|
|
77
78
|
requestContext,
|
|
78
79
|
pluginExports,
|
|
79
80
|
jobs: jobRunner,
|
|
81
|
+
tools: toolRunner,
|
|
80
82
|
responseValidation: options?.responseValidation
|
|
81
83
|
});
|
|
82
84
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Env, Hono } from "hono";
|
|
2
|
-
import { ApiWithRouter, ContractJobsRouter, ContractRouter, ErrorFormatter, GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, RouteDefinition, RouteHandler as RouteHandler$1, Routes, SCHEMES_META, Server as Server$1, ServerOptions } from "@ts-kizuna/core/adapter";
|
|
2
|
+
import { ApiWithRouter, ContractJobsRouter, ContractRouter, ContractToolsRouter, ErrorFormatter, GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, RouteDefinition, RouteHandler as RouteHandler$1, Routes, SCHEMES_META, Server as Server$1, ServerOptions, TOOLS_META } from "@ts-kizuna/core/adapter";
|
|
3
3
|
import { Contract, RoutesOf } from "@ts-kizuna/core";
|
|
4
4
|
|
|
5
5
|
//#region src/server.d.ts
|
|
@@ -8,6 +8,7 @@ type HonoApi<R extends Routes = Routes> = ApiWithRouter<R> & {
|
|
|
8
8
|
readonly [SCHEMES_META]?: unknown;
|
|
9
9
|
readonly [REQUEST_CONTEXT_META]?: unknown;
|
|
10
10
|
readonly [JOBS_META]?: unknown;
|
|
11
|
+
readonly [TOOLS_META]?: unknown;
|
|
11
12
|
/**
|
|
12
13
|
* Register every contract route on a Hono app.
|
|
13
14
|
*/
|
|
@@ -32,6 +33,10 @@ type Router<C, E extends Env = Env> = ContractRouter<C, HonoHandlerContext<E>>;
|
|
|
32
33
|
* receives only the job's `input`, so the same handler can be run in process.
|
|
33
34
|
*/
|
|
34
35
|
type JobsRouter<C> = ContractJobsRouter<C>;
|
|
36
|
+
/**
|
|
37
|
+
* The handler for each of a contract's tools, typed against it.
|
|
38
|
+
*/
|
|
39
|
+
type ToolsRouter<C> = ContractToolsRouter<C>;
|
|
35
40
|
interface HonoOptions {
|
|
36
41
|
/**
|
|
37
42
|
* Validate handler return values against the routes' response schemas.
|
|
@@ -66,8 +71,9 @@ declare class KizunaServer<C extends Contract, E extends Env = Env> implements S
|
|
|
66
71
|
readonly requestContext: Server<C, E>['requestContext'];
|
|
67
72
|
readonly router: Server<C, E>['router'];
|
|
68
73
|
readonly jobs: Server<C, E>['jobs'];
|
|
74
|
+
readonly tools: Server<C, E>['tools'];
|
|
69
75
|
readonly api: Server<C, E>['api'];
|
|
70
76
|
constructor(contract: C, options?: ServerOptions);
|
|
71
77
|
}
|
|
72
78
|
//#endregion
|
|
73
|
-
export { HonoApi, HonoHandlerContext, HonoOptions, JobsRouter, KizunaServer, RouteHandler, Router, Server, mountHono };
|
|
79
|
+
export { HonoApi, HonoHandlerContext, HonoOptions, JobsRouter, KizunaServer, RouteHandler, Router, Server, ToolsRouter, mountHono };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiWithRouter, ContractJobsRouter, ContractRouter, ErrorFormatter, GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, RouteDefinition, RouteHandler as RouteHandler$1, Routes, SCHEMES_META, Server as Server$1, ServerOptions } from "@ts-kizuna/core/adapter";
|
|
1
|
+
import { ApiWithRouter, ContractJobsRouter, ContractRouter, ContractToolsRouter, ErrorFormatter, GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, RouteDefinition, RouteHandler as RouteHandler$1, Routes, SCHEMES_META, Server as Server$1, ServerOptions, TOOLS_META } from "@ts-kizuna/core/adapter";
|
|
2
2
|
import { Context, Env, Hono } from "hono";
|
|
3
3
|
import { Contract, RoutesOf } from "@ts-kizuna/core";
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ type HonoApi<R extends Routes = Routes> = ApiWithRouter<R> & {
|
|
|
8
8
|
readonly [SCHEMES_META]?: unknown;
|
|
9
9
|
readonly [REQUEST_CONTEXT_META]?: unknown;
|
|
10
10
|
readonly [JOBS_META]?: unknown;
|
|
11
|
+
readonly [TOOLS_META]?: unknown;
|
|
11
12
|
/**
|
|
12
13
|
* Register every contract route on a Hono app.
|
|
13
14
|
*/
|
|
@@ -32,6 +33,10 @@ type Router<C, E extends Env = Env> = ContractRouter<C, HonoHandlerContext<E>>;
|
|
|
32
33
|
* receives only the job's `input`, so the same handler can be run in process.
|
|
33
34
|
*/
|
|
34
35
|
type JobsRouter<C> = ContractJobsRouter<C>;
|
|
36
|
+
/**
|
|
37
|
+
* The handler for each of a contract's tools, typed against it.
|
|
38
|
+
*/
|
|
39
|
+
type ToolsRouter<C> = ContractToolsRouter<C>;
|
|
35
40
|
interface HonoOptions {
|
|
36
41
|
/**
|
|
37
42
|
* Validate handler return values against the routes' response schemas.
|
|
@@ -66,8 +71,9 @@ declare class KizunaServer<C extends Contract, E extends Env = Env> implements S
|
|
|
66
71
|
readonly requestContext: Server<C, E>['requestContext'];
|
|
67
72
|
readonly router: Server<C, E>['router'];
|
|
68
73
|
readonly jobs: Server<C, E>['jobs'];
|
|
74
|
+
readonly tools: Server<C, E>['tools'];
|
|
69
75
|
readonly api: Server<C, E>['api'];
|
|
70
76
|
constructor(contract: C, options?: ServerOptions);
|
|
71
77
|
}
|
|
72
78
|
//#endregion
|
|
73
|
-
export { HonoApi, HonoHandlerContext, HonoOptions, JobsRouter, KizunaServer, RouteHandler, Router, Server, mountHono };
|
|
79
|
+
export { HonoApi, HonoHandlerContext, HonoOptions, JobsRouter, KizunaServer, RouteHandler, Router, Server, ToolsRouter, mountHono };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, ROUTER_META, SCHEMES_META, createAdapter, createServerSurface, headersToObject, jobRouter, jobRoutes, jobRunnerFrom, parseFetchBody, pluginExportsOf, pluginRouterOf, pluginRoutesOf, renderJsonResult } from "@ts-kizuna/core/adapter";
|
|
1
|
+
import { GUARDS_META, JOBS_META, REQUEST_CONTEXT_META, ROUTER_META, SCHEMES_META, TOOLS_META, createAdapter, createServerSurface, headersToObject, jobRouter, jobRoutes, jobRunnerFrom, parseFetchBody, pluginExportsOf, pluginRouterOf, pluginRoutesOf, renderJsonResult, toolRunnerFrom } from "@ts-kizuna/core/adapter";
|
|
2
2
|
//#region src/server.ts
|
|
3
3
|
/**
|
|
4
4
|
* A guard per identity, keyed by name. Each receives the handler context, a
|
|
@@ -45,6 +45,7 @@ function mountHono(api, app, options) {
|
|
|
45
45
|
const pluginExports = pluginExportsOf(api);
|
|
46
46
|
const jobsMeta = api[JOBS_META];
|
|
47
47
|
const jobRunner = jobRunnerFrom(jobsMeta);
|
|
48
|
+
const toolRunner = toolRunnerFrom(api[TOOLS_META]);
|
|
48
49
|
const mountRoute = (routeKey, route, lane, resolvedRouter) => {
|
|
49
50
|
const method = route.method.toLowerCase();
|
|
50
51
|
const kizunaHandler = async (c) => {
|
|
@@ -76,6 +77,7 @@ function mountHono(api, app, options) {
|
|
|
76
77
|
requestContext,
|
|
77
78
|
pluginExports,
|
|
78
79
|
jobs: jobRunner,
|
|
80
|
+
tools: toolRunner,
|
|
79
81
|
responseValidation: options?.responseValidation
|
|
80
82
|
});
|
|
81
83
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-kizuna/hono",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.60.0",
|
|
4
4
|
"description": "Hono adapter for ts-kizuna",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ts-kizuna",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"hono": "^4.0.0",
|
|
59
59
|
"zod": "^4.0.0",
|
|
60
|
-
"@ts-kizuna/core": "1.
|
|
60
|
+
"@ts-kizuna/core": "1.60.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"hono": "^4.7.0",
|
|
64
64
|
"tsdown": "^0.21.0",
|
|
65
65
|
"typescript": "^6.0.3",
|
|
66
66
|
"zod": "^4.0.0",
|
|
67
|
-
"@ts-kizuna/core": "1.
|
|
67
|
+
"@ts-kizuna/core": "1.60.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown src/index.ts --format esm,cjs --dts --clean --external @ts-kizuna/core --external hono --external zod",
|