rouzer 1.0.0-beta.3 → 1.0.0-beta.4

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.
@@ -1,3 +1,4 @@
1
+ import type { Promisable, RouteRequest } from '../types.js';
1
2
  export declare function createClient(config: {
2
3
  /**
3
4
  * Base URL to use for all requests.
@@ -11,7 +12,7 @@ export declare function createClient(config: {
11
12
  * Custom handler for non-200 response to a `.json()` request. By default, the
12
13
  * response is always parsed as JSON, regardless of the HTTP status code.
13
14
  */
14
- onJsonError?: (response: Response) => Response;
15
+ onJsonError?: (response: Response) => Promisable<Response>;
15
16
  }): {
16
17
  config: {
17
18
  /**
@@ -26,7 +27,7 @@ export declare function createClient(config: {
26
27
  * Custom handler for non-200 response to a `.json()` request. By default, the
27
28
  * response is always parsed as JSON, regardless of the HTTP status code.
28
29
  */
29
- onJsonError?: (response: Response) => Response;
30
+ onJsonError?: (response: Response) => Promisable<Response>;
30
31
  };
31
32
  request<T extends RouteRequest>({ pathPattern, method, args: { path, query, body, headers }, route, }: T): Promise<Response & {
32
33
  json(): Promise<T["$result"]>;
@@ -1,4 +1,4 @@
1
- import { shake } from '../common';
1
+ import { shake } from '../common.js';
2
2
  export function createClient(config) {
3
3
  return {
4
4
  config,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './route';
2
- export * from './server/router';
3
- export * from './client/index';
4
- export type * from './types';
1
+ export * from './route.js';
2
+ export * from './server/router.js';
3
+ export * from './client/index.js';
4
+ export type * from './types.js';
5
5
  export * from 'alien-middleware';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './route';
2
- export * from './server/router';
3
- export * from './client/index';
1
+ export * from './route.js';
2
+ export * from './server/router.js';
3
+ export * from './client/index.js';
4
4
  export * from 'alien-middleware';
package/dist/route.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { RoutePattern } from '@remix-run/route-pattern';
2
- import type { Routes } from './types';
2
+ import type { MutationRoute, QueryRoute, RouteFunction, Routes, Unchecked } from './types.js';
3
3
  export declare function $type<T>(): Unchecked<T>;
4
4
  export declare function route<P extends string, T extends Routes>(path: P, routes: T): {
5
5
  path: P;
6
6
  pathPattern: RoutePattern<string>;
7
7
  routes: T;
8
- } & { [K in keyof T]: RouteFunction<any>; };
8
+ } & { [K in keyof T]: RouteFunction<Extract<T[K], MutationRoute | QueryRoute>>; };
package/dist/route.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RoutePattern } from '@remix-run/route-pattern';
2
- import { mapEntries } from './common';
2
+ import { mapEntries } from './common.js';
3
3
  export function $type() {
4
4
  return null;
5
5
  }
@@ -2,7 +2,7 @@ import type { AdapterRequestContext } from '@hattip/core';
2
2
  import { type Params } from '@remix-run/route-pattern';
3
3
  import { chain, MiddlewareChain, type MiddlewareContext } from 'alien-middleware';
4
4
  import * as z from 'zod/mini';
5
- import type { Routes } from '../types';
5
+ import type { InferRouteResponse, MutationRoute, Promisable, QueryRoute, Routes } from '../types.js';
6
6
  export { chain };
7
7
  type EmptyMiddlewareChain<TPlatform = unknown> = MiddlewareChain<{
8
8
  initial: {
@@ -34,11 +34,11 @@ export declare function createRouter<TRoutes extends Record<string, {
34
34
  query: z.infer<T["query"]>;
35
35
  params: Params<TRoutes[K]["path"]>;
36
36
  headers: z.infer<T["headers"]>;
37
- }) => Promisable<TResult | Response> : T extends MutationRoute ? (context: MiddlewareContext<TMiddleware> & {
37
+ }) => Promisable<Response | InferRouteResponse<T>> : T extends MutationRoute ? (context: MiddlewareContext<TMiddleware> & {
38
38
  body: z.infer<T["body"]>;
39
39
  params: Params<TRoutes[K]["path"]>;
40
40
  headers: z.infer<T["headers"]>;
41
- }) => Promisable<TResult | Response> : never : never : never; }; }) => import("alien-middleware").ApplyMiddleware<TMiddleware, (context: AdapterRequestContext<TMiddleware extends MiddlewareChain<infer T extends {
41
+ }) => Promisable<Response | InferRouteResponse<T>> : never : never : never; }; }) => import("alien-middleware").ApplyMiddleware<TMiddleware, (context: AdapterRequestContext<TMiddleware extends MiddlewareChain<infer T extends {
42
42
  initial: {
43
43
  env: object;
44
44
  properties: object;
@@ -1,6 +1,6 @@
1
1
  import { RoutePattern } from '@remix-run/route-pattern';
2
2
  import { chain, } from 'alien-middleware';
3
- import { mapValues } from '../common';
3
+ import { mapValues } from '../common.js';
4
4
  import * as z from 'zod/mini';
5
5
  export { chain };
6
6
  export function createRouter(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rouzer",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {