@kaito-http/core 4.0.0-beta.19 → 4.0.0-beta.20
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.d.cts +25 -23
- package/dist/index.d.ts +25 -23
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -74,42 +74,42 @@ declare class KaitoHead {
|
|
|
74
74
|
get touched(): boolean;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
type PrefixRoutesPathInner<R extends AnyRoute, Prefix extends `/${string}`> = R extends Route<infer ContextFrom, infer ContextTo, infer RouterInput, infer
|
|
77
|
+
type PrefixRoutesPathInner<R extends AnyRoute, Prefix extends `/${string}`> = R extends Route<infer ContextFrom, infer ContextTo, infer RouterInput, infer ResultInput, infer ResultOutput, infer Path, infer AdditionalParams, infer Method, infer Query, infer BodyOutput> ? Route<ContextFrom, ContextTo, RouterInput, ResultInput, ResultOutput, `${Prefix}${Path extends '/' ? '' : Path}`, AdditionalParams, Method, Query, BodyOutput> : never;
|
|
78
78
|
type PrefixRoutesPath<Prefix extends `/${string}`, R extends AnyRoute> = R extends R ? PrefixRoutesPathInner<R, Prefix> : never;
|
|
79
79
|
type RouterState<ContextFrom, ContextTo, RequiredParams extends string, Routes extends AnyRoute, Input extends readonly unknown[]> = {
|
|
80
80
|
routes: Set<Routes>;
|
|
81
81
|
through: (context: ContextFrom, params: Record<RequiredParams, string>) => Promise<ContextTo> | ContextTo;
|
|
82
82
|
config: KaitoConfig<ContextFrom, Input>;
|
|
83
83
|
};
|
|
84
|
-
declare class Router<ContextFrom, ContextTo, RequiredParams extends string,
|
|
84
|
+
declare class Router<ContextFrom, ContextTo, RequiredParams extends string, Routes extends AnyRoute, Input extends readonly unknown[]> {
|
|
85
85
|
#private;
|
|
86
86
|
static create: <Context = null, Input_1 extends readonly unknown[] = []>(config?: KaitoConfig<Context, Input_1>) => Router<Context, Context, never, never, Input_1>;
|
|
87
|
-
protected constructor(state: RouterState<ContextFrom, ContextTo, RequiredParams,
|
|
88
|
-
get routes(): Set<
|
|
87
|
+
protected constructor(state: RouterState<ContextFrom, ContextTo, RequiredParams, Routes, Input>);
|
|
88
|
+
get routes(): Set<Routes>;
|
|
89
89
|
private readonly add;
|
|
90
|
-
readonly params: [RequiredParams] extends [never] ? <NextParams extends string>() => Router<ContextFrom, ContextTo, NextParams,
|
|
91
|
-
readonly merge: <PathPrefix extends `/${string}`, NextRequiredParams extends string, OtherRoutes extends AnyRoute>(pathPrefix: [NextRequiredParams] extends [ExtractRouteParams<PathPrefix> | RequiredParams] ? PathPrefix : `/:${Exclude<NextRequiredParams, ExtractRouteParams<PathPrefix> | RequiredParams>}`, other: Router<ContextFrom, ContextTo, NextRequiredParams, OtherRoutes, Input>) => Router<ContextFrom, ContextTo, RequiredParams,
|
|
92
|
-
protected static getFindRoute: <
|
|
90
|
+
readonly params: [RequiredParams] extends [never] ? <NextParams extends string>() => Router<ContextFrom, ContextTo, NextParams, Routes, Input> : () => Router<ContextFrom, ContextTo, RequiredParams, Routes, Input>;
|
|
91
|
+
readonly merge: <PathPrefix extends `/${string}`, NextRequiredParams extends string, OtherRoutes extends AnyRoute>(pathPrefix: [NextRequiredParams] extends [ExtractRouteParams<PathPrefix> | RequiredParams] ? PathPrefix : `/:${Exclude<NextRequiredParams, ExtractRouteParams<PathPrefix> | RequiredParams>}`, other: Router<ContextFrom, ContextTo, NextRequiredParams, OtherRoutes, Input>) => Router<ContextFrom, ContextTo, RequiredParams, Routes | PrefixRoutesPath<PathPrefix, OtherRoutes>, Input>;
|
|
92
|
+
protected static getFindRoute: <R>(routes: Map<KaitoMethod, Map<string, R>>) => (method: KaitoMethod, path: string) => {
|
|
93
93
|
route?: never;
|
|
94
94
|
params?: never;
|
|
95
95
|
} | {
|
|
96
|
-
route:
|
|
96
|
+
route: R;
|
|
97
97
|
params: Record<string, string>;
|
|
98
98
|
};
|
|
99
99
|
serve: () => (request: Request, ...args: Input) => Promise<Response>;
|
|
100
100
|
openapi: ({ info, servers, }: {
|
|
101
101
|
info: OpenAPI.InfoObject;
|
|
102
102
|
servers?: Partial<Record<(`https://` | `http://`) | ({} & string), string>>;
|
|
103
|
-
}) => Router<ContextFrom, ContextTo, RequiredParams,
|
|
103
|
+
}) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, never, Response, "/openapi.json", RequiredParams, "GET", {}, never>, Input>;
|
|
104
104
|
private readonly method;
|
|
105
|
-
readonly get: <Path extends string,
|
|
106
|
-
readonly post: <Path extends string,
|
|
107
|
-
readonly put: <Path extends string,
|
|
108
|
-
readonly patch: <Path extends string,
|
|
109
|
-
readonly delete: <Path extends string,
|
|
110
|
-
readonly head: <Path extends string,
|
|
111
|
-
readonly options: <Path extends string,
|
|
112
|
-
through: <NextContext>(through: (context: ContextTo, params: Record<RequiredParams, string>) => MaybePromise<NextContext>) => Router<ContextFrom, NextContext, RequiredParams,
|
|
105
|
+
readonly get: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "GET", Query, Body>, "body" | "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "GET", Query, Body>, Input>;
|
|
106
|
+
readonly post: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "POST", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "POST", Query, Body>, Input>;
|
|
107
|
+
readonly put: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PUT", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PUT", Query, Body>, Input>;
|
|
108
|
+
readonly patch: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PATCH", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PATCH", Query, Body>, Input>;
|
|
109
|
+
readonly delete: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "DELETE", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "DELETE", Query, Body>, Input>;
|
|
110
|
+
readonly head: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "HEAD", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "HEAD", Query, Body>, Input>;
|
|
111
|
+
readonly options: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "OPTIONS", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "OPTIONS", Query, Body>, Input>;
|
|
112
|
+
through: <NextContext>(through: (context: ContextTo, params: Record<RequiredParams, string>) => MaybePromise<NextContext>) => Router<ContextFrom, NextContext, RequiredParams, Routes, Input>;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
type RouteRunData<Params extends string, Context, QueryOutput, BodyOutput> = {
|
|
@@ -125,14 +125,16 @@ type Through<From, To, RequiredParams extends string> = (context: From, params:
|
|
|
125
125
|
type SSEOutputSpec<Result extends JSONValue> = {
|
|
126
126
|
type: 'sse';
|
|
127
127
|
schema: AnySchemaFor<Result>;
|
|
128
|
-
description?: string;
|
|
128
|
+
description?: string | undefined;
|
|
129
129
|
};
|
|
130
130
|
type JSONOutputSpec<ResultInput, ResultOutput extends JSONValue> = {
|
|
131
131
|
type: 'json';
|
|
132
132
|
schema: BaseSchema<ResultOutput, ResultInput, BaseSchemaDef<ResultOutput>>;
|
|
133
|
-
description?: string;
|
|
133
|
+
description?: string | undefined;
|
|
134
134
|
};
|
|
135
|
-
type OutputSpec<ResultInput, ResultOutput> =
|
|
135
|
+
type OutputSpec<ResultInput, ResultOutput> = ResultInput extends KaitoSSEResponse<infer R> ? SSEOutputSpec<Extract<R, JSONValue>> & {
|
|
136
|
+
description?: string;
|
|
137
|
+
} : JSONOutputSpec<ResultOutput, Extract<ResultInput, JSONValue>> & {
|
|
136
138
|
description?: string;
|
|
137
139
|
};
|
|
138
140
|
type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultInput, ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue>, Body extends JSONValue> = {
|
|
@@ -142,11 +144,11 @@ type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], Resul
|
|
|
142
144
|
};
|
|
143
145
|
path: Path;
|
|
144
146
|
method: Method;
|
|
145
|
-
openapi?: OutputSpec<
|
|
147
|
+
openapi?: OutputSpec<ResultInput, ResultOutput>;
|
|
146
148
|
router: Router<ContextFrom, ContextTo, AdditionalParams, AnyRoute, RouterInput>;
|
|
147
|
-
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query, Body>):
|
|
149
|
+
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query, Body>): ResultOutput;
|
|
148
150
|
};
|
|
149
|
-
type AnyRoute = Route<any, any, any, any, any,
|
|
151
|
+
type AnyRoute = Route<any, any, any, any, any, any, any, any, any, any>;
|
|
150
152
|
|
|
151
153
|
/**
|
|
152
154
|
* A helper to check if the environment is Node.js-like and the `NODE_ENV` environment variable is set to `'development'`
|
package/dist/index.d.ts
CHANGED
|
@@ -74,42 +74,42 @@ declare class KaitoHead {
|
|
|
74
74
|
get touched(): boolean;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
type PrefixRoutesPathInner<R extends AnyRoute, Prefix extends `/${string}`> = R extends Route<infer ContextFrom, infer ContextTo, infer RouterInput, infer
|
|
77
|
+
type PrefixRoutesPathInner<R extends AnyRoute, Prefix extends `/${string}`> = R extends Route<infer ContextFrom, infer ContextTo, infer RouterInput, infer ResultInput, infer ResultOutput, infer Path, infer AdditionalParams, infer Method, infer Query, infer BodyOutput> ? Route<ContextFrom, ContextTo, RouterInput, ResultInput, ResultOutput, `${Prefix}${Path extends '/' ? '' : Path}`, AdditionalParams, Method, Query, BodyOutput> : never;
|
|
78
78
|
type PrefixRoutesPath<Prefix extends `/${string}`, R extends AnyRoute> = R extends R ? PrefixRoutesPathInner<R, Prefix> : never;
|
|
79
79
|
type RouterState<ContextFrom, ContextTo, RequiredParams extends string, Routes extends AnyRoute, Input extends readonly unknown[]> = {
|
|
80
80
|
routes: Set<Routes>;
|
|
81
81
|
through: (context: ContextFrom, params: Record<RequiredParams, string>) => Promise<ContextTo> | ContextTo;
|
|
82
82
|
config: KaitoConfig<ContextFrom, Input>;
|
|
83
83
|
};
|
|
84
|
-
declare class Router<ContextFrom, ContextTo, RequiredParams extends string,
|
|
84
|
+
declare class Router<ContextFrom, ContextTo, RequiredParams extends string, Routes extends AnyRoute, Input extends readonly unknown[]> {
|
|
85
85
|
#private;
|
|
86
86
|
static create: <Context = null, Input_1 extends readonly unknown[] = []>(config?: KaitoConfig<Context, Input_1>) => Router<Context, Context, never, never, Input_1>;
|
|
87
|
-
protected constructor(state: RouterState<ContextFrom, ContextTo, RequiredParams,
|
|
88
|
-
get routes(): Set<
|
|
87
|
+
protected constructor(state: RouterState<ContextFrom, ContextTo, RequiredParams, Routes, Input>);
|
|
88
|
+
get routes(): Set<Routes>;
|
|
89
89
|
private readonly add;
|
|
90
|
-
readonly params: [RequiredParams] extends [never] ? <NextParams extends string>() => Router<ContextFrom, ContextTo, NextParams,
|
|
91
|
-
readonly merge: <PathPrefix extends `/${string}`, NextRequiredParams extends string, OtherRoutes extends AnyRoute>(pathPrefix: [NextRequiredParams] extends [ExtractRouteParams<PathPrefix> | RequiredParams] ? PathPrefix : `/:${Exclude<NextRequiredParams, ExtractRouteParams<PathPrefix> | RequiredParams>}`, other: Router<ContextFrom, ContextTo, NextRequiredParams, OtherRoutes, Input>) => Router<ContextFrom, ContextTo, RequiredParams,
|
|
92
|
-
protected static getFindRoute: <
|
|
90
|
+
readonly params: [RequiredParams] extends [never] ? <NextParams extends string>() => Router<ContextFrom, ContextTo, NextParams, Routes, Input> : () => Router<ContextFrom, ContextTo, RequiredParams, Routes, Input>;
|
|
91
|
+
readonly merge: <PathPrefix extends `/${string}`, NextRequiredParams extends string, OtherRoutes extends AnyRoute>(pathPrefix: [NextRequiredParams] extends [ExtractRouteParams<PathPrefix> | RequiredParams] ? PathPrefix : `/:${Exclude<NextRequiredParams, ExtractRouteParams<PathPrefix> | RequiredParams>}`, other: Router<ContextFrom, ContextTo, NextRequiredParams, OtherRoutes, Input>) => Router<ContextFrom, ContextTo, RequiredParams, Routes | PrefixRoutesPath<PathPrefix, OtherRoutes>, Input>;
|
|
92
|
+
protected static getFindRoute: <R>(routes: Map<KaitoMethod, Map<string, R>>) => (method: KaitoMethod, path: string) => {
|
|
93
93
|
route?: never;
|
|
94
94
|
params?: never;
|
|
95
95
|
} | {
|
|
96
|
-
route:
|
|
96
|
+
route: R;
|
|
97
97
|
params: Record<string, string>;
|
|
98
98
|
};
|
|
99
99
|
serve: () => (request: Request, ...args: Input) => Promise<Response>;
|
|
100
100
|
openapi: ({ info, servers, }: {
|
|
101
101
|
info: OpenAPI.InfoObject;
|
|
102
102
|
servers?: Partial<Record<(`https://` | `http://`) | ({} & string), string>>;
|
|
103
|
-
}) => Router<ContextFrom, ContextTo, RequiredParams,
|
|
103
|
+
}) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, never, Response, "/openapi.json", RequiredParams, "GET", {}, never>, Input>;
|
|
104
104
|
private readonly method;
|
|
105
|
-
readonly get: <Path extends string,
|
|
106
|
-
readonly post: <Path extends string,
|
|
107
|
-
readonly put: <Path extends string,
|
|
108
|
-
readonly patch: <Path extends string,
|
|
109
|
-
readonly delete: <Path extends string,
|
|
110
|
-
readonly head: <Path extends string,
|
|
111
|
-
readonly options: <Path extends string,
|
|
112
|
-
through: <NextContext>(through: (context: ContextTo, params: Record<RequiredParams, string>) => MaybePromise<NextContext>) => Router<ContextFrom, NextContext, RequiredParams,
|
|
105
|
+
readonly get: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "GET", Query, Body>, "body" | "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "GET", Query, Body>, Input>;
|
|
106
|
+
readonly post: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "POST", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "POST", Query, Body>, Input>;
|
|
107
|
+
readonly put: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PUT", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PUT", Query, Body>, Input>;
|
|
108
|
+
readonly patch: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PATCH", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "PATCH", Query, Body>, Input>;
|
|
109
|
+
readonly delete: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "DELETE", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "DELETE", Query, Body>, Input>;
|
|
110
|
+
readonly head: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "HEAD", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "HEAD", Query, Body>, Input>;
|
|
111
|
+
readonly options: <Path extends string, ResultInput = never, ResultOutput = never, Query extends AnyQuery = {}, Body extends JSONValue = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, Body>) => ResultOutput) | Omit<Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "OPTIONS", Query, Body>, "path" | "method" | "router">) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultInput, ResultOutput, Path, RequiredParams, "OPTIONS", Query, Body>, Input>;
|
|
112
|
+
through: <NextContext>(through: (context: ContextTo, params: Record<RequiredParams, string>) => MaybePromise<NextContext>) => Router<ContextFrom, NextContext, RequiredParams, Routes, Input>;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
type RouteRunData<Params extends string, Context, QueryOutput, BodyOutput> = {
|
|
@@ -125,14 +125,16 @@ type Through<From, To, RequiredParams extends string> = (context: From, params:
|
|
|
125
125
|
type SSEOutputSpec<Result extends JSONValue> = {
|
|
126
126
|
type: 'sse';
|
|
127
127
|
schema: AnySchemaFor<Result>;
|
|
128
|
-
description?: string;
|
|
128
|
+
description?: string | undefined;
|
|
129
129
|
};
|
|
130
130
|
type JSONOutputSpec<ResultInput, ResultOutput extends JSONValue> = {
|
|
131
131
|
type: 'json';
|
|
132
132
|
schema: BaseSchema<ResultOutput, ResultInput, BaseSchemaDef<ResultOutput>>;
|
|
133
|
-
description?: string;
|
|
133
|
+
description?: string | undefined;
|
|
134
134
|
};
|
|
135
|
-
type OutputSpec<ResultInput, ResultOutput> =
|
|
135
|
+
type OutputSpec<ResultInput, ResultOutput> = ResultInput extends KaitoSSEResponse<infer R> ? SSEOutputSpec<Extract<R, JSONValue>> & {
|
|
136
|
+
description?: string;
|
|
137
|
+
} : JSONOutputSpec<ResultOutput, Extract<ResultInput, JSONValue>> & {
|
|
136
138
|
description?: string;
|
|
137
139
|
};
|
|
138
140
|
type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultInput, ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue>, Body extends JSONValue> = {
|
|
@@ -142,11 +144,11 @@ type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], Resul
|
|
|
142
144
|
};
|
|
143
145
|
path: Path;
|
|
144
146
|
method: Method;
|
|
145
|
-
openapi?: OutputSpec<
|
|
147
|
+
openapi?: OutputSpec<ResultInput, ResultOutput>;
|
|
146
148
|
router: Router<ContextFrom, ContextTo, AdditionalParams, AnyRoute, RouterInput>;
|
|
147
|
-
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query, Body>):
|
|
149
|
+
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query, Body>): ResultOutput;
|
|
148
150
|
};
|
|
149
|
-
type AnyRoute = Route<any, any, any, any, any,
|
|
151
|
+
type AnyRoute = Route<any, any, any, any, any, any, any, any, any, any>;
|
|
150
152
|
|
|
151
153
|
/**
|
|
152
154
|
* A helper to check if the environment is Node.js-like and the `NODE_ENV` environment variable is set to `'development'`
|