Skip to content

Commit

Permalink
refactor: add clientInput and bindArgsClientInputs to server code…
Browse files Browse the repository at this point in the history
… function args
  • Loading branch information
TheEdoRan committed Dec 15, 2024
1 parent 6371ef2 commit 199a09f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/next-safe-action/src/action-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ export function actionBuilder<
scfArgs[0] = {
parsedInput: parsedInputDatas.at(-1) as IS extends Schema ? Infer<IS> : undefined,
bindArgsParsedInputs: parsedInputDatas.slice(0, -1) as InferArray<BAS>,
clientInput: clientInputs.at(-1) as IS extends Schema ? InferIn<IS> : undefined,
bindArgsClientInputs: (bindArgsSchemas.length ? clientInputs.slice(0, -1) : []) as InferInArray<BAS>,
ctx: currentCtx as Ctx,
metadata: args.metadata,
};
Expand Down
4 changes: 4 additions & 0 deletions packages/next-safe-action/src/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export type ServerCodeFn<
Data,
> = (args: {
parsedInput: S extends Schema ? Infer<S> : undefined;
clientInput: S extends Schema ? InferIn<S> : undefined;
bindArgsParsedInputs: InferArray<BAS>;
bindArgsClientInputs: InferInArray<BAS>;
ctx: Prettify<Ctx>;
metadata: MD;
}) => Promise<Data>;
Expand All @@ -143,7 +145,9 @@ export type StateServerCodeFn<
> = (
args: {
parsedInput: S extends Schema ? Infer<S> : undefined;
clientInput: S extends Schema ? InferIn<S> : undefined;
bindArgsParsedInputs: InferArray<BAS>;
bindArgsClientInputs: InferInArray<BAS>;
ctx: Prettify<Ctx>;
metadata: MD;
},
Expand Down

0 comments on commit 199a09f

Please sign in to comment.