@firtoz/router-toolkit 3.0.3 → 3.0.5
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/package.json +2 -2
- package/src/formAction.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firtoz/router-toolkit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"description": "Type-safe React Router 7 framework mode helpers with enhanced fetching, form submission, and state management",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"README.md"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
29
|
+
"typecheck": "tsc --noEmit -p ./tsconfig.json",
|
|
30
30
|
"lint": "biome check --write src",
|
|
31
31
|
"lint:ci": "biome ci src",
|
|
32
32
|
"format": "biome format src --write",
|
package/src/formAction.ts
CHANGED
|
@@ -34,10 +34,10 @@ import { zfd } from "zod-form-data";
|
|
|
34
34
|
/**
|
|
35
35
|
* Error types that can be returned by formAction
|
|
36
36
|
*/
|
|
37
|
-
export type FormActionError<TError> =
|
|
37
|
+
export type FormActionError<TError, TSchema extends z.ZodTypeAny> =
|
|
38
38
|
| {
|
|
39
39
|
type: "validation";
|
|
40
|
-
error: ReturnType<typeof z.treeifyError<z.
|
|
40
|
+
error: ReturnType<typeof z.treeifyError<z.infer<TSchema>>>;
|
|
41
41
|
}
|
|
42
42
|
| {
|
|
43
43
|
type: "handler";
|
|
@@ -150,7 +150,7 @@ export const formAction = <
|
|
|
150
150
|
}: FormActionConfig<TSchema, TResult, TError, ActionArgs>) => {
|
|
151
151
|
return async (
|
|
152
152
|
args: ActionArgs,
|
|
153
|
-
): Promise<MaybeError<TResult, FormActionError<TError>>> => {
|
|
153
|
+
): Promise<MaybeError<TResult, FormActionError<TError, TSchema>>> => {
|
|
154
154
|
try {
|
|
155
155
|
const rawFormData = await args.request.formData();
|
|
156
156
|
const formData = await zfd.formData(schema).safeParseAsync(rawFormData);
|
|
@@ -158,8 +158,8 @@ export const formAction = <
|
|
|
158
158
|
if (!formData.success) {
|
|
159
159
|
return fail({
|
|
160
160
|
type: "validation" as const,
|
|
161
|
-
error: z.treeifyError<TSchema
|
|
162
|
-
formData.error as z.core.$ZodError<TSchema
|
|
161
|
+
error: z.treeifyError<z.infer<TSchema>>(
|
|
162
|
+
formData.error as z.core.$ZodError<z.infer<TSchema>>,
|
|
163
163
|
),
|
|
164
164
|
});
|
|
165
165
|
}
|