@adonisjs/inertia 4.0.0-next.11 → 4.0.0-next.13

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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { Tuyau } from '@tuyau/core/client';
3
- import type { AdonisRegistry } from '@tuyau/core/types';
3
+ import type { TuyauRegistry } from '@tuyau/core/types';
4
4
  /**
5
5
  * Provider component that makes the Tuyau client available to child components.
6
6
  *
@@ -8,7 +8,7 @@ import type { AdonisRegistry } from '@tuyau/core/types';
8
8
  * application that needs access to type-safe routing functionality.
9
9
  *
10
10
  */
11
- export declare function TuyauProvider<R extends AdonisRegistry>(props: {
11
+ export declare function TuyauProvider<R extends TuyauRegistry>(props: {
12
12
  children: React.ReactNode;
13
13
  client: Tuyau<R>;
14
14
  }): React.JSX.Element;
@@ -21,4 +21,4 @@ export declare function TuyauProvider<R extends AdonisRegistry>(props: {
21
21
  * @returns The Tuyau client instance with full type safety
22
22
  * @throws Error if used outside of a TuyauProvider
23
23
  */
24
- export declare function useTuyau(): Tuyau<any>;
24
+ export declare function useTuyau(): Tuyau<any, any>;
@@ -1,23 +1,24 @@
1
1
  import React from 'react';
2
- import type { UserRegistry } from '@tuyau/core/types';
2
+ import type { UserRegistry, InferRoutes } from '@tuyau/core/types';
3
3
  import { AreAllOptional } from '@poppinss/utils/types';
4
4
  import { Link as InertiaLink } from '@inertiajs/react';
5
+ type Routes = InferRoutes<UserRegistry>;
5
6
  /**
6
7
  * Get parameter tuple type for a route
7
8
  */
8
- type ExtractParamsTuple<Route extends keyof UserRegistry> = UserRegistry[Route]['types']['paramsTuple'];
9
+ type ExtractParamsTuple<Route extends keyof Routes> = Routes[Route]['types']['paramsTuple'];
9
10
  /**
10
11
  * Get parameter object type for a route
11
12
  */
12
- type ExtractParamsObject<Route extends keyof UserRegistry> = UserRegistry[Route]['types']['params'];
13
+ type ExtractParamsObject<Route extends keyof Routes> = Routes[Route]['types']['params'];
13
14
  /**
14
15
  * Get params format for a route
15
16
  */
16
- type RouteParamsFormats<Route extends keyof UserRegistry> = ExtractParamsObject<Route> extends Record<string, never> ? never : ExtractParamsTuple<Route> | ExtractParamsObject<Route>;
17
+ type RouteParamsFormats<Route extends keyof Routes> = ExtractParamsObject<Route> extends Record<string, never> ? never : ExtractParamsTuple<Route> | ExtractParamsObject<Route>;
17
18
  /**
18
19
  * Parameters required for route navigation with proper type safety.
19
20
  */
20
- export type LinkParams<Route extends keyof UserRegistry> = {
21
+ export type LinkParams<Route extends keyof Routes> = {
21
22
  route: Route;
22
23
  } & (RouteParamsFormats<Route> extends never ? {
23
24
  params?: never;
@@ -30,7 +31,7 @@ export type LinkParams<Route extends keyof UserRegistry> = {
30
31
  * Props for the Link component extending InertiaLink props
31
32
  * with route-specific type safety and parameter validation.
32
33
  */
33
- type LinkProps<Route extends keyof UserRegistry> = Omit<React.ComponentPropsWithoutRef<typeof InertiaLink>, 'href' | 'method'> & LinkParams<Route>;
34
+ type LinkProps<Route extends keyof Routes> = Omit<React.ComponentPropsWithoutRef<typeof InertiaLink>, 'href' | 'method'> & LinkParams<Route>;
34
35
  /**
35
36
  * Internal Link component implementation with forward ref support.
36
37
  * Resolves route parameters and generates the appropriate URL and HTTP method
@@ -39,7 +40,7 @@ type LinkProps<Route extends keyof UserRegistry> = Omit<React.ComponentPropsWith
39
40
  * @param props - Link properties including route and parameters
40
41
  * @param ref - Forward ref for the underlying InertiaLink component
41
42
  */
42
- declare function LinkInner<Route extends keyof UserRegistry>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>): React.JSX.Element;
43
+ declare function LinkInner<Route extends keyof Routes>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>): React.JSX.Element;
43
44
  /**
44
45
  * Type-safe Link component for Inertia.js navigation.
45
46
  *
@@ -58,7 +59,7 @@ declare function LinkInner<Route extends keyof UserRegistry>(props: LinkProps<Ro
58
59
  * </Link>
59
60
  * ```
60
61
  */
61
- export declare const Link: <Route extends keyof UserRegistry>(props: LinkProps<Route> & {
62
+ export declare const Link: <Route extends keyof Routes>(props: LinkProps<Route> & {
62
63
  ref?: React.Ref<React.ElementRef<typeof InertiaLink>>;
63
64
  }) => ReturnType<typeof LinkInner>;
64
65
  export {};
@@ -1,4 +1,4 @@
1
- import type { UserRegistry } from '@tuyau/core/types';
1
+ import type { UserRegistry, InferRoutes } from '@tuyau/core/types';
2
2
  import { router as InertiaRouter } from '@inertiajs/react';
3
3
  import type { LinkParams } from './link.tsx';
4
4
  /**
@@ -29,5 +29,5 @@ export declare function useRouter(): {
29
29
  * router.visit({ route: 'user.edit', params: { id: userId } })
30
30
  * ```
31
31
  */
32
- visit: <Route extends keyof UserRegistry>(props: LinkParams<Route>, options?: Parameters<typeof InertiaRouter.visit>[1]) => any;
32
+ visit: <Route extends keyof InferRoutes<UserRegistry>>(props: LinkParams<Route>, options?: Parameters<typeof InertiaRouter.visit>[1]) => any;
33
33
  };
@@ -1,64 +1,67 @@
1
- declare const routes: {
2
- readonly 'users.index': {
3
- readonly methods: ["GET", "HEAD"];
4
- readonly pattern: "/";
5
- readonly tokens: [{
6
- readonly old: "/";
7
- readonly type: 0;
8
- readonly val: "/";
9
- readonly end: "";
10
- }];
11
- readonly types: {
12
- body: {};
13
- paramsTuple: [];
14
- params: {};
15
- query: {};
16
- response: unknown;
1
+ declare const registry: {
2
+ routes: {
3
+ readonly 'users.index': {
4
+ readonly methods: ["GET", "HEAD"];
5
+ readonly pattern: "/";
6
+ readonly tokens: [{
7
+ readonly old: "/";
8
+ readonly type: 0;
9
+ readonly val: "/";
10
+ readonly end: "";
11
+ }];
12
+ readonly types: {
13
+ body: {};
14
+ paramsTuple: [];
15
+ params: {};
16
+ query: {};
17
+ response: unknown;
18
+ };
17
19
  };
18
- };
19
- readonly 'users.comments.edit': {
20
- readonly methods: ["GET", "HEAD"];
21
- readonly pattern: "/users/:id/comments/:comment_id/edit";
22
- readonly tokens: [{
23
- readonly old: "/users";
24
- readonly type: 0;
25
- readonly val: "users";
26
- readonly end: "/";
27
- }, {
28
- readonly old: ":id";
29
- readonly type: 1;
30
- readonly val: "id";
31
- readonly end: "/";
32
- }, {
33
- readonly old: "/comments";
34
- readonly type: 0;
35
- readonly val: "comments";
36
- readonly end: "/";
37
- }, {
38
- readonly old: ":comment_id";
39
- readonly type: 1;
40
- readonly val: "comment_id";
41
- readonly end: "/edit";
42
- }, {
43
- readonly old: "/edit";
44
- readonly type: 0;
45
- readonly val: "edit";
46
- readonly end: "";
47
- }];
48
- readonly types: {
49
- body: {};
50
- paramsTuple: [string, string];
51
- params: {
52
- id: string;
53
- comment_id: string;
20
+ readonly 'users.comments.edit': {
21
+ readonly methods: ["GET", "HEAD"];
22
+ readonly pattern: "/users/:id/comments/:comment_id/edit";
23
+ readonly tokens: [{
24
+ readonly old: "/users";
25
+ readonly type: 0;
26
+ readonly val: "users";
27
+ readonly end: "/";
28
+ }, {
29
+ readonly old: ":id";
30
+ readonly type: 1;
31
+ readonly val: "id";
32
+ readonly end: "/";
33
+ }, {
34
+ readonly old: "/comments";
35
+ readonly type: 0;
36
+ readonly val: "comments";
37
+ readonly end: "/";
38
+ }, {
39
+ readonly old: ":comment_id";
40
+ readonly type: 1;
41
+ readonly val: "comment_id";
42
+ readonly end: "/edit";
43
+ }, {
44
+ readonly old: "/edit";
45
+ readonly type: 0;
46
+ readonly val: "edit";
47
+ readonly end: "";
48
+ }];
49
+ readonly types: {
50
+ body: {};
51
+ paramsTuple: [string, string];
52
+ params: {
53
+ id: string;
54
+ comment_id: string;
55
+ };
56
+ query: {};
57
+ response: unknown;
54
58
  };
55
- query: {};
56
- response: unknown;
57
59
  };
58
60
  };
61
+ $tree: any;
59
62
  };
60
63
  declare module '@tuyau/core/types' {
61
- type Registry = typeof routes;
64
+ type Registry = typeof registry;
62
65
  interface UserRegistry extends Registry {
63
66
  }
64
67
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/inertia",
3
3
  "description": "Official Inertia.js adapter for AdonisJS",
4
- "version": "4.0.0-next.11",
4
+ "version": "4.0.0-next.13",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -60,7 +60,7 @@
60
60
  "@japa/snapshot": "^2.0.9",
61
61
  "@poppinss/ts-exec": "^1.4.1",
62
62
  "@release-it/conventional-changelog": "^10.0.2",
63
- "@tuyau/core": "^1.0.0-beta.1",
63
+ "@tuyau/core": "^1.0.0-beta.5",
64
64
  "@types/node": "^24.10.1",
65
65
  "@types/react": "^19.2.7",
66
66
  "@types/supertest": "^6.0.3",
@@ -92,7 +92,7 @@
92
92
  "@inertiajs/react": "^2.2.15",
93
93
  "@japa/api-client": "^3.1.0",
94
94
  "@japa/plugin-adonisjs": "^5.0.0-next.0",
95
- "@tuyau/core": "^1.0.0-beta.1",
95
+ "@tuyau/core": "^1.0.0-beta.5",
96
96
  "edge.js": "^6.0.0",
97
97
  "react": "^19.2.0"
98
98
  },