Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

server-act

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

server-act - npm Package Compare versions

Comparing version 0.0.10 to 1.0.0

6

CHANGELOG.md
# server-act
## 1.0.0
### Major Changes
- b4318a8: Get `formAction` out of experimental!
## 0.0.10

@@ -4,0 +10,0 @@

4

dist/index.d.ts

@@ -38,5 +38,5 @@ import { z } from 'zod';

/**
* ***Experimental*** - Create an action for React `useFormState`
* Create an action for React `useFormState`
*/
experimental_formAction: <TState>(action: (params: Prettify<{
formAction: <TState>(action: (params: Prettify<{
ctx: InferContextType<TParams['_context']>;

@@ -43,0 +43,0 @@ prevState: any;

@@ -154,3 +154,3 @@ "use strict";

},
experimental_formAction: (action) => {
formAction: (action) => {
return async (prevState, formData) => {

@@ -157,0 +157,0 @@ var _a;

{
"name": "server-act",
"version": "0.0.10",
"version": "1.0.0",
"homepage": "https://github.com/chungweileong94/server-act#readme",

@@ -5,0 +5,0 @@ "repository": {

@@ -83,5 +83,8 @@ # Server-Act

### _(Experimental)_ `useFormState` Support
### `useFormState` Support
> `useFormState` Documentation: https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#error-handling
> `useFormState` Documentation:
>
> - https://nextjs.org/docs/app/building-your-application/data-fetching/forms-and-mutations#error-handling
> - https://react.dev/reference/react-dom/hooks/useFormState

@@ -103,3 +106,3 @@ ```ts

)
.experimental_formAction(async ({ input, formErrors, ctx }) => {
.formAction(async ({ input, formErrors, ctx }) => {
if (formErrors) {

@@ -106,0 +109,0 @@ return { formErrors: formErrors.formErrors.fieldErrors };

@@ -67,3 +67,3 @@ import {test, expect, expectTypeOf, vi, beforeEach, describe} from 'vitest';

test('should able to create form action without input', async () => {
const action = serverAct.experimental_formAction(async () => Promise.resolve('bar'));
const action = serverAct.formAction(async () => Promise.resolve('bar'));

@@ -79,5 +79,3 @@ expectTypeOf(action).parameter(0).toBeString();

test('should able to create form action with input', async () => {
const action = serverAct
.input(z.object({foo: z.string()}))
.experimental_formAction(async () => Promise.resolve('bar'));
const action = serverAct.input(z.object({foo: z.string()})).formAction(async () => Promise.resolve('bar'));

@@ -96,3 +94,3 @@ expectTypeOf(action).parameter(0).toBeString();

.input(z.object({foo: z.string({required_error: 'Required'})}))
.experimental_formAction(async ({formErrors}) => {
.formAction(async ({formErrors}) => {
if (formErrors) {

@@ -99,0 +97,0 @@ return formErrors;

@@ -50,5 +50,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */

/**
* ***Experimental*** - Create an action for React `useFormState`
* Create an action for React `useFormState`
*/
experimental_formAction: <TState>(
formAction: <TState>(
action: (

@@ -105,3 +105,3 @@ params: Prettify<

},
experimental_formAction: (action) => {
formAction: (action) => {
return async (prevState, formData) => {

@@ -108,0 +108,0 @@ const ctx = await _def.middleware?.();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc