Skip to content

Commit e21c47e

Browse files
authored
Merge pull request #345 from TheEdoRan/beta
Version 8
2 parents cc804e8 + 3ccc930 commit e21c47e

File tree

126 files changed

+4471
-5203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+4471
-5203
lines changed

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
.turbo
4+
.next
5+
*.md
6+
*.mdx

packages/next-safe-action/.prettierrc.json renamed to .prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"tabWidth": 2,
77
"semi": true,
88
"singleQuote": false,
9-
"quoteProps": "consistent"
9+
"quoteProps": "consistent",
10+
"plugins": ["prettier-plugin-tailwindcss"]
1011
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"editor.rulers": [120],
88
"[markdown]": {
99
"editor.formatOnSave": false
10-
}
10+
},
11+
"typescript.tsdk": "node_modules/typescript/lib"
1112
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
**Explore the documentation for the current stable version of the library on the [next-safe-action v7 website](https://next-safe-action.dev).**
2121

22-
### Looking for v6 docs?
22+
### Looking for v7 docs?
2323

24-
You can keep using version 6 and eventually upgrade to version 7. Check out the v6 documentation [here](https://v6.next-safe-action.dev).
24+
You can keep using version 6 and eventually upgrade to version 7. Check out the v7 documentation [here](https://v7.next-safe-action.dev).
2525

26-
## Migrate from v6 to v7
26+
## Migrate from v7 to v8
2727

28-
Check out the [v6 to v7 migration guide](https://next-safe-action.dev/docs/migrations/v6-to-v7) to learn how to update your code for v7.
28+
Check out the [v7 to v8 migration guide](https://next-safe-action.dev/docs/migrations/v7-to-v8) to learn how to update your code for v8.
2929

3030
## Installation
3131

apps/playground/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
},
1111
"author": "Edoardo Ranghieri",
1212
"dependencies": {
13-
"@hookform/resolvers": "^3.10.0",
14-
"lucide-react": "^0.474.0",
15-
"next": "15.1.6",
13+
"@hookform/resolvers": "^4.1.3",
14+
"lucide-react": "^0.483.0",
15+
"next": "catalog:",
1616
"next-safe-action": "workspace:*",
17-
"react": "^19",
18-
"react-dom": "^19",
17+
"react": "catalog:",
18+
"react-dom": "catalog:",
1919
"react-hook-form": "^7.54.2",
20-
"zod": "^3.24.1",
21-
"zod-form-data": "^2.0.5"
20+
"zod": "^3.24.2",
21+
"zod-form-data": "^2.0.7"
2222
},
2323
"devDependencies": {
2424
"@types/node": "^22",
2525
"@types/react": "^19",
2626
"@types/react-dom": "^19",
27-
"autoprefixer": "10.4.20",
28-
"eslint": "^8.57.0",
29-
"eslint-config-next": "15.1.6",
30-
"postcss": "8.5.1",
27+
"autoprefixer": "10.4.21",
28+
"eslint": "catalog:",
29+
"eslint-config-next": "catalog:",
30+
"postcss": "8.5.3",
3131
"tailwindcss": "^3",
32-
"typescript": "^5.7.3"
32+
"typescript": "catalog:"
3333
}
3434
}

apps/playground/src/app/(examples)/async-schema/login-action.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"use server";
22

33
import { action } from "@/lib/safe-action";
4-
import {
5-
flattenValidationErrors,
6-
returnValidationErrors,
7-
} from "next-safe-action";
4+
import { flattenValidationErrors, returnValidationErrors } from "next-safe-action";
85
import { z } from "zod";
96

107
async function getSchema() {
@@ -16,11 +13,10 @@ async function getSchema() {
1613

1714
export const loginUser = action
1815
.metadata({ actionName: "loginUser" })
19-
.schema(getSchema, {
16+
.inputSchema(getSchema, {
2017
// Here we use the `flattenValidationErrors` function to customize the returned validation errors
2118
// object to the client.
22-
handleValidationErrorsShape: async (ve) =>
23-
flattenValidationErrors(ve).fieldErrors,
19+
handleValidationErrorsShape: async (ve) => flattenValidationErrors(ve).fieldErrors,
2420
})
2521
.action(async ({ parsedInput: { username, password } }) => {
2622
if (username === "johndoe") {

apps/playground/src/app/(examples)/async-schema/page.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,10 @@ export default function AsyncSchemaPage() {
2828
};
2929
const res = await loginUser(input); // this is the type safe action directly called
3030
setResult(res);
31-
}}>
32-
<StyledInput
33-
type="text"
34-
name="username"
35-
id="username"
36-
placeholder="Username"
37-
/>
38-
<StyledInput
39-
type="password"
40-
name="password"
41-
id="password"
42-
placeholder="Password"
43-
/>
31+
}}
32+
>
33+
<StyledInput type="text" name="username" id="username" placeholder="Username" />
34+
<StyledInput type="password" name="password" id="password" placeholder="Password" />
4435
<StyledButton type="submit">Log in</StyledButton>
4536
</form>
4637
<ResultBox result={result} />

apps/playground/src/app/(examples)/bind-arguments/onboard-action.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@ const schema = z.object({
77
username: z.string().min(3).max(30),
88
});
99

10-
const bindArgsSchemas: [userId: z.ZodString, age: z.ZodNumber] = [
11-
z.string().uuid(),
12-
z.number().min(18).max(150),
13-
];
10+
const bindArgsSchemas: [userId: z.ZodString, age: z.ZodNumber] = [z.string().uuid(), z.number().min(18).max(150)];
1411

1512
export const onboardUser = action
1613
.metadata({ actionName: "onboardUser" })
17-
.schema(schema)
14+
.inputSchema(schema)
1815
.bindArgsSchemas(bindArgsSchemas)
19-
.action(
20-
async ({
21-
parsedInput: { username },
22-
bindArgsParsedInputs: [userId, age],
23-
}) => {
24-
await new Promise((res) => setTimeout(res, 1000));
16+
.action(async ({ parsedInput: { username }, bindArgsParsedInputs: [userId, age] }) => {
17+
await new Promise((res) => setTimeout(res, 1000));
2518

26-
return {
27-
message: `Welcome on board, ${username}! (age = ${age}, user id = ${userId})`,
28-
};
29-
}
30-
);
19+
return {
20+
message: `Welcome on board, ${username}! (age = ${age}, user id = ${userId})`,
21+
};
22+
});

apps/playground/src/app/(examples)/bind-arguments/page.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import { ResultBox } from "../../_components/result-box";
88
import { onboardUser } from "./onboard-action";
99

1010
export default function BindArguments() {
11-
const boundOnboardUser = onboardUser.bind(
12-
null,
13-
crypto.randomUUID(),
14-
Math.floor(Math.random() * 200)
15-
);
11+
const boundOnboardUser = onboardUser.bind(null, crypto.randomUUID(), Math.floor(Math.random() * 200));
1612

1713
const { execute, result, status, reset } = useAction(boundOnboardUser);
1814

@@ -32,13 +28,9 @@ export default function BindArguments() {
3228

3329
// Action call.
3430
execute(input);
35-
}}>
36-
<StyledInput
37-
type="text"
38-
name="username"
39-
id="username"
40-
placeholder="Username"
41-
/>
31+
}}
32+
>
33+
<StyledInput type="text" name="username" id="username" placeholder="Username" />
4234
<StyledButton type="submit">Onboard user</StyledButton>
4335
<StyledButton type="button" onClick={reset}>
4436
Reset

apps/playground/src/app/(examples)/direct/login-action.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"use server";
22

33
import { action } from "@/lib/safe-action";
4-
import {
5-
flattenValidationErrors,
6-
returnValidationErrors,
7-
} from "next-safe-action";
4+
import { flattenValidationErrors, returnValidationErrors } from "next-safe-action";
85
import { z } from "zod";
96

107
const schema = z.object({
@@ -14,11 +11,10 @@ const schema = z.object({
1411

1512
export const loginUser = action
1613
.metadata({ actionName: "loginUser" })
17-
.schema(schema, {
14+
.inputSchema(schema, {
1815
// Here we use the `flattenValidationErrors` function to customize the returned validation errors
1916
// object to the client.
20-
handleValidationErrorsShape: async (ve) =>
21-
flattenValidationErrors(ve).fieldErrors,
17+
handleValidationErrorsShape: async (ve) => flattenValidationErrors(ve).fieldErrors,
2218
})
2319
.action(
2420
async ({ parsedInput: { username, password } }) => {

0 commit comments

Comments
 (0)