-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action-client): export a copy of safe action client from
/zod
…
…path (#115) Sometimes, TypeSchema causes errors with its dynamic import system, to handle multiple validation libraries. The code in this PR exports a copy of the safe action client from the `/zod` path, that support just Zod validation library, as the name implies. This should fix problems with the edge runtime and hopefully future bundler issues too.
- Loading branch information
Showing
13 changed files
with
338 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
export { createSafeActionClient } from "./safe-action-client"; | ||
import type { Schema } from "@typeschema/main"; | ||
import type { SafeActionClientOpts } from "./index.types"; | ||
import { createClientWithStrategy } from "./safe-action-client"; | ||
|
||
export { DEFAULT_SERVER_ERROR_MESSAGE, EMPTY_HOOK_RESULT as EMPTY_RESULT } from "./utils"; | ||
export { flattenBindArgsValidationErrors, flattenValidationErrors, returnValidationErrors } from "./validation-errors"; | ||
|
||
export type * from "./index.types"; | ||
export type * from "./validation-errors.types"; | ||
|
||
/** | ||
* Create a new safe action client. | ||
* @param createOpts Optional initialization options | ||
* | ||
* {@link https://next-safe-action.dev/docs/safe-action-client/initialization-options See docs for more information} | ||
*/ | ||
export const createSafeActionClient = <ServerError = string, MetadataSchema extends Schema | undefined = undefined>( | ||
createOpts?: SafeActionClientOpts<ServerError, MetadataSchema> | ||
) => { | ||
return createClientWithStrategy("typeschema", createOpts); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Schema } from "@typeschema/main"; | ||
import type { SafeActionClientOpts } from "./index.types"; | ||
import { createClientWithStrategy } from "./safe-action-client"; | ||
|
||
export { DEFAULT_SERVER_ERROR_MESSAGE, EMPTY_HOOK_RESULT as EMPTY_RESULT } from "./utils"; | ||
export { flattenBindArgsValidationErrors, flattenValidationErrors, returnValidationErrors } from "./validation-errors"; | ||
|
||
export type * from "./index.types"; | ||
export type * from "./validation-errors.types"; | ||
|
||
/** | ||
* Create a new safe action client. | ||
* Note: this client only works with Zod as the validation library. | ||
* This is needed when TypeSchema causes problems in your application. | ||
* Check out the [troubleshooting](https://next-safe-action.dev/docs/troubleshooting/errors-with-typeschema) page of the docs for more information. | ||
* @param createOpts Optional initialization options | ||
* | ||
* {@link https://next-safe-action.dev/docs/safe-action-client/initialization-options See docs for more information} | ||
*/ | ||
export const createSafeActionClient = <ServerError = string, MetadataSchema extends Schema | undefined = undefined>( | ||
createOpts?: SafeActionClientOpts<ServerError, MetadataSchema> | ||
) => { | ||
return createClientWithStrategy("zod", createOpts); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.