@@ -23,40 +23,41 @@ import {
2323
2424import {
2525 type CancelWorkflowRunParams ,
26+ type CreateEventRequest ,
27+ type CreateHookRequest ,
28+ type CreateStepRequest ,
2629 type CreateWorkflowRunRequest ,
30+ type Event ,
31+ EventSchema ,
32+ type GetHookParams ,
33+ type GetStepParams ,
2734 type GetWorkflowRunParams ,
35+ type Hook ,
36+ HookSchema ,
37+ ListEventsByCorrelationIdParams ,
38+ type ListEventsParams ,
2839 type ListWorkflowRunsParams ,
40+ ListWorkflowRunStepsParams ,
2941 type PauseWorkflowRunParams ,
3042 type ResumeWorkflowRunParams ,
31- type UpdateWorkflowRunRequest ,
32- type WorkflowRun ,
3343 type Step ,
34- type CreateStepRequest ,
35- type GetStepParams ,
44+ StepSchema ,
3645 type UpdateStepRequest ,
37- type Hook ,
38- type CreateHookRequest ,
39- type GetHookParams ,
40- type Event ,
41- type CreateEventRequest ,
42- type ListEventsParams ,
43- ListWorkflowRunStepsParams ,
44- ListEventsByCorrelationIdParams ,
46+ type UpdateWorkflowRunRequest ,
47+ type WorkflowRun ,
4548 WorkflowRunSchema ,
46- StepSchema ,
47- EventSchema ,
48- HookSchema ,
4949} from "@workflow/world" ;
5050import {
5151 DEFAULT_RESOLVE_DATA_OPTION ,
52+ filterEventData ,
53+ filterHookData ,
5254 filterRunData ,
5355 filterStepData ,
54- filterHookData ,
55- filterEventData ,
5656} from "./utils.js" ;
5757
5858import { JsonTransport } from "@vercel/queue" ;
59- import { QueueParamsSchema , serde } from "@restatedev/common" ;
59+ import { serde } from "@restatedev/restate-sdk-zod" ;
60+ import { schemas } from "@restatedev/common" ;
6061
6162// key by runId
6263
@@ -591,14 +592,12 @@ export const indexService = service({
591592 async ( ctx : Context , param : { token : string } ) : Promise < Hook > => {
592593 const hookTokens = ( await ctx
593594 . objectClient ( keyValue , param . token )
594- . get ( ) ) as { runId : string ; hookId : string } [ ] ;
595+ . get ( ) ) as string [ ] ;
595596
596597 if ( hookTokens === undefined || hookTokens . length === 0 ) {
597598 throw new TerminalError ( "No hooks found" , { errorCode : 404 } ) ;
598599 }
599- const theHook = hookTokens [ 0 ] ;
600- const hook = await ctx . objectClient ( hooksApi , theHook ! . hookId ) . get ( { } ) ;
601- return hook ;
600+ return await ctx . objectClient ( hooksApi , hookTokens [ 0 ] ! ) . get ( { } ) ;
602601 }
603602 ) ,
604603
@@ -626,7 +625,7 @@ export const queue = service({
626625 onMaxAttempts : "kill" ,
627626 } ,
628627
629- input : serde . zod ( QueueParamsSchema ) ,
628+ input : serde . zod ( schemas . QueueParamsSchema ) ,
630629 } ,
631630 async ( ctx : Context , params ) => {
632631 let pathname : string ;
@@ -650,7 +649,7 @@ export const queue = service({
650649 headers : {
651650 "x-vqs-queue-name" : params . queueName ,
652651 "x-vqs-message-id" : messageId ,
653- "x-vqs-message-attempt" : String ( 1 ) , // TODO: fix this.
652+ "x-vqs-message-attempt" : String ( params . attempt ) ,
654653 } ,
655654 }
656655 ) ;
@@ -661,11 +660,14 @@ export const queue = service({
661660 if ( response . status === 503 ) {
662661 const { retryIn } = ( await response . json ( ) ) as { retryIn : number } ;
663662
663+ // Increment attempt count
664+ params . attempt += 1 ;
665+
664666 ctx . serviceSendClient ( queue ) . queue (
665667 params ,
666668 rpc . sendOpts ( {
667669 delay : { seconds : retryIn } ,
668- input : serde . zod ( QueueParamsSchema ) ,
670+ input : serde . zod ( schemas . QueueParamsSchema ) ,
669671 } )
670672 ) ;
671673
0 commit comments