rouzer 1.4.0 → 1.5.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/client/index.d.ts +2 -1
- package/dist/common.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/route.d.ts +2 -1
- package/dist/server/types.d.ts +2 -1
- package/dist/types.d.ts +12 -5
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Promisable } from '../common.js';
|
|
1
2
|
import { Route } from '../route.js';
|
|
2
|
-
import type { InferRouteResponse,
|
|
3
|
+
import type { InferRouteResponse, RouteArgs, RouteRequest, RouteSchema } from '../types.js';
|
|
3
4
|
export type RouzerClient<TRoutes extends Record<string, Route> = Record<string, never>> = ReturnType<typeof createClient<TRoutes>>;
|
|
4
5
|
export declare function createClient<TRoutes extends Record<string, Route> = Record<string, never>>(config: {
|
|
5
6
|
/**
|
package/dist/common.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/route.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RoutePattern } from '@remix-run/route-pattern';
|
|
2
|
-
import
|
|
2
|
+
import { Unchecked } from './common.js';
|
|
3
|
+
import type { RouteRequestFactory, RouteSchema, RouteSchemaMap } from './types.js';
|
|
3
4
|
export declare function $type<T>(): Unchecked<T>;
|
|
4
5
|
export declare namespace $type {
|
|
5
6
|
var symbol: symbol;
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Params } from '@remix-run/route-pattern';
|
|
2
2
|
import type { AnyMiddlewareChain, MiddlewareChain, MiddlewareContext } from 'alien-middleware';
|
|
3
3
|
import type * as z from 'zod/mini';
|
|
4
|
-
import
|
|
4
|
+
import { Promisable } from '../common.js';
|
|
5
|
+
import type { InferRouteResponse, Routes, RouteSchema } from '../types.js';
|
|
5
6
|
type RequestContext<TMiddleware extends AnyMiddlewareChain> = MiddlewareContext<TMiddleware>;
|
|
6
7
|
type RouteRequestHandler<TMiddleware extends AnyMiddlewareChain, TArgs extends object, TResult> = (context: RequestContext<TMiddleware> & TArgs) => Promisable<TResult | Response>;
|
|
7
8
|
type InferRouteRequestHandler<TMiddleware extends AnyMiddlewareChain, TSchema extends RouteSchema, TMethod extends string, TPath extends string> = TMethod extends 'GET' ? RouteRequestHandler<TMiddleware, {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Params, RoutePattern } from '@remix-run/route-pattern';
|
|
2
2
|
import * as z from 'zod/mini';
|
|
3
|
-
|
|
4
|
-
export type Unchecked
|
|
5
|
-
__unchecked__: T;
|
|
6
|
-
};
|
|
3
|
+
import { Unchecked } from './common.js';
|
|
4
|
+
export type { Unchecked };
|
|
7
5
|
export type QueryRouteSchema = {
|
|
8
6
|
path?: z.ZodMiniObject<any>;
|
|
9
7
|
query?: z.ZodMiniObject<any>;
|
|
@@ -89,9 +87,18 @@ export type RouteResponse<TResult = any> = Response & {
|
|
|
89
87
|
export type InferRouteResponse<T extends RouteSchema> = T extends {
|
|
90
88
|
response: Unchecked<infer TResponse>;
|
|
91
89
|
} ? TResponse : void;
|
|
90
|
+
type InferRouteSchemaBody<TSchema> = TSchema extends MutationRouteSchema ? TSchema extends {
|
|
91
|
+
body: infer TBody;
|
|
92
|
+
} ? z.infer<TBody> : unknown : never;
|
|
93
|
+
type InferRouteArgsBody<TArgs> = TArgs extends {
|
|
94
|
+
body?: infer TBody;
|
|
95
|
+
} ? TBody : never;
|
|
96
|
+
export type InferRouteBody<T> = T extends RouteRequestFactory<any, any> ? InferRouteArgsBody<T['$args']> : T extends RouteSchema ? InferRouteSchemaBody<T> : never;
|
|
97
|
+
export type InferRouteMethodBody<TRoute extends {
|
|
98
|
+
methods: RouteSchemaMap;
|
|
99
|
+
}, TMethod extends keyof TRoute['methods']> = TMethod extends 'GET' | 'ALL' ? never : TMethod extends keyof TRoute ? InferRouteBody<TRoute[TMethod]> : InferRouteBody<Extract<TRoute['methods'][TMethod], RouteSchema>>;
|
|
92
100
|
export type RouteRequestFactory<T extends RouteSchema, P extends string> = {
|
|
93
101
|
(...p: RouteArgs<T, P> extends infer TArgs ? {} extends TArgs ? [args?: TArgs] : [args: TArgs] : never): RouteRequest<InferRouteResponse<T>>;
|
|
94
102
|
$args: RouteArgs<T, P>;
|
|
95
103
|
$response: InferRouteResponse<T>;
|
|
96
104
|
};
|
|
97
|
-
export {};
|