@@ -173,11 +173,13 @@ function exportReturns(functionDefinition: FunctionDefinition) {
173
173
export const mutationGeneric : MutationBuilder < any , "public" > = ( (
174
174
functionDefinition : FunctionDefinition ,
175
175
) => {
176
- const func = (
176
+ const handler = (
177
177
typeof functionDefinition === "function"
178
178
? functionDefinition
179
179
: functionDefinition . handler
180
180
) as RegisteredMutation < "public" , any , any > ;
181
+ const func = ( ( ctx : any , args : any ) =>
182
+ handler ( ctx , args ) ) as RegisteredMutation < "public" , any , any > ;
181
183
182
184
// Helpful runtime check that functions are only be registered once
183
185
if ( func . isRegistered ) {
@@ -190,6 +192,7 @@ export const mutationGeneric: MutationBuilder<any, "public"> = ((
190
192
func . invokeMutation = ( argsStr ) => invokeMutation ( func , argsStr ) ;
191
193
func . exportArgs = exportArgs ( functionDefinition ) ;
192
194
func . exportReturns = exportReturns ( functionDefinition ) ;
195
+ func . _handler = handler ;
193
196
return func ;
194
197
} ) as MutationBuilder < any , "public" > ;
195
198
@@ -209,11 +212,13 @@ export const mutationGeneric: MutationBuilder<any, "public"> = ((
209
212
export const internalMutationGeneric : MutationBuilder < any , "internal" > = ( (
210
213
functionDefinition : FunctionDefinition ,
211
214
) => {
212
- const func = (
215
+ const handler = (
213
216
typeof functionDefinition === "function"
214
217
? functionDefinition
215
218
: functionDefinition . handler
216
219
) as RegisteredMutation < "internal" , any , any > ;
220
+ const func = ( ( ctx : any , args : any ) =>
221
+ handler ( ctx , args ) ) as RegisteredMutation < "internal" , any , any > ;
217
222
218
223
// Helpful runtime check that functions are only be registered once
219
224
if ( func . isRegistered ) {
@@ -226,6 +231,7 @@ export const internalMutationGeneric: MutationBuilder<any, "internal"> = ((
226
231
func . invokeMutation = ( argsStr ) => invokeMutation ( func , argsStr ) ;
227
232
func . exportArgs = exportArgs ( functionDefinition ) ;
228
233
func . exportReturns = exportReturns ( functionDefinition ) ;
234
+ func . _handler = handler ;
229
235
return func ;
230
236
} ) as MutationBuilder < any , "internal" > ;
231
237
@@ -263,11 +269,16 @@ async function invokeQuery<
263
269
export const queryGeneric : QueryBuilder < any , "public" > = ( (
264
270
functionDefinition : FunctionDefinition ,
265
271
) => {
266
- const func = (
272
+ const handler = (
267
273
typeof functionDefinition === "function"
268
274
? functionDefinition
269
275
: functionDefinition . handler
270
276
) as RegisteredQuery < "public" , any , any > ;
277
+ const func = ( ( ctx : any , args : any ) => handler ( ctx , args ) ) as RegisteredQuery <
278
+ "public" ,
279
+ any ,
280
+ any
281
+ > ;
271
282
272
283
// Helpful runtime check that functions are only be registered once
273
284
if ( func . isRegistered ) {
@@ -280,6 +291,7 @@ export const queryGeneric: QueryBuilder<any, "public"> = ((
280
291
func . invokeQuery = ( argsStr ) => invokeQuery ( func , argsStr ) ;
281
292
func . exportArgs = exportArgs ( functionDefinition ) ;
282
293
func . exportReturns = exportReturns ( functionDefinition ) ;
294
+ func . _handler = handler ;
283
295
return func ;
284
296
} ) as QueryBuilder < any , "public" > ;
285
297
@@ -299,11 +311,16 @@ export const queryGeneric: QueryBuilder<any, "public"> = ((
299
311
export const internalQueryGeneric : QueryBuilder < any , "internal" > = ( (
300
312
functionDefinition : FunctionDefinition ,
301
313
) => {
302
- const func = (
314
+ const handler = (
303
315
typeof functionDefinition === "function"
304
316
? functionDefinition
305
317
: functionDefinition . handler
306
318
) as RegisteredQuery < "internal" , any , any > ;
319
+ const func = ( ( ctx : any , args : any ) => handler ( ctx , args ) ) as RegisteredQuery <
320
+ "internal" ,
321
+ any ,
322
+ any
323
+ > ;
307
324
308
325
// Helpful runtime check that functions are only be registered once
309
326
if ( func . isRegistered ) {
@@ -316,6 +333,7 @@ export const internalQueryGeneric: QueryBuilder<any, "internal"> = ((
316
333
func . invokeQuery = ( argsStr ) => invokeQuery ( func as any , argsStr ) ;
317
334
func . exportArgs = exportArgs ( functionDefinition ) ;
318
335
func . exportReturns = exportReturns ( functionDefinition ) ;
336
+ func . _handler = handler ;
319
337
return func ;
320
338
} ) as QueryBuilder < any , "internal" > ;
321
339
@@ -349,11 +367,13 @@ async function invokeAction<
349
367
export const actionGeneric : ActionBuilder < any , "public" > = ( (
350
368
functionDefinition : FunctionDefinition ,
351
369
) => {
352
- const func = (
370
+ const handler = (
353
371
typeof functionDefinition === "function"
354
372
? functionDefinition
355
373
: functionDefinition . handler
356
374
) as RegisteredAction < "public" , any , any > ;
375
+ const func = ( ( ctx : any , args : any ) =>
376
+ handler ( ctx , args ) ) as RegisteredAction < "public" , any , any > ;
357
377
358
378
// Helpful runtime check that functions are only be registered once
359
379
if ( func . isRegistered ) {
@@ -367,6 +387,7 @@ export const actionGeneric: ActionBuilder<any, "public"> = ((
367
387
invokeAction ( func , requestId , argsStr ) ;
368
388
func . exportArgs = exportArgs ( functionDefinition ) ;
369
389
func . exportReturns = exportReturns ( functionDefinition ) ;
390
+ func . _handler = handler ;
370
391
return func ;
371
392
} ) as ActionBuilder < any , "public" > ;
372
393
@@ -384,11 +405,13 @@ export const actionGeneric: ActionBuilder<any, "public"> = ((
384
405
export const internalActionGeneric : ActionBuilder < any , "internal" > = ( (
385
406
functionDefinition : FunctionDefinition ,
386
407
) => {
387
- const func = (
408
+ const handler = (
388
409
typeof functionDefinition === "function"
389
410
? functionDefinition
390
411
: functionDefinition . handler
391
412
) as RegisteredAction < "internal" , any , any > ;
413
+ const func = ( ( ctx : any , args : any ) =>
414
+ handler ( ctx , args ) ) as RegisteredAction < "internal" , any , any > ;
392
415
393
416
// Helpful runtime check that functions are only be registered once
394
417
if ( func . isRegistered ) {
@@ -402,6 +425,7 @@ export const internalActionGeneric: ActionBuilder<any, "internal"> = ((
402
425
invokeAction ( func , requestId , argsStr ) ;
403
426
func . exportArgs = exportArgs ( functionDefinition ) ;
404
427
func . exportReturns = exportReturns ( functionDefinition ) ;
428
+ func . _handler = handler ;
405
429
return func ;
406
430
} ) as ActionBuilder < any , "internal" > ;
407
431
@@ -437,7 +461,9 @@ export const httpActionGeneric = (
437
461
request : Request ,
438
462
) => Promise < Response > ,
439
463
) : PublicHttpAction => {
440
- const q = func as unknown as PublicHttpAction ;
464
+ const handler = func as unknown as PublicHttpAction ;
465
+ const q = ( ( ctx : any , request : any ) =>
466
+ handler ( ctx , request ) ) as PublicHttpAction ;
441
467
// Helpful runtime check that functions are only be registered once
442
468
if ( q . isRegistered ) {
443
469
throw new Error ( "Function registered twice " + func ) ;
@@ -446,6 +472,7 @@ export const httpActionGeneric = (
446
472
q . isRegistered = true ;
447
473
q . isHttp = true ;
448
474
q . invokeHttpAction = ( request ) => invokeHttpAction ( func as any , request ) ;
475
+ q . _handler = func ;
449
476
return q ;
450
477
} ;
451
478
0 commit comments