Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TheEdoRan/next-safe-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.9.2
Choose a base ref
...
head repository: TheEdoRan/next-safe-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.9.3
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Sep 8, 2024

  1. chore(website): fix bind args validation errors shape customizer func…

    …tion name in example
    TheEdoRan committed Sep 8, 2024
    Copy the full SHA
    b1f0601 View commit details

Commits on Sep 13, 2024

  1. chore: update pnpm to 9.10.0

    TheEdoRan committed Sep 13, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    495ecba View commit details
  2. fix: export SafeActionClient type to make it portable (#267) (#269)

    Includes the `SafeActionClient` into the types export to make the
    inferred type of `createSafeActionClient` portable in order to avoid the
    error [TS2742](https://typescript.tv/errors/#ts2742). It enables
    declaring the action client in a shared package and import it in the
    other apps or packages.
    
    closes #64
    
    Co-authored-by: Bruno Moreira <bruno@brunormoreira.com>
    TheEdoRan and brunorodmoreira authored Sep 13, 2024
    Copy the full SHA
    197ec51 View commit details
Showing with 12 additions and 3 deletions.
  1. +1 −1 package.json
  2. +9 −0 packages/next-safe-action/src/index.types.ts
  3. +2 −2 website/docs/define-actions/validation-errors.md
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -38,5 +38,5 @@
"is-ci": "^3.0.1",
"turbo": "^2.1.1"
},
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
"packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
}
9 changes: 9 additions & 0 deletions packages/next-safe-action/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -272,3 +272,12 @@ export type InferServerError<T> = T extends
| SafeStateActionFn<infer ServerError, any, any, any, any, any>
? ServerError
: never;


/**
* Type of the core safe action client.
*/
export {
SafeActionClient
};

4 changes: 2 additions & 2 deletions website/docs/define-actions/validation-errors.md
Original file line number Diff line number Diff line change
@@ -45,14 +45,14 @@ export const loginUser = actionClient
// Here we use the `flattenBindArgsValidatonErrors` function to customize the returned bind args
// validation errors object array to the client.
// highlight-next-line
handleBindArgsValidationErrors: (ve, utils) => flattenBindArgsValidationErrors(ve),
handleBindArgsValidationErrorsShape: (ve, utils) => flattenBindArgsValidationErrors(ve),
})
.action(async ({ parsedInput: { username, password } }) => {
// Your code here...
});
```

The second argument of both `handleValidationErrorsShape` and `handleBindArgsValidationErrors` functions is an `utils` object that contains info about the current action execution (`clientInput`, `bindArgsClientInputs`, `metadata` and `ctx` properties). It's passed to the functions to allow granular and dynamic customization of the validation errors shape.
The second argument of both `handleValidationErrorsShape` and `handleBindArgsValidationErrorsShape` functions is an `utils` object that contains info about the current action execution (`clientInput`, `bindArgsClientInputs`, `metadata` and `ctx` properties). It's passed to the functions to allow granular and dynamic customization of the validation errors shape.

:::note
If you chain multiple `schema` methods, as explained in the [Extend previous schema](/docs/define-actions/extend-previous-schemas) page, and want to override the default validation errors shape, you **must** use `handleValidationErrorsShape` inside the last `schema` method, otherwise there would be a type mismatch in the returned action result.