Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade library to version 4 #24

Merged
merged 45 commits into from
Oct 5, 2023
Merged

Upgrade library to version 4 #24

merged 45 commits into from
Oct 5, 2023

Conversation

TheEdoRan
Copy link
Owner

Library rewrite. Documentation and migration guide will be available on the new library website.

`action` -> `actionBuilder`, `serverFunction` -> `serverCode`.

BREAKING CHANGE: `ActionDefinition` type is now called `ServerCode`.
BREAKING CHANGE: Exported `HookRes` type is now called `HookResponse`. Same for the ex-`res` object
returned by hooks, now called `response`.
…`onError`

BREAKING CHANGE: `input` is now the second argument of `onSuccess` and `onError` callbacks, last one
is `reset` function.
Before action status via hooks was reported with multiple keys: `hasExecuted`, `isExecuting`,
`hasErrored`, `hasSucceded`. Now there's just a single `status` key, which can be `idle`,
`executing`, `hasSucceded`, `hasErrored`.

BREAKING CHANGE: Removed all current action status keys from the object returned by hooks. There's a
single key now called `status`, which indicates the action status via string.
…rErrorLog`

BREAKING CHANGE: initializer option `serverErrorLogFunction` is now called `handleServerErrorLog`
BREAKING CHANGE: `ClientCaller` type renamed to `SafeAction`
…ema`

`inputValidator` argument is now called `schema`. `IV` generic type is now called `Schema`.
If `safeParse` is used instead of `safeParseAsync`, Zod throws an error when a `superRefine()` is
used asynchronously.
`response` object is now called `result` everywhere. Same for `HookResponse` type, now called
`HookResult`.

BREAKING CHANGE: hooks `response` object renamed to `result`, exported `HookResponse` type renamed
to `HookResult`
BREAKING CHANGE: `useOptimisticAction` hook now requires a reducer function as third argument.
`execute` function returned by the hook now only has one argument, which is the safe action input.
Optimistic state update behavior is determined by the reducer's function body.
BREAKING CHANGE: `buildContext` client initialization option is now called `middleware`
@vercel
Copy link

vercel bot commented Oct 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
next-safe-action-example-app ✅ Ready (Inspect) Visit Preview Oct 4, 2023 11:56pm

@TheEdoRan TheEdoRan merged commit 4c8e752 into main Oct 5, 2023
5 checks passed
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@TheEdoRan TheEdoRan deleted the experimental branch October 23, 2023 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant