@@ -130,8 +130,8 @@ export class SafeActionClient<
130
130
* {@link https://next-safe-action.dev/docs/safe-action-client/instance-methods#schema See docs for more information}
131
131
*/
132
132
schema <
133
- OS extends Schema | ( ( ) => Promise < Schema > ) ,
134
- AS extends Schema = OS extends ( ) => Promise < Schema > ? Awaited < ReturnType < OS > > : OS , // actual schema
133
+ OS extends Schema | ( ( prevSchema : S ) => Promise < Schema > ) ,
134
+ AS extends Schema = OS extends ( prevSchema : S ) => Promise < Schema > ? Awaited < ReturnType < OS > > : OS , // actual schema
135
135
OCVE = ODVES extends "flattened" ? FlattenedValidationErrors < ValidationErrors < AS > > : ValidationErrors < AS > ,
136
136
> (
137
137
schema : OS ,
@@ -147,7 +147,13 @@ export class SafeActionClient<
147
147
metadataSchema : this . #metadataSchema,
148
148
metadata : this . #metadata,
149
149
// @ts -expect-error
150
- schemaFn : ( schema [ Symbol . toStringTag ] === "AsyncFunction" ? schema : async ( ) => schema ) as SF ,
150
+ schemaFn : ( schema [ Symbol . toStringTag ] === "AsyncFunction"
151
+ ? async ( ) => {
152
+ const prevSchema = await this . #schemaFn?.( ) ;
153
+ // @ts -expect-error
154
+ return schema ( prevSchema as S ) as AS ;
155
+ }
156
+ : async ( ) => schema ) as SF ,
151
157
bindArgsSchemas : this . #bindArgsSchemas,
152
158
handleValidationErrorsShape : ( utils ?. handleValidationErrorsShape ??
153
159
this . #handleValidationErrorsShape) as HandleValidationErrorsShapeFn < AS , OCVE > ,
0 commit comments