@kaito-http/core 4.0.0-beta.30 → 4.0.0-beta.31
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 +23 -23
- package/dist/index.d.ts +23 -23
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSONValue, BaseSchema, AnySchemaFor } from './schema/schema.cjs';
|
|
2
|
-
export { ArrayChecks, ArrayDef,
|
|
1
|
+
import { JSONValue, BaseSchema, BaseSchemaDef, AnySchemaFor } from './schema/schema.cjs';
|
|
2
|
+
export { ArrayChecks, ArrayDef, BooleanDef, Issue, JSONPrimitive, KArray, KBoolean, KLazy, KLiteral, KNativeEnum, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRecord, KRef, KScalar, KString, KUnion, LazyDef, LiteralDef, NativeEnumDef, NullDef, NumberChecks, NumberDef, NumberFormat, ObjectDef, ParseContext, ParseResult, RecordDef, RefDef, STRING_FORMAT_REGEXES, ScalarDef, ScalarOptions, SchemaError, StringChecks, StringDef, StringFormat, UnionDef, isPrimitiveJSONValue, k } from './schema/schema.cjs';
|
|
3
3
|
import * as OpenAPI from 'openapi3-ts/oas31';
|
|
4
4
|
import { KaitoSSEResponse, SSEEvent } from './stream/stream.cjs';
|
|
5
5
|
|
|
@@ -74,7 +74,7 @@ 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 ResultOutput, infer Path, infer AdditionalParams, infer Method, infer Query, infer BodyOutput> ? Route<ContextFrom, ContextTo, RouterInput, ResultOutput, `${Prefix}${Path extends '/' ? '' : Path}`, AdditionalParams, Method, Query, BodyOutput> : never;
|
|
77
|
+
type PrefixRoutesPathInner<R extends AnyRoute, Prefix extends `/${string}`> = R extends Route<infer ContextFrom, infer ContextTo, infer RouterInput, infer ResultOutput, infer Path, infer AdditionalParams, infer Method, infer Query, infer BodyInput, infer BodyOutput> ? Route<ContextFrom, ContextTo, RouterInput, ResultOutput, `${Prefix}${Path extends '/' ? '' : Path}`, AdditionalParams, Method, Query, BodyInput, 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>;
|
|
@@ -121,29 +121,29 @@ declare class Router<ContextFrom, ContextTo, RequiredParams extends string, Rout
|
|
|
121
121
|
openapi: ({ info, servers, }: {
|
|
122
122
|
info: OpenAPI.InfoObject;
|
|
123
123
|
servers?: Partial<Record<(`https://` | `http://`) | ({} & string), string>>;
|
|
124
|
-
}) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, Response, "/openapi.json", RequiredParams, "GET", {}, never>, Input>;
|
|
124
|
+
}) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, Response, "/openapi.json", RequiredParams, "GET", {}, never, never>, Input>;
|
|
125
125
|
private readonly method;
|
|
126
|
-
readonly get: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
126
|
+
readonly get: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "GET", Query, BodyInput, BodyOutput>, "body" | "path" | "method" | "router" | "openapi"> & {
|
|
127
127
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
128
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "GET", Query,
|
|
129
|
-
readonly post: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
128
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "GET", Query, BodyInput, BodyOutput>, Input>;
|
|
129
|
+
readonly post: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "POST", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
130
130
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
131
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "POST", Query,
|
|
132
|
-
readonly put: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
131
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "POST", Query, BodyInput, BodyOutput>, Input>;
|
|
132
|
+
readonly put: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PUT", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
133
133
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
134
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PUT", Query,
|
|
135
|
-
readonly patch: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
134
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PUT", Query, BodyInput, BodyOutput>, Input>;
|
|
135
|
+
readonly patch: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PATCH", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
136
136
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
137
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PATCH", Query,
|
|
138
|
-
readonly delete: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
137
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PATCH", Query, BodyInput, BodyOutput>, Input>;
|
|
138
|
+
readonly delete: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "DELETE", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
139
139
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
140
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "DELETE", Query,
|
|
141
|
-
readonly head: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
140
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "DELETE", Query, BodyInput, BodyOutput>, Input>;
|
|
141
|
+
readonly head: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "HEAD", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
142
142
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
143
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "HEAD", Query,
|
|
144
|
-
readonly options: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
143
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "HEAD", Query, BodyInput, BodyOutput>, Input>;
|
|
144
|
+
readonly options: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "OPTIONS", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
145
145
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
146
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "OPTIONS", Query,
|
|
146
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "OPTIONS", Query, BodyInput, BodyOutput>, Input>;
|
|
147
147
|
through: <NextContext>(through: (context: ContextTo, params: Record<RequiredParams, string>) => MaybePromise<NextContext>) => Router<ContextFrom, NextContext, RequiredParams, Routes, Input>;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -184,8 +184,8 @@ type OpenAPISpec<Body extends OutputSpec = OutputSpec> = {
|
|
|
184
184
|
body: Body;
|
|
185
185
|
};
|
|
186
186
|
type OpenAPISpecFor<ResultOutput> = 0 extends 1 & ResultOutput ? OpenAPISpec : [ResultOutput] extends [never] ? OpenAPISpec : [ResultOutput] extends [KaitoSSEResponse<any>] ? [ResultOutput extends KaitoSSEResponse<SSEEvent<infer U, any>> ? U : never] extends [JSONValue] ? OpenAPISpec<SSEOutputSpec> : OpenAPISpec<SSEOutputSpecWithSchema> : [ResultOutput] extends [Response] ? OpenAPISpec<ResponseOutputSpec> : OpenAPISpec<JSONOutputSpec>;
|
|
187
|
-
type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue>,
|
|
188
|
-
body?:
|
|
187
|
+
type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue>, BodyInput extends JSONValue, BodyOutput> = {
|
|
188
|
+
body?: BaseSchema<BodyInput, BodyOutput, BaseSchemaDef<BodyInput>>;
|
|
189
189
|
query?: {
|
|
190
190
|
[Key in keyof Query]: AnySchemaFor<Query[Key]>;
|
|
191
191
|
};
|
|
@@ -193,9 +193,9 @@ type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], Resul
|
|
|
193
193
|
method: Method;
|
|
194
194
|
openapi?: OpenAPISpec;
|
|
195
195
|
router: Router<ContextFrom, ContextTo, AdditionalParams, AnyRoute, RouterInput>;
|
|
196
|
-
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query,
|
|
196
|
+
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query, BodyOutput>): Promise<ResultOutput> | ResultOutput;
|
|
197
197
|
};
|
|
198
|
-
type AnyRoute = Route<any, any, any, unknown, any, any, any, any, any>;
|
|
198
|
+
type AnyRoute = Route<any, any, any, unknown, any, any, any, any, any, any>;
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* A helper to check if the environment is Node.js-like and the `NODE_ENV` environment variable is set to `'development'`
|
|
@@ -297,4 +297,4 @@ interface KaitoConfig<ContextFrom, Input extends readonly unknown[]> {
|
|
|
297
297
|
*/
|
|
298
298
|
declare const create: <Context = null, Input extends readonly unknown[] = []>(config?: KaitoConfig<Context, Input>) => Router<Context, Context, never, never, Input>;
|
|
299
299
|
|
|
300
|
-
export { type AnyQuery, type AnyRoute, AnySchemaFor, BaseSchema, type ExtractRouteParams, type GetContext, type InferRoutes, type JSONOutputSpec, JSONValue, type KaitoConfig, KaitoError, KaitoHead, type KaitoMethod, KaitoRequest, type MaybePromise, type OpenAPISpec, type OpenAPISpecFor, type OutputSpec, type ResponseOutputSpec, type Route, type RouteRunData, Router, type RouterState, type SSEOutputSpec, type SSEOutputSpecWithSchema, type SSEOutputSpecWithoutSchema, type Through, WrappedError, create, isNodeLikeDev };
|
|
300
|
+
export { type AnyQuery, type AnyRoute, AnySchemaFor, BaseSchema, BaseSchemaDef, type ExtractRouteParams, type GetContext, type InferRoutes, type JSONOutputSpec, JSONValue, type KaitoConfig, KaitoError, KaitoHead, type KaitoMethod, KaitoRequest, type MaybePromise, type OpenAPISpec, type OpenAPISpecFor, type OutputSpec, type ResponseOutputSpec, type Route, type RouteRunData, Router, type RouterState, type SSEOutputSpec, type SSEOutputSpecWithSchema, type SSEOutputSpecWithoutSchema, type Through, WrappedError, create, isNodeLikeDev };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSONValue, BaseSchema, AnySchemaFor } from './schema/schema.js';
|
|
2
|
-
export { ArrayChecks, ArrayDef,
|
|
1
|
+
import { JSONValue, BaseSchema, BaseSchemaDef, AnySchemaFor } from './schema/schema.js';
|
|
2
|
+
export { ArrayChecks, ArrayDef, BooleanDef, Issue, JSONPrimitive, KArray, KBoolean, KLazy, KLiteral, KNativeEnum, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRecord, KRef, KScalar, KString, KUnion, LazyDef, LiteralDef, NativeEnumDef, NullDef, NumberChecks, NumberDef, NumberFormat, ObjectDef, ParseContext, ParseResult, RecordDef, RefDef, STRING_FORMAT_REGEXES, ScalarDef, ScalarOptions, SchemaError, StringChecks, StringDef, StringFormat, UnionDef, isPrimitiveJSONValue, k } from './schema/schema.js';
|
|
3
3
|
import * as OpenAPI from 'openapi3-ts/oas31';
|
|
4
4
|
import { KaitoSSEResponse, SSEEvent } from './stream/stream.js';
|
|
5
5
|
|
|
@@ -74,7 +74,7 @@ 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 ResultOutput, infer Path, infer AdditionalParams, infer Method, infer Query, infer BodyOutput> ? Route<ContextFrom, ContextTo, RouterInput, ResultOutput, `${Prefix}${Path extends '/' ? '' : Path}`, AdditionalParams, Method, Query, BodyOutput> : never;
|
|
77
|
+
type PrefixRoutesPathInner<R extends AnyRoute, Prefix extends `/${string}`> = R extends Route<infer ContextFrom, infer ContextTo, infer RouterInput, infer ResultOutput, infer Path, infer AdditionalParams, infer Method, infer Query, infer BodyInput, infer BodyOutput> ? Route<ContextFrom, ContextTo, RouterInput, ResultOutput, `${Prefix}${Path extends '/' ? '' : Path}`, AdditionalParams, Method, Query, BodyInput, 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>;
|
|
@@ -121,29 +121,29 @@ declare class Router<ContextFrom, ContextTo, RequiredParams extends string, Rout
|
|
|
121
121
|
openapi: ({ info, servers, }: {
|
|
122
122
|
info: OpenAPI.InfoObject;
|
|
123
123
|
servers?: Partial<Record<(`https://` | `http://`) | ({} & string), string>>;
|
|
124
|
-
}) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, Response, "/openapi.json", RequiredParams, "GET", {}, never>, Input>;
|
|
124
|
+
}) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, Response, "/openapi.json", RequiredParams, "GET", {}, never, never>, Input>;
|
|
125
125
|
private readonly method;
|
|
126
|
-
readonly get: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
126
|
+
readonly get: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "GET", Query, BodyInput, BodyOutput>, "body" | "path" | "method" | "router" | "openapi"> & {
|
|
127
127
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
128
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "GET", Query,
|
|
129
|
-
readonly post: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
128
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "GET", Query, BodyInput, BodyOutput>, Input>;
|
|
129
|
+
readonly post: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "POST", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
130
130
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
131
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "POST", Query,
|
|
132
|
-
readonly put: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
131
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "POST", Query, BodyInput, BodyOutput>, Input>;
|
|
132
|
+
readonly put: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PUT", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
133
133
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
134
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PUT", Query,
|
|
135
|
-
readonly patch: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
134
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PUT", Query, BodyInput, BodyOutput>, Input>;
|
|
135
|
+
readonly patch: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PATCH", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
136
136
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
137
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PATCH", Query,
|
|
138
|
-
readonly delete: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
137
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "PATCH", Query, BodyInput, BodyOutput>, Input>;
|
|
138
|
+
readonly delete: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "DELETE", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
139
139
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
140
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "DELETE", Query,
|
|
141
|
-
readonly head: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
140
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "DELETE", Query, BodyInput, BodyOutput>, Input>;
|
|
141
|
+
readonly head: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "HEAD", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
142
142
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
143
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "HEAD", Query,
|
|
144
|
-
readonly options: <Path extends string, ResultOutput = never, Query extends AnyQuery = {},
|
|
143
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "HEAD", Query, BodyInput, BodyOutput>, Input>;
|
|
144
|
+
readonly options: <Path extends string, ResultOutput = never, Query extends AnyQuery = {}, BodyInput extends JSONValue = never, BodyOutput = never>(path: Path, route: ((data: RouteRunData<RequiredParams | ExtractRouteParams<Path>, ContextTo, Query, BodyOutput>) => ResultOutput | Promise<ResultOutput>) | (Omit<Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "OPTIONS", Query, BodyInput, BodyOutput>, "path" | "method" | "router" | "openapi"> & {
|
|
145
145
|
openapi?: OpenAPISpecFor<ResultOutput>;
|
|
146
|
-
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "OPTIONS", Query,
|
|
146
|
+
})) => Router<ContextFrom, ContextTo, RequiredParams, Routes | Route<ContextFrom, ContextTo, Input, ResultOutput, Path, RequiredParams, "OPTIONS", Query, BodyInput, BodyOutput>, Input>;
|
|
147
147
|
through: <NextContext>(through: (context: ContextTo, params: Record<RequiredParams, string>) => MaybePromise<NextContext>) => Router<ContextFrom, NextContext, RequiredParams, Routes, Input>;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -184,8 +184,8 @@ type OpenAPISpec<Body extends OutputSpec = OutputSpec> = {
|
|
|
184
184
|
body: Body;
|
|
185
185
|
};
|
|
186
186
|
type OpenAPISpecFor<ResultOutput> = 0 extends 1 & ResultOutput ? OpenAPISpec : [ResultOutput] extends [never] ? OpenAPISpec : [ResultOutput] extends [KaitoSSEResponse<any>] ? [ResultOutput extends KaitoSSEResponse<SSEEvent<infer U, any>> ? U : never] extends [JSONValue] ? OpenAPISpec<SSEOutputSpec> : OpenAPISpec<SSEOutputSpecWithSchema> : [ResultOutput] extends [Response] ? OpenAPISpec<ResponseOutputSpec> : OpenAPISpec<JSONOutputSpec>;
|
|
187
|
-
type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue>,
|
|
188
|
-
body?:
|
|
187
|
+
type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue>, BodyInput extends JSONValue, BodyOutput> = {
|
|
188
|
+
body?: BaseSchema<BodyInput, BodyOutput, BaseSchemaDef<BodyInput>>;
|
|
189
189
|
query?: {
|
|
190
190
|
[Key in keyof Query]: AnySchemaFor<Query[Key]>;
|
|
191
191
|
};
|
|
@@ -193,9 +193,9 @@ type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], Resul
|
|
|
193
193
|
method: Method;
|
|
194
194
|
openapi?: OpenAPISpec;
|
|
195
195
|
router: Router<ContextFrom, ContextTo, AdditionalParams, AnyRoute, RouterInput>;
|
|
196
|
-
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query,
|
|
196
|
+
run(data: RouteRunData<ExtractRouteParams<Path> | AdditionalParams, ContextTo, Query, BodyOutput>): Promise<ResultOutput> | ResultOutput;
|
|
197
197
|
};
|
|
198
|
-
type AnyRoute = Route<any, any, any, unknown, any, any, any, any, any>;
|
|
198
|
+
type AnyRoute = Route<any, any, any, unknown, any, any, any, any, any, any>;
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* A helper to check if the environment is Node.js-like and the `NODE_ENV` environment variable is set to `'development'`
|
|
@@ -297,4 +297,4 @@ interface KaitoConfig<ContextFrom, Input extends readonly unknown[]> {
|
|
|
297
297
|
*/
|
|
298
298
|
declare const create: <Context = null, Input extends readonly unknown[] = []>(config?: KaitoConfig<Context, Input>) => Router<Context, Context, never, never, Input>;
|
|
299
299
|
|
|
300
|
-
export { type AnyQuery, type AnyRoute, AnySchemaFor, BaseSchema, type ExtractRouteParams, type GetContext, type InferRoutes, type JSONOutputSpec, JSONValue, type KaitoConfig, KaitoError, KaitoHead, type KaitoMethod, KaitoRequest, type MaybePromise, type OpenAPISpec, type OpenAPISpecFor, type OutputSpec, type ResponseOutputSpec, type Route, type RouteRunData, Router, type RouterState, type SSEOutputSpec, type SSEOutputSpecWithSchema, type SSEOutputSpecWithoutSchema, type Through, WrappedError, create, isNodeLikeDev };
|
|
300
|
+
export { type AnyQuery, type AnyRoute, AnySchemaFor, BaseSchema, BaseSchemaDef, type ExtractRouteParams, type GetContext, type InferRoutes, type JSONOutputSpec, JSONValue, type KaitoConfig, KaitoError, KaitoHead, type KaitoMethod, KaitoRequest, type MaybePromise, type OpenAPISpec, type OpenAPISpecFor, type OutputSpec, type ResponseOutputSpec, type Route, type RouteRunData, Router, type RouterState, type SSEOutputSpec, type SSEOutputSpecWithSchema, type SSEOutputSpecWithoutSchema, type Through, WrappedError, create, isNodeLikeDev };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
KaitoSSEResponse,
|
|
3
|
-
sseEventToString
|
|
4
|
-
} from "./chunk-HJ5HIYGW.js";
|
|
5
1
|
import {
|
|
6
2
|
BaseSchema,
|
|
7
3
|
KArray,
|
|
@@ -24,6 +20,10 @@ import {
|
|
|
24
20
|
isPrimitiveJSONValue,
|
|
25
21
|
k
|
|
26
22
|
} from "./chunk-DRJX3OJG.js";
|
|
23
|
+
import {
|
|
24
|
+
KaitoSSEResponse,
|
|
25
|
+
sseEventToString
|
|
26
|
+
} from "./chunk-HJ5HIYGW.js";
|
|
27
27
|
|
|
28
28
|
// src/router/router.ts
|
|
29
29
|
import "openapi3-ts/oas31";
|