hono 4.3.0 → 4.3.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/dist/types/types.d.ts +18 -6
- package/package.json +1 -1
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from './context';
|
|
2
2
|
import type { Hono } from './hono';
|
|
3
3
|
import type { StatusCode } from './utils/http-status';
|
|
4
|
-
import type { IfAnyThenEmptyObject, JSONValue, Prettify, RemoveBlankRecord, UnionToIntersection } from './utils/types';
|
|
4
|
+
import type { IfAnyThenEmptyObject, IsAny, JSONValue, Prettify, RemoveBlankRecord, Simplify, UnionToIntersection } from './utils/types';
|
|
5
5
|
export type Bindings = Record<string, unknown>;
|
|
6
6
|
export type Variables = Record<string, unknown>;
|
|
7
7
|
export type Env = {
|
|
@@ -9,6 +9,7 @@ export type Env = {
|
|
|
9
9
|
Variables?: Variables;
|
|
10
10
|
};
|
|
11
11
|
export type Next = () => Promise<void>;
|
|
12
|
+
export type ExtractInput<I extends Input | Input['in']> = I extends Input ? unknown extends I['in'] ? {} : I['in'] : I;
|
|
12
13
|
export type Input = {
|
|
13
14
|
in?: {};
|
|
14
15
|
out?: {};
|
|
@@ -361,16 +362,27 @@ export interface OnHandlerInterface<E extends Env = Env, S extends Schema = {},
|
|
|
361
362
|
<I extends Input = BlankInput, R extends HandlerResponse<any> = any>(methods: string | string[], paths: string[], ...handlers: H<E, any, I, R>[]): Hono<E, S & ToSchema<string, string, I, MergeTypedResponse<R>>, BasePath>;
|
|
362
363
|
}
|
|
363
364
|
type ExtractKey<S> = S extends Record<infer Key, unknown> ? Key extends string ? Key : never : string;
|
|
364
|
-
export type ToSchema<M extends string, P extends string, I extends Input
|
|
365
|
+
export type ToSchema<M extends string, P extends string, I extends Input | Input['in'], RorO> = Prettify<{
|
|
365
366
|
[K in P]: {
|
|
366
|
-
[K2 in M as AddDollar<K2>]:
|
|
367
|
-
input:
|
|
367
|
+
[K2 in M as AddDollar<K2>]: Simplify<{
|
|
368
|
+
input: AddParam<ExtractInput<I>, P>;
|
|
369
|
+
} & (IsAny<RorO> extends true ? {
|
|
370
|
+
output: {};
|
|
371
|
+
outputFormat: ResponseFormat;
|
|
372
|
+
status: StatusCode;
|
|
373
|
+
} : RorO extends TypedResponse<infer T, infer U, infer F> ? {
|
|
368
374
|
output: unknown extends T ? {} : T;
|
|
369
375
|
outputFormat: I extends {
|
|
370
376
|
outputFormat: string;
|
|
371
|
-
} ? I['outputFormat'] :
|
|
377
|
+
} ? I['outputFormat'] : F;
|
|
372
378
|
status: U;
|
|
373
|
-
} :
|
|
379
|
+
} : {
|
|
380
|
+
output: unknown extends RorO ? {} : RorO;
|
|
381
|
+
outputFormat: unknown extends RorO ? 'json' : I extends {
|
|
382
|
+
outputFormat: string;
|
|
383
|
+
} ? I['outputFormat'] : 'json';
|
|
384
|
+
status: StatusCode;
|
|
385
|
+
})>;
|
|
374
386
|
};
|
|
375
387
|
}>;
|
|
376
388
|
export type Schema = {
|