rouzer 1.0.0-beta.18 → 1.0.0-beta.19
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/client/index.d.ts +7 -3
- package/dist/route.d.ts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function createClient<TRoutes extends Record<string, Route> = Rec
|
|
|
24
24
|
* response is always parsed as JSON, regardless of the HTTP status code.
|
|
25
25
|
*/
|
|
26
26
|
onJsonError?: (response: Response) => Promisable<Response>;
|
|
27
|
-
}): { [K in keyof TRoutes]: TRoutes[K]["methods"] extends infer TMethods ? { [M in keyof TMethods]:
|
|
27
|
+
}): { [K in keyof TRoutes]: TRoutes[K]["methods"] extends infer TMethods ? { [M in keyof TMethods]: RouteFunction<Extract<TMethods[M], RouteSchema>, TRoutes[K]["path"]["source"]>; } : never; } & {
|
|
28
28
|
config: {
|
|
29
29
|
/**
|
|
30
30
|
* Base URL to use for all requests.
|
|
@@ -54,7 +54,11 @@ export declare function createClient<TRoutes extends Record<string, Route> = Rec
|
|
|
54
54
|
}>;
|
|
55
55
|
json: <T extends RouteRequest>(props: T) => Promise<T["$result"]>;
|
|
56
56
|
};
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* This function sends a request to a route of the same name. Such a function is
|
|
59
|
+
* accessible by setting the `routes` option when creating a Rouzer client,
|
|
60
|
+
* where it will exist as a method on the client.
|
|
61
|
+
*/
|
|
62
|
+
export type RouteFunction<T extends RouteSchema, P extends string> = (...p: RouteArgs<T, P> extends infer TArgs ? {} extends TArgs ? [args?: TArgs] : [args: TArgs] : never) => Promise<T extends {
|
|
58
63
|
response: any;
|
|
59
64
|
} ? InferRouteResponse<T> : Response>;
|
|
60
|
-
export {};
|
package/dist/route.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RoutePattern } from '@remix-run/route-pattern';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RouteRequestFactory, RouteSchema, RouteSchemaMap, Unchecked } from './types.js';
|
|
3
3
|
export declare function $type<T>(): Unchecked<T>;
|
|
4
4
|
export type Route<P extends string = string, T extends RouteSchemaMap = RouteSchemaMap> = {
|
|
5
5
|
path: RoutePattern<P>;
|
|
6
6
|
methods: T;
|
|
7
7
|
} & {
|
|
8
|
-
[K in keyof T]:
|
|
8
|
+
[K in keyof T]: RouteRequestFactory<Extract<T[K], RouteSchema>, P>;
|
|
9
9
|
};
|
|
10
10
|
export declare function route<P extends string, T extends RouteSchemaMap>(pattern: P, methods: T): Route<P, T>;
|
package/dist/types.d.ts
CHANGED
|
@@ -83,8 +83,8 @@ export type RouteResponse<TResult = any> = Response & {
|
|
|
83
83
|
export type InferRouteResponse<T extends RouteSchema> = T extends {
|
|
84
84
|
response: Unchecked<infer TResponse>;
|
|
85
85
|
} ? TResponse : void;
|
|
86
|
-
export type
|
|
87
|
-
(
|
|
86
|
+
export type RouteRequestFactory<T extends RouteSchema, P extends string> = {
|
|
87
|
+
(...p: RouteArgs<T, P> extends infer TArgs ? {} extends TArgs ? [args?: TArgs] : [args: TArgs] : never): RouteRequest<InferRouteResponse<T>>;
|
|
88
88
|
$args: RouteArgs<T, P>;
|
|
89
89
|
$response: InferRouteResponse<T>;
|
|
90
90
|
};
|