@@ -15,7 +15,6 @@ import type {
1515 ObjectType ,
1616 PropertyValidators ,
1717 Validator ,
18- Value ,
1918} from "convex/values" ;
2019import { asObjectValidator , v } from "convex/values" ;
2120import type {
@@ -92,12 +91,20 @@ export type Customization<
9291 | Promise < {
9392 ctx : CustomCtx ;
9493 args : CustomMadeArgs ;
95- onSuccess ?: ( result : unknown ) => void | Promise < void > ;
94+ onSuccess ?: ( obj : {
95+ ctx : Ctx ;
96+ args : Record < string , unknown > ;
97+ result : unknown ;
98+ } ) => void | Promise < void > ;
9699 } >
97100 | {
98101 ctx : CustomCtx ;
99102 args : CustomMadeArgs ;
100- onSuccess ?: ( result : unknown ) => void | Promise < void > ;
103+ onSuccess ?: ( obj : {
104+ ctx : Ctx ;
105+ args : Record < string , unknown > ;
106+ result : unknown ;
107+ } ) => void | Promise < void > ;
101108 } ;
102109} ;
103110
@@ -201,7 +208,7 @@ export const NoOp = {
201208 * return {
202209 * ctx: { db, user, session },
203210 * args: {},
204- * onSuccess: (result) => {
211+ * onSuccess: ({ result } ) => {
205212 * // Optional callback that runs after the function executes
206213 * // Has access to resources created during input processing
207214 * console.log(`Query for ${user.name} returned:`, result);
@@ -289,7 +296,7 @@ export function customQuery<
289296 * return {
290297 * ctx: { db, user, session },
291298 * args: {},
292- * onSuccess: (result) => {
299+ * onSuccess: ({ result } ) => {
293300 * // Optional callback that runs after the function executes
294301 * // Has access to resources created during input processing
295302 * console.log(`User ${user.name} returned:`, result);
@@ -381,7 +388,7 @@ export function customMutation<
381388 * return {
382389 * ctx: { user },
383390 * args: {},
384- * onSuccess: (result) => {
391+ * onSuccess: ({ result } ) => {
385392 * // Optional callback that runs after the function executes
386393 * // Has access to resources created during input processing
387394 * logger.info(`Action for user ${user.name} returned:`, result);
@@ -484,9 +491,10 @@ function customFnBuilder(
484491 ) ;
485492 const args = omit ( allArgs , Object . keys ( inputArgs ) ) ;
486493 const finalCtx = { ...ctx , ...added . ctx } ;
487- const result = await handler ( finalCtx , { ...args , ...added . args } ) ;
494+ const finalArgs = { ...args , ...added . args } ;
495+ const result = await handler ( finalCtx , finalArgs ) ;
488496 if ( added . onSuccess ) {
489- await added . onSuccess ( result ?? null ) ;
497+ await added . onSuccess ( { ctx , args , result } ) ;
490498 }
491499 return result ;
492500 } ,
@@ -503,9 +511,10 @@ function customFnBuilder(
503511 handler : async ( ctx : any , args : any ) => {
504512 const added = await customInput ( ctx , args , extra ) ;
505513 const finalCtx = { ...ctx , ...added . ctx } ;
506- const result = await handler ( finalCtx , { ...args , ...added . args } ) ;
514+ const finalArgs = { ...args , ...added . args } ;
515+ const result = await handler ( finalCtx , finalArgs ) ;
507516 if ( added . onSuccess ) {
508- await added . onSuccess ( result ?? null ) ;
517+ await added . onSuccess ( { ctx , args , result } ) ;
509518 }
510519 return result ;
511520 } ,
0 commit comments