Skip to content

Commit 74c0dc8

Browse files
committedMay 9, 2024··
refactor(hooks): export EMPTY_HOOK_RESULT just from /hooks path
1 parent 17935ad commit 74c0dc8

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed
 

‎packages/next-safe-action/src/hooks.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ import type {
1313
HookSafeActionFn,
1414
HookSafeStateActionFn,
1515
} from "./hooks.types";
16-
import { EMPTY_HOOK_RESULT, isError } from "./utils";
16+
import { isError } from "./utils";
17+
18+
/**
19+
* Default value for `result` object returned by `useAction`, `useOptimisticAction` and `useStateAction` hooks.
20+
*/
21+
export const EMPTY_HOOK_RESULT = {
22+
data: undefined,
23+
fetchError: undefined,
24+
serverError: undefined,
25+
validationErrors: undefined,
26+
} satisfies HookResult<any, any, any, any, any, any>;
1727

1828
const getActionStatus = <
1929
ServerError,
@@ -318,6 +328,4 @@ export const useStateAction = <
318328
};
319329
};
320330

321-
export { EMPTY_HOOK_RESULT };
322-
323331
export type * from "./hooks.types";

‎packages/next-safe-action/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Schema } from "@typeschema/main";
22
import type { SafeActionClientOpts } from "./index.types";
33
import { createClientWithStrategy } from "./safe-action-client";
44

5-
export { DEFAULT_SERVER_ERROR_MESSAGE, EMPTY_HOOK_RESULT as EMPTY_RESULT } from "./utils";
5+
export { DEFAULT_SERVER_ERROR_MESSAGE } from "./utils";
66
export { flattenBindArgsValidationErrors, flattenValidationErrors, returnValidationErrors } from "./validation-errors";
77

88
export type * from "./index.types";

‎packages/next-safe-action/src/utils.ts

-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Infer, InferIn, Schema } from "@typeschema/main";
2-
import type { HookResult } from "./hooks.types";
32

43
export const DEFAULT_SERVER_ERROR_MESSAGE = "Something went wrong while executing the operation.";
54

@@ -24,13 +23,3 @@ export type InferArray<BAS extends readonly Schema[]> = {
2423
export type InferInArray<BAS extends readonly Schema[]> = {
2524
[K in keyof BAS]: InferIn<BAS[K]>;
2625
};
27-
28-
/**
29-
* Default value for `result` object returned by `useAction`, `useOptimisticAction` and `useStateAction` hooks.
30-
*/
31-
export const EMPTY_HOOK_RESULT = {
32-
data: undefined,
33-
fetchError: undefined,
34-
serverError: undefined,
35-
validationErrors: undefined,
36-
} satisfies HookResult<any, any, any, any, any, any>;

‎packages/next-safe-action/src/zod.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Schema } from "@typeschema/main";
22
import type { SafeActionClientOpts } from "./index.types";
33
import { createClientWithStrategy } from "./safe-action-client";
44

5-
export { DEFAULT_SERVER_ERROR_MESSAGE, EMPTY_HOOK_RESULT as EMPTY_RESULT } from "./utils";
5+
export { DEFAULT_SERVER_ERROR_MESSAGE } from "./utils";
66
export { flattenBindArgsValidationErrors, flattenValidationErrors, returnValidationErrors } from "./validation-errors";
77

88
export type * from "./index.types";

0 commit comments

Comments
 (0)